我使用的是 beaglebone black 和最新的 IoT Debian 9 映像 (BeagleBoard.org Debian Image 2018-03-05)
以下是我配置网络接口的方法:
/etc/网络/接口
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.220
netmask 255.255.255.0
gateway 192.168.0.155
# Ethernet/RNDIS gadget (g_ether)
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.252
network 192.168.7.0
gateway 192.168.7.1
# Nameservers
dns-nameservers 192.168.0.155
启动界面后,我的路由表如下所示:
debian@beaglebone:~$ ip route
default via 192.168.0.155 dev eth0 onlink
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.220
192.168.6.0/30 dev usb1 proto kernel scope link src 192.168.6.2 linkdown
192.168.7.0/30 dev usb0 proto kernel scope link src 192.168.7.2
我可以通过默认网关访问互联网,一切正常,但 1-2 分钟后会出现一些其他条目。
现在我的路由表如下所示:
debian@beaglebone:~$ ip route
default dev eth0 scope link
default via 192.168.0.155 dev eth0 onlink
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.220
169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.66.227
192.168.6.0/30 dev usb1 proto kernel scope link src 192.168.6.2 linkdown
192.168.7.0/30 dev usb0 proto kernel scope link src 192.168.7.2
现在似乎使用了上层默认网关,而不是我定义的网关。因此,互联网(和其他内部网络)无法访问。
仅当 eth0 连接到网络时才会发生这种情况。我正在使用的网络中的所有其他设备也是静态配置的。
如何让我的系统使用我希望它使用的默认网关?
我已经尝试从 usb0 中删除默认网关或将其放入单独的路由表中,这导致无法通过任何接口访问 beaglebone。
这是 ifconfig 的输出,以防万一有人在这里发现可疑的东西。
debian@beaglebone:~$ ifconfig
eth0: flags=-28605<UP,BROADCAST,RUNNING,MULTICAST,DYNAMIC> mtu 1500
inet 192.168.0.220 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::564a:16ff:fee5:e79d prefixlen 64 scopeid 0x20<link>
ether 54:4a:16:e5:e7:9d txqueuelen 1000 (Ethernet)
RX packets 79 bytes 9988 (9.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 458 bytes 85028 (83.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 181
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 1 (Local Loopback)
RX packets 180 bytes 14118 (13.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 180 bytes 14118 (13.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.7.2 netmask 255.255.255.252 broadcast 192.168.7.3
inet6 fe80::564a:16ff:fee5:e79f prefixlen 64 scopeid 0x20<link>
ether 54:4a:16:e5:e7:9f txqueuelen 1000 (Ethernet)
RX packets 740 bytes 79447 (77.5 KiB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 525 bytes 97473 (95.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
usb1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.6.2 netmask 255.255.255.252 broadcast 192.168.6.3
ether 54:4a:16:e5:e7:a2 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
答案1
问题似乎是 connman 正在我的机器上运行。它忽略了我的配置并插入了它自己的东西。卸载 connman 后,一切都按预期进行。