我有一台多宿主主机,eth0 位于 172.31.254.0/24 上,eth0.10 位于 172.31.253.0/24 上。显然,eth0.10 是 vlan id 10 上的子接口。
从此主机我可以成功 ping 通 172.31.253.0/24 网络上的主机,但不能始终如一在 172.31.254.0/24 网络上。例如,请注意 ping #5-#25 中的丢失:
[root@pbx1 ~]# ping -I eth0 172.31.254.37
PING 172.31.254.31 (172.31.254.31) from 172.31.254.13 eth0: 56(84) bytes of data.
64 bytes from 172.31.254.37: icmp_seq=1 ttl=128 time=1.03 ms
64 bytes from 172.31.254.37: icmp_seq=2 ttl=128 time=0.247 ms
64 bytes from 172.31.254.37: icmp_seq=3 ttl=128 time=0.236 ms
64 bytes from 172.31.254.37: icmp_seq=4 ttl=128 time=4.00 ms
64 bytes from 172.31.254.37: icmp_seq=26 ttl=128 time=0.237 ms
64 bytes from 172.31.254.37: icmp_seq=27 ttl=128 time=0.299 ms
我的界面看起来正确:
[root@myhost1 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:22:4D:B2:28:AC
inet addr:172.31.254.13 Bcast:172.31.254.255 Mask:255.255.255.0
inet6 addr: fe80::222:4dff:feb2:28ac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:121808 errors:0 dropped:0 overruns:0 frame:0
TX packets:120948 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16685937 (15.9 MiB) TX bytes:23059300 (21.9 MiB)
Interrupt:16 Memory:d0020000-d0040000
eth0.10 Link encap:Ethernet HWaddr 00:22:4D:B2:28:AC
inet addr:172.31.253.4 Bcast:172.31.253.255 Mask:255.255.255.0
inet6 addr: fe80::222:4dff:feb2:28ac/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2732 errors:0 dropped:0 overruns:0 frame:0
TX packets:828 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1394817 (1.3 MiB) TX bytes:417925 (408.1 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:30573 errors:0 dropped:0 overruns:0 frame:0
TX packets:30573 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2225449 (2.1 MiB) TX bytes:2225449 (2.1 MiB)
并且路由表看起来正确:
[root@myhost1 ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.31.254.0 * 255.255.255.0 U 0 0 0 eth0
172.31.253.0 * 255.255.255.0 U 0 0 0 eth0.10
link-local * 255.255.0.0 U 1002 0 0 eth0
default firewall.mydomain.com 0.0.0.0 UG 0 0 0 eth0
那么,为什么我的数据包无法到达 172.31.254.0/24 网络上的主机(或从其返回响应)?我将 /proc/sys/net/ipv4/conf/eth0/rp_filter 设置为 0,但没有任何效果
更新:目标主机的路由表:
IPv4 Route Table
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 172.31.254.1 172.31.254.37 266
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
172.31.252.0 255.255.255.0 172.31.254.2 172.31.254.37 11
172.31.253.0 255.255.255.0 172.31.254.2 172.31.254.37 11
172.31.254.0 255.255.255.0 On-link 172.31.254.37 266
172.31.254.37 255.255.255.255 On-link 172.31.254.37 266
172.31.254.255 255.255.255.255 On-link 172.31.254.37 266
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 172.31.254.37 266
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 172.31.254.37 266
===========================================================================
Persistent Routes:
Network Address Netmask Gateway Address Metric
172.31.252.0 255.255.255.0 172.31.254.2 1
172.31.253.0 255.255.255.0 172.31.254.2 1
0.0.0.0 0.0.0.0 172.31.254.1 Default
===========================================================================
答案1
您的网络上可能使用了两次 172.31.254.13。
我还怀疑接收端存在路由或 arp 问题:
你能检查一下吗ARP表在主机 172.31.254.13 和主机 172.31.254.31 上?
完整路由表路由每个主机上的命令也可能有帮助。
答案2
我需要创建一个 iproute2 策略,并禁用接口和子接口的 rp_filter。
此后,一切运行正常。
答案3
您在同一张卡上的另一个网络上拥有 VIP。(相同的 MAC)尝试执行相同操作,但创建作为独立段的 vNIC,然后为其他 NIC 设置默认路由和特定路由。