This is my IP route config, with IP rules:
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
Then I use ping 8.8.8.8 -I eth0
, which I want to ping 8.8.8.8 by default route in 1001 table. But I got errors like this:
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
I don't know why, as in my opinion, my ping should work as there is IP rule like this 32765: from 172.18.8.215 lookup 1001
, and table 1001 has default IP route.
But Why I got errors? Is this a bug? If I want to use default route in table 1001, how should I config route table?
And BTW, could someone show me the codes in kernel related in this feature?
Thank you.