LoginSignup
0
0

More than 3 years have passed since last update.

Raspbian Buster で eth0:1 にスタティックIPを割り当てる

Last updated at Posted at 2019-12-21

環境

  • 2019-09-26-Raspbian Buster Lite
  • Raspberry Pi 3 Model B

やりたいこと

eth0 の dhcp クライアント設定を残したままで、169.254ではじまるリンクローカルアドレスレンジでもアクセスできるようにします。
169.254.12.24 を eth0:1 に割り当てたいと考えました。

解決法

/etc/rc.local の最後に以下を書きます。


ifconfig eth0:1 169.254.12.24
exit 0

結果


pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.42.12  netmask 255.255.255.0  broadcast 192.168.42.255
        inet6 fe80::651b:9046:3a77:39da  prefixlen 64  scopeid 0x20<link>
        inet6 240b:10:a261:a200:39f1:7e0c:58a6:c4b1  prefixlen 64  scopeid 0x0<global>
        ether b8:27:eb:50:88:58  txqueuelen 1000  (Ethernet)
        RX packets 845  bytes 77211 (75.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 602  bytes 85997 (83.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 169.254.12.24  netmask 255.255.0.0  broadcast 169.254.255.255
        ether b8:27:eb:50:88:58  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        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=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:27:eb:05:dd:0d  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


問題点

dhcpサーバの挙動でIPアドレスが再割り当てされると、eth0:1も消去されるのではないかな? RaspberryPiの挙動はまだ確認できてないため、追って報告予定。

どうしてこんな方法を?

本来なら /etc/dhcpcd.conf や /etc/dhcpcd.exit-hook に書くのだけれど、どうも
RaspberryPi3と Raspbian Busterの組み合わせでは固定IP設定に難があるらしいです。
cf., https://www.raspberrypi.org/forums/viewtopic.php?t=245701#p1577134

また、ip コマンドでのセカンダリアドレスの設定もうまくいかず、結局 rc.local と ifconfig のレガシー組み合わせになりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0