如何使辅助 IP 可路由

如何使辅助 IP 可路由

我正在尝试为我的主接口分配一个辅助 IP。

我将 IP 添加到我的eth0接口

ip addr add 172.20.14.253/21 dev eth0

$ ip a show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether fa:16:3e:35:91:b5 brd ff:ff:ff:ff:ff:ff
    inet 172.20.11.35/21 brd 172.20.15.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 172.20.11.253/21 scope global secondary eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe35:91b5/64 scope link
       valid_lft forever preferred_lft forever

现在,如果我尝试从本地机器 ping 该 IP,我会看到服务器正在接收 ARP 请求,并且也正在响应,但是响应没有传出。

$ tcpdump -A -nnvvv host 172.20.11.253
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
09:50:42.746806 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.20.11.253 tell 172.20.10.198, length 46
..........>.^X..
.............................
09:50:42.746864 ARP, Ethernet (len 6), IPv4 (len 4), Reply 172.20.11.253 is-at fa:16:3e:35:91:b5, length 28
..........>5........>.^X..
.
09:50:43.777926 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.20.11.253 tell 172.20.10.198, length 46
..........>.^X..
.............................
09:50:43.777956 ARP, Ethernet (len 6), IPv4 (len 4), Reply 172.20.11.253 is-at fa:16:3e:35:91:b5, length 28
..........>5........>.^X..
.
09:50:44.805936 ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 172.20.11.253 tell 172.20.10.198, length 46
..........>.^X..
.............................
09:50:44.805994 ARP, Ethernet (len 6), IPv4 (len 4), Reply 172.20.11.253 is-at fa:16:3e:35:91:b5, length 28
..........>5........>.^X..

我假设远程盒子上没有路由来响应所到达的请求,172.20.11.253所以我也添加了一条路由。

ip route add 172.20.10.198/32 via default dev eth0 src 172.20.11.253

但什么都没改变。

我的路线

$ ip r
default via 172.20.15.253 dev eth0
10.0.0.0/8 via 172.20.8.1 dev eth0
172.16.0.0/12 via 172.20.8.1 dev eth0
172.20.8.0/21 dev eth0 proto kernel scope link src 172.20.11.35
172.20.10.198 dev eth0 src 172.20.11.253
192.168.0.0/20 dev docker0 proto kernel scope link src 192.168.0.1 linkdown

我在这里遗漏了什么?

相关内容