Help us understand the problem. What is going on with this article?

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

環境

  • 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 のレガシー組み合わせになりました。

nanbuwks
iotlt
IoT縛りの勉強会です。 毎月イベントを実施しているので是非遊びに来てください! 登壇者を中心にQiitaでも情報発信していきます。 https://iotlt.connpass.com
https://iotlt.connpass.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした