这是我的IP路由配置,其中包含IP规则:
root@NX-ZWYC-M1F202-A16-HW6865-A-INT-215:~# ip ru show
0: from all lookup local
32764: from all to 172.18.8.215 lookup 1001
32765: from 172.18.8.215 lookup 1001
32766: from all lookup main
32767: from all lookup default
root@NX-ZWYC-M1F202-A16-HW6865-A-INT-215:~# ip route show table 1001
default via 172.18.8.1 dev eth0
172.18.8.0/24 dev eth0 scope link
root@NX-ZWYC-M1F202-A16-HW6865-A-INT-215:~# ip route show table main
default via 172.18.8.1 dev eth0
10.131.152.16/30 dev Ethernet49 proto kernel scope link src 10.131.152.18
10.131.153.16/30 dev Ethernet50 proto kernel scope link src 10.131.153.18
10.131.154.16/30 dev Ethernet51 proto kernel scope link src 10.131.154.18
10.131.155.16/30 dev Ethernet52 proto kernel scope link src 10.131.155.18
10.131.156.16/30 dev Ethernet53 proto kernel scope link src 10.131.156.18
10.131.157.16/30 dev Ethernet54 proto kernel scope link src 10.131.157.18
10.131.158.16/30 dev Ethernet55 proto kernel scope link src 10.131.158.18
10.131.159.16/30 dev Ethernet56 proto kernel scope link src 10.131.159.18
10.133.224.0/24 dev Vlan100 proto kernel scope link src 10.133.224.1
240.127.1.0/24 dev docker0 proto kernel scope link src 240.127.1.1
然后我使用ping 8.8.8.8 -I eth0
,我想在1001表中默认路由ping 8.8.8.8。但是我遇到了这样的错误:
root@NX-ZWYC-M1F202-A16-HW6865-A-INT-215:~# ping 8.8.8.8 -I eth0
PING 8.8.8.8 (8.8.8.8) from 172.18.8.215 eth0: 56(84) bytes of data.
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1008ms
我不知道为什么,我认为ping应该可以工作,因为存在诸如32765: from 172.18.8.215 lookup 1001
这样的IP规则,并且表1001具有默认IP路由。
但是为什么我会出错?这是错误吗?如果要使用表1001中的默认路由,该如何配置路由表?
顺便说一句,有人可以告诉我与此功能相关的内核代码吗?
谢谢。