■概要
Raspberry Pi 2(Raspbian)で固定IPを設定をします。
なお、Debianの標準的なやり方で固定IPを設定すると下記のような症状が発生し、ネットワークが何かのタイミングで切れることがありました。
/var/log/syslog
Jan 17 06:35:19 raspberrypi01 dhcpcd[3414]: eth0: carrier lost
Jan 17 06:35:19 raspberrypi01 kernel: [4512912.336501] smsc95xx 1-1.1:1.0 eth0: link down
原因は、Raspbianにはraspberrypi-net-modsというカスタマイズがされているからっぽいです。
■手順
・su -
・cd /etc/
・cp -p dhcpcd.conf dhcpcd.conf.org
・vi dhcpcd.conf
下記の2行をファイルの一番上に追加。IPは固定したい物で書き換えてください。
dhcpcd.conf
interface eth0
static ip_address=192.168.178.1/24
・reboot
・ifconfigで確認
完了です。お疲れ様でした。
■既に/etc/network/interfacesで固定IPを設定している場合
/etc/network/interfaces eth0をmanualに戻す必要があるそうです。
それか、raspberrypi-net-modsをアンインストールすれば良さそう。
参考サイトを参照してみてください。
■参考
Raspberry Pi • View topic - Eth0 doesn't keep static IP
https://www.raspberrypi.org/forums/viewtopic.php?t=120982&p=817858