furuhashilab / raspberrypi4unvt

Raspberry Pi Case for UNVT
1 stars 0 forks source link

ラズパイがインターネットにつながらない #7

Open ShogoHirasawa opened 2 years ago

ShogoHirasawa commented 2 years ago

このサイトを参考にして、Apacheをインストールするため $ sudo apt-get updateを実行しようとしたら、以下のエラーが表示された。

Err:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Temporary failure resolving 'raspbian.raspberrypi.org' Err:2 http://archive.raspberrypi.org/debian buster InRelease
Temporary failure resolving 'archive.raspberrypi.org' Reading package lists... Done
W: Failed to fetch http://raspbian.raspberrypi.org/raspbian/dists/buster/InRelease Temporary failure resolving 'raspbian.raspberrypi.org' W: Failed to fetch http://archive.raspberrypi.org/debian/dists/buster/InRelease Temporary failure resolving 'archive.raspberrypi.org' W: Some index files failed to download. They have been ignored, or old ones used instead.

解決策としてこのサイトに記載してあった以下のコマンドを打つがこれも失敗し、上記のエラーコードが吐き出された。

Misa0716 commented 2 years ago

Temporary failure resolving 'raspbian.raspberrypi.org'ということは名前解決ができていないのだと思います。 ラズパイに設定しているDNSサーバのIPアドレスを確認してみてください。 ちなみにうちは同じネットワーク内にDNSサーバがいないので、デフォゲ(BBルータ)のIPを設定しています。

ShogoHirasawa commented 2 years ago

これって要はラズパイに固定のIPアドレスを振ってないから起きてる問題ってことなんでしょうか? 名前解決ができていない=IPアドレスが固定化されていないという認識であっていますでしょうか? ド素人の質問ですいません...m( )m

Misa0716 commented 2 years ago

ラズパイ自体に固定IPを振っていないのは直接関係なくて、デフォルトゲートウェイやDNSサーバIPの設定がないことが原因だと思います。 ちょっと確認したいのですが、今ラズパイはインターネットに接続できる状態ですか?

Misa0716 commented 2 years ago

ちょっとこのあと席外すので先に上げちゃいますね。 たぶんインターネット接続できない状態じゃないかなーとは思ってます笑 ちなみに私はインターネット接続あるなしを確かめるときはgoogleかyahooのIPアドレスにラズパイからpingを打ってます。

名前解決についてはここで説明すると長くなるので先人の知恵をお借りします笑 参考→https://pfs.nifcloud.com/navi/beginner/dns.htm

今回の事象はこれと同じかなーと思ってます。 https://teratail.com/questions/222148

インターネットに出る経路(デフォルトゲートウェイ)の設定がないのと、名前解決の依頼先(DNSサーバのIP)を知らないのが原因だと思うので、ラズパイに固定のIPを振って、デフォゲとDNSに自宅のホームゲートウェイのIPを設定したらいけると思います。

ホームゲートウェイについてはこちら↓ https://dream.jp/ftth/tips_f/hikari32.html

ShogoHirasawa commented 2 years ago

名前解決ができておらず、ネットに接続できていなかったので、設定をしようとしたのですが、うまくいきませんでした....。いまいち解決策がわからず、悶絶しています泣

現状、家のルーター(デフォルトゲートウェイ)のIPは192.168.11.1でした

スクリーンショット 2021-11-10 23 37 01

arp -a コマンドでIPの192.168.11.3が空いていることを確認して、/etc/dhcpcd.confに以下の通りに記載しました

スクリーンショット 2021-11-10 23 37 43

ifconfigコマンドでIP設定ができているかどうかを確認したところ、以下の通りになりました。(有線でつないでいます)

スクリーンショット 2021-11-10 23 39 14

rootコマンドでルートテーブルを確認しようとしたところ何も表示されないという状態です。

スクリーンショット 2021-11-10 23 38 57
Misa0716 commented 2 years ago

遅くなってすみません汗 1枚目の画像はラズパイのGUI設定画面であってます?

私が知っている画面とちょっと違うので自信がないのですが、 「IPv4の設定」のところをDHCPサーバを使用しないにできますかね🤔

パッと解決策出てこないので私の設定値共有しますね。 root@FilePi:~# cat /etc/dhcpcd.conf

A sample configuration for dhcpcd.

See dhcpcd.conf(5) for details.

Allow users of this group to interact with dhcpcd via the control socket.

controlgroup wheel

Inform the DHCP server of our hostname for DDNS.

hostname

Use the hardware address of the interface for the Client ID.

clientid

or

Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.

Some non-RFC compliant DHCP servers do not reply with this set.

In this case, comment out duid and enable clientid above.

duid

Persist interface configuration when dhcpcd exits.

persistent

Rapid commit support.

Safe to enable by default because it requires the equivalent option set

on the server to actually work.

option rapid_commit

A list of options to request from the DHCP server.

option domain_name_servers, domain_name, domain_search, host_name option classless_static_routes

Respect the network MTU. This is applied to DHCP routes.

option interface_mtu

Most distributions have NTP support.

option ntp_servers

A ServerID is required by RFC2131.

require dhcp_server_identifier

Generate SLAAC address using the Hardware Address of the interface

slaac hwaddr

OR generate Stable Private IPv6 Addresses based from the DUID

slaac private

Example static IP configuration:

interface eth0

static ip_address=192.168.0.10/24

static ip6_address=fd51:42f8:caae:d92e::ff/64

static routers=192.168.0.1

static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

t is possible to fall back to a static IP if DHCP fails:

define static profile

profile static_eth0

static ip_address=192.168.1.23/24

static routers=192.168.1.1

static domain_name_servers=192.168.1.1

fallback to static profile on eth0

interface eth0

fallback static_eth0

SSID elecom5g-783729  ←うちのWIFI inform 192.168.2.109/24  static routers=192.168.2.1 static domain_name_servers=192.168.2.1

SSID elecom5g-783729 ←うちのWIFI inform 192.168.2.109/24 static routers=192.168.2.1 static domain_name_servers=192.168.2.1

root@FilePi:~# ifconfig eth0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether dc:a6:32:36:5f:bb txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.2.109 netmask 255.255.255.0 broadcast 192.168.2.255 inet6 fe80::6e4f:dad4:b39:f164 prefixlen 64 scopeid 0x20 ether dc:a6:32:36:5f:bc txqueuelen 1000 (Ethernet) RX packets 7466 bytes 3768447 (3.5 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13228 bytes 3013805 (2.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

root@FilePi:~# ip route default via 192.168.2.1 dev wlan0 src 192.168.2.109 metric 303 192.168.2.0/24 dev wlan0 proto dhcp scope link src 192.168.2.109 metric 303

ちょっと調べてみます~!

Misa0716 commented 2 years ago

1枚目のGUIでの設定?のIPv4の設定のところが「192.168.11.12」になっていますが、 /etc/dhcpcd.confのIPv4固定アドレス値が「192.168.11.3」になっています。 ここどっちかの値に統一させたらつながるかもです。

moruku36 commented 2 years ago

もう解決してるかもですが、 30分ぐらいzoom繋いで画面共有しながらリアルタイムでペアプロするといいかもしれないですね。

ShogoHirasawa commented 2 years ago

いろいろ試してみたのですが、なかなかうまくいかないんですよね...。 ペアプロして頂ける人がいたら嬉しいです....泣

ShogoHirasawa commented 2 years ago

ここのIsuueをみて解決しました https://github.com/furuhashilab/raspberrypi4unvt/issues/3