我正在使用 ifconfig 命令在 Linux 模块(TI AM3359 定制硬件上的定制 Yocto 发行版)上分配静态 IP 地址。
sudo ifconfig eth1 10.11.3.80 netmask 255.255.248.0
sudo route add default gw 10.11.0.1 eth1
如果我在大约 60 秒之前执行此操作,路由表将如下所示,并且我能够从范围为 172.10.xx.xx 的动态 IP 无限期地 ping 模块。
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.11.0.1 0.0.0.0 UG 0 0 0 eth1
10.11.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth1
但是如果我在开机后立即分配一个静态 IP,我的路由表会在大约一分钟左右的延迟后更改为该 IP。
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 eth1
0.0.0.0 10.11.0.1 0.0.0.0 UG 0 0 0 eth1
10.11.0.0 0.0.0.0 255.255.248.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1
发生这种情况后,我无法从动态 IP 地址 ping 主板。
请建议该怎么做,因为我几乎搜索了整个互联网来寻找解决方案但却没有找到任何东西。
我的防火墙如下所示:
root@a:~# iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
这是 ip addr 的输出:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,DYNAMIC,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 3c:e0:64:14:b3:c9 brd ff:ff:ff:ff:ff:ff
4: eth1: <BROADCAST,MULTICAST,PROMISC,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 3c:e0:64:14:b3:cb brd ff:ff:ff:ff:ff:ff
inet 10.11.3.80/21 brd 10.11.7.255 scope global eth1
valid_lft forever preferred_lft forever
inet 169.254.199.165/16 brd 169.254.255.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::3ee0:64ff:fe14:b3cb/64 scope link
valid_lft forever preferred_lft forever
请注意,如果我尝试从类似的 IP 范围(例如 10.xx.x.xx 范围)ping 该模块,它可以工作。
我尝试禁用 zeroconf、防火墙并尝试禁用 dhcp。但似乎都不起作用。
编辑:
知识产权
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
link/sit 0.0.0.0 brd 0.0.0.0
3: eth0: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,DYNAMIC,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether 3c:e0:64:14:b3:c9 brd ff:ff:ff:ff:ff:ff
4: eth1: <BROADCAST,MULTICAST,PROMISC,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 3c:e0:64:14:b3:cb brd ff:ff:ff:ff:ff:ff
inet 10.11.3.80/21 brd 10.11.7.255 scope global eth1
valid_lft forever preferred_lft forever
inet 169.254.199.165/16 brd 169.254.255.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::3ee0:64ff:fe14:b3cb/64 scope link
valid_lft forever preferred_lft forever
知识产权
default dev eth1 scope link
default via 10.11.0.1 dev eth1
10.11.0.0/21 dev eth1 proto kernel scope link src 10.11.3.80
169.254.0.0/16 dev eth1 proto kernel scope link src 169.254.199.165