見出し画像

RasPi Buster Overlay のネットワーク

Overlay による Read-only 設定」で紹介した機能ですが、有線接続で使うと困った現象をみつけて、私なりに対策して使っています。

おそらく、Buster のバグの類で、いずれ修正される不具合だと思います。

課題

どうやら、Overlay Enable の時と、Disable の時ではネットワーク接続の挙動が違うように見えます。

Ethernet 接続がある場合、Overlay Disable で固定IPで動いていたものが、Overlay Enable にするとDHCP接続になる様に見えます。
同じ動作にしたいと思います。

最初に認識した具体的事例

/etc/dhcpcd.conf の内容が同じなのに、Overlay Enable と Disable では IPアドレスが異なるようです

ハードウェア Raspberry Pi 3B
ネットワークの設定は /etc/wpa_supplicant/wpa_supplicant.conf と /etc/dhcpcd.conf で行っています。

/etc/wpa_supplicant/wpa_supplicant.conf については接続出来ていることから問題ないと思いますので、 /etc/dhcpcd.conf の内容を示します。

/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
# It 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

interface wlan0
static ip_address=192.168.11.170/24
static routers=192.168.11.1
static domain_name_servers=192.168.11.1
static domain_search=
noipv6

interface eth0
static ip_address=192.168.11.170/24
static routers=192.168.11.1
static domain_name_servers=192.168.11.1
static domain_search=
noipv6

Disable では /etc/dhcpcd.conf で指定した固定IPが得られるのに対して、Overlay Enable ではDHCPで割り振られたと思われるIPアドレスになっています。

元々、WiFi 環境で試験した時には気付かなかった(固定IPだった)のですが、有線接続したらDHCPに変わってしまったように思います。

ルータA環境
WiFi で接続し、Overlay Enable で /etc/dpcd.conf に指定した固定IPを得ていました。

ルーターB環境(IP はルーターAと同じ)
Overlay Enable で(WiFi OFF) 有線接続すると DHCP で得たIP(若番)で接続されます。
この状態でWiFiをONにしてもIPは変わりません。LANケーブルを抜き差ししてもIPは変わりませんでした。

同じ設定のまま、Overlay Disable にし(WiFi OFF) 有線接続すると /etc/dhcpcd.conf に指定した固定IPを得ています。

現象の整理

念の為、最初にアップデートを行いました。
sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo apt dist-upgrade
reboot

Overlay Disable
WiFi ON で起動 → wlan0 192.168.11.170/24
Ethernet 接続 → wlan0 192.168.11.170/24
         eth0  192.168.11.170/24

WiFi ON , Ethernet 接続状態で起動
wlan0 192.168.11.170/24
eth0  192.168.11.170/24

WiFi OFF , Ethernet 接続状態で起動
eth0  192.168.11.170/24

Overlay Enable
WiFi ON で起動 → wlan0 192.168.11.170/24
Ethernet 接続( eth0: ではなく以下のように表示される)

enxb827ebb53495: Configured 192.168.11.15/24
wlan0: Configured 192.168.11.170/24

ケーブルを抜き差ししても enxb827ebb53495: Configured 192.168.11.15/24ケーブルを抜いて5分放置後にケーブルを挿しても
enxb827ebb53495: Configured 192.168.11.15/24

eth0: ではなくて、見慣れない enxb827ebb53495: になるところにヒントがありそうです。(文字列はRasPi毎に変化するようです)

Ethernet と WiFi で異なるIPが使えるようですが、目先の課題としてはOverlay Enable の時にも、Overlay Disable と同じ動きをしてほしいのです。

参考URLと私的対策

<<< 同様の報告 >>>

デバイス名 eth0 が enxb827ebb53495 に変わってしまうようなので、先程の /etc/dhcpcd.conf に以下を追記して試してみました。

interface enxb827ebb53495
static ip_address=192.168.11.170/24
static routers=192.168.11.1
static domain_name_servers=192.168.11.1
static domain_search=
noipv6

Overlay Enable , WiFi OFF , Ethernet ケーブル接続で起動したところ、指定した固定IPで立ち上がりました。この状態で WiFi ON にすると、これも指定した固定IPを獲得します。

enx に続く文字列は Ethernet モジュールのMACアドレスと一致しています。
これらはLXTerminal から ip addr show (略して ip a)コマンドで確認出来ます。

個々の Raspberry Pi 毎に異なる /etc/dhcpcd.conf を書くことになりますが、私にとって唯一の解決策です。

暗中模索の無策状態を脱し、だいぶ安心しました。


もっと良い方法や、お気付きの点などありましたら、教えていただけると助かります。



出来ればサポート頂けると、嬉しいです。 新しい基板や造形品を作る資金等に使いたいと思います。