使用 Raspberry Pi Raspbian Jessie Lite 架設一個網路監控系統,但很奇怪的是設定好固定 IP 後,系統好像會自動出多一個 IP。
使用 ip 指令可以查詢到 2 個 IP
# ip addr show eth0 | grep ‘inet’ | grep -v ‘inet6’ | awk ‘{print $2}’
192.168.1.74/24
192.168.1.82/24
使用 ifconfig 指令只能查詢一個 IP
# ifconfig eth0 | grep ‘inet addr’ | awk ‘{print $2}’ | awk -F’:’ ‘{print $2}’
192.168.1.74[@more@]可是在 /etc/network/interfaces 只設定了一個 IP
# cat /etc/network/interfaces
iface eth0 inet static
address 192.168.1.74
netmask 255.255.255.0
gateway 192.168.1.254
dns-nameservers 168.95.1.1
解決方式:
1. 關閉 dhcpcd 服務
# systemctl stop dhcpcd.service
2. 取消開機時啟動 dhcpcd 服務
# systemctl disable dhcpcd.service
Synchronizing state for dhcpcd.service with sysvinit using update-rc.d…
Executing /usr/sbin/update-rc.d dhcpcd defaults
insserv: warning: current start runlevel(s) (empty) of script `dhcpcd’ overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dhcpcd’ overrides LSB defaults (0 1 6).
Executing /usr/sbin/update-rc.d dhcpcd disable
insserv: warning: current start runlevel(s) (empty) of script `dhcpcd’ overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dhcpcd’ overrides LSB defaults (0 1 6).
3. 重新啟啟動電腦
# sysnc;sync;reboot