BeagleBone Black 静态 IP 地址发生奇怪变化

BeagleBone Black 静态 IP 地址发生奇怪变化

我将 BBB 设置为静态 IP 地址,如下所示:

root@beaglebone:/var/log# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 192.168.0.99
    netmask 255.255.255.0
    gateway 192.168.0.1
# Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE

# WiFi Example
#auto wlan0
#iface wlan0 inet dhcp
#    wpa-ssid "essid"
#    wpa-psk  "password"

# Ethernet/RNDIS gadget (g_ether)
# ... or on host side, usbnet and random hwaddr
# Note on some boards, usb0 is automaticly setup with an init script
# in that case, to completely disable remove file [run_boot-scripts] from the boot partition
iface usb0 inet static
    address 192.168.7.2
    netmask 255.255.255.0
    network 192.168.7.0
    gateway 192.168.7.1

中国的DNS配置如下:

root@beaglebone:/var/log# cat /etc/resolv.conf
nameserver 202.96.128.86
nameserver 202.96.134.33

从2015-12-15 17:04:33到2015-12-22 23:03:41,我的BBB在静态IP地址192.168.0.99上工作得很好。之后,我的BBB静态IP地址奇怪地变成了192.168.0.128:

root@beaglebone:/var/log# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether d0:5f:b8:e8:b3:86 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.128/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::d25f:b8ff:fee8:b386/64 scope link
       valid_lft forever preferred_lft forever
3: usb0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether ba:5c:46:47:5f:c1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.7.2/30 brd 192.168.7.3 scope global usb0

以及/var/log/messages下面的类似内容(为什么?):

Dec 22 23:03:41 beaglebone kernel: [626417.699238] libphy: 4a101000.mdio:00 - Link is Down
Dec 22 23:03:44 beaglebone kernel: [626420.411322] net eth0: initializing cpsw version 1.12 (0)
Dec 22 23:03:44 beaglebone kernel: [626420.414330] net eth0: phy found : id is : 0x7c0f1
Dec 22 23:03:44 beaglebone kernel: [626420.430487] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Dec 22 23:03:45 beaglebone kernel: [626421.064855] net eth0: initializing cpsw version 1.12 (0)
Dec 22 23:03:45 beaglebone kernel: [626421.067713] net eth0: phy found : id is : 0x7c0f1
Dec 22 23:03:45 beaglebone kernel: [626421.083786] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Dec 22 23:03:47 beaglebone kernel: [626423.075018] libphy: 4a101000.mdio:00 - Link is Up - 100/Full
Dec 22 23:03:47 beaglebone kernel: [626423.075152] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
Dec 22 23:03:51 beaglebone kernel: [626427.215227] net eth0: initializing cpsw version 1.12 (0)
Dec 22 23:03:51 beaglebone kernel: [626427.218207] net eth0: phy found : id is : 0x7c0f1
Dec 22 23:03:51 beaglebone kernel: [626427.234320] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Dec 22 23:03:51 beaglebone kernel: [626427.637475] net eth0: initializing cpsw version 1.12 (0)
Dec 22 23:03:51 beaglebone kernel: [626427.640382] net eth0: phy found : id is : 0x7c0f1
Dec 22 23:03:51 beaglebone kernel: [626427.656675] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Dec 22 23:03:53 beaglebone kernel: [626429.645608] libphy: 4a101000.mdio:00 - Link is Up - 100/Full
Dec 22 23:03:53 beaglebone kernel: [626429.645732] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

uname -a的如下:

Linux beaglebone 3.8.13-bone47 #1 SMP Fri Apr 11 01:36:09 UTC 2014 armv7l GNU/Linux

没有人访问 BeagleBone 来更改其 ip,为什么eth0在2015-12-22 23:03:41左右忽上忽下?为什么down和up后静态IP地址变了?

附言。

  • BeagleBone 从未重新启动过
  • 我发现了一个类似的Q静态IP地址转移到192.168.1.251,这没有帮助
  • 我检查了命令历史记录,在 2015-12-22 23:03:41 左右没有找到命令

更新1我发现热插拔网线会出现上述情况,而且dmesg出现的情况和上面一样,请问是什么原因呢?也许我的交换机昨晚在 2015-12-22 23:03:41 左右重新启动,我不确定

更新2

root@beaglebone:~# ps ax | grep dhc
 1132 ?        Ss     0:00 /usr/sbin/udhcpd -S /etc/udhcpd.conf
10022 ?        Ss     0:00 /sbin/dhclient -v eth0
20352 pts/1    S+     0:00 grep dhc

答案1

当热插拔网线时,dhcp-client 会更改静态 IP 地址。

临时解决方案:

mv /sbin/dhclient /sbin/dhclient.bak

答案2

首先做:

apt-get purge connman dnsmasq*

/etc/network/interfaces然后你在配置中注释掉usb0。然后eth0像这样更改为静态:

auto eth0
iface eth0 inet static
address 192.168.0.99
netmask 255.255.255.0
gateway 192.168.0.1

不要忘记在/etc/resolv.conf.

nameserver 8.8.8.8
nameserver 8.8.4.4

相关内容