看来我的 Ubuntu 14 一直在删除我的 eth0 的 IP 地址。
有其他人见过这种情况吗?我应该从哪里开始检查?
我没有日志可显示:设置ifconfig eth0 10.10.0.4 netmask 255.0.0.0
IP 地址后在 ifconfig 中可见,但几分钟后就消失了。
编辑 :
$ dmesg | grep eth0
[ 5.293971] tg3 0000:04:00.0 eth0: Tigon3 [partno(BCM95723) rev 5784100] (PCI Express) MAC address 3c:4a:92:b2:a2:1e
[ 5.293974] tg3 0000:04:00.0 eth0: attached PHY is 5784 (10/100/1000Base-T Ethernet) (WireSpeed[1], EEE[0])
[ 5.293976] tg3 0000:04:00.0 eth0: RXcsums[1] LinkChgREG[0] MIirq[0] ASF[1] TSOcap[1]
[ 5.293978] tg3 0000:04:00.0 eth0: dma_rwctrl[76180000] dma_mask[64-bit]
[ 9.124499] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 10.758438] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 10.758756] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 13.183081] tg3 0000:04:00.0 eth0: Link is up at 1000 Mbps, full duplex
[ 13.183091] tg3 0000:04:00.0 eth0: Flow control is on for TX and on for RX
[ 13.183104] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
答案1
您必须在 /etc/network/interfaces 文件中进行设置
静态 IP 的格式如下:
auto eth0
iface eth0 inet static
address 10.10.0.4
netmask 255.0.0.0
gateway 10.10.0.1
broadcast 10.255.255.255
network 10.0.0.0
dns-nameservers 8.8.8.8 8.8.4.4
dns-search domain-search.com
如果你想要 dhcp:
auto eth0
iface eth0 inet dhcp
之后,保存文件并重新启动网络:/etc/init.d/networking restart(我相信这是老方法,但应该可行)。