设备 192.200.235.91 路由问题和解决办法
场景:
a. 3网卡 eth0:192.200.235.91 eth2: 192.200.235.82 eth3:192.200.235.93 共同默认网关192.200.235.81
b. 到目的ip 10.191.88.1走 eth2 到目的ip 10.191.88.33 走eth3
问题:
a. 内网其他设备ping 82、93 不通。 从eth2 eth3上ping网关81 不通。 原因是都获取到eth0的mac地址了,可能导致网卡把包drop了;
b. 通信出现间断问题,抓包发现是mac地址获取出现问题
原始路由:
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.200.235.81 0.0.0.0 UG 0 0 0 eth0
10.191.88.1 192.200.235.81 255.255.255.255 UGH 0 0 0 eth2
10.191.88.33 192.200.235.81 255.255.255.255 UGH 0 0 0 eth3
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
192.200.235.80 0.0.0.0 255.255.255.240 U 0 0 0 eth0
192.200.235.80 0.0.0.0 255.255.255.240 U 0 0 0 eth2
192.200.235.80 0.0.0.0 255.255.255.240 U 0 0 0 eth3
192.200.240.144 0.0.0.0 255.255.255.240 U 0 0 0 eth1
route add -host 10.191.88.1 gw 192.200.235.81 dev eth2
route add -host 10.191.88.33 gw 192.200.235.81 dev eth3
策略路由操作步骤:
#添加2个路由表
echo "210 eth2table" >> /etc/iproute2/rt_tables
echo "220 eth3table" >> /etc/iproute2/rt_tables
#设置路由
#可能必须
ip route add default dev eth2 via 192.200.235.81 table eth2table
#可能必须
ip route add default dev eth3 via 192.200.235.81 table eth3table
ip route add 10.191.88.1 via 192.200.235.81 dev eth2 table eth2table
ip route add 10.191.88.33 via 192.200.235.81 dev eth3 table eth3table
#源ip目的ip策略路由
#可能必须
ip rule add from 192.200.235.82 table eth2table
#可能必须
ip rule add from 192.200.235.93 table eth3table
ip rule add to 10.191.88.1 table eth2table
ip rule add to 10.191.88.33 table eth3table
#查看规则和验证
##ip rule show
[root@localhost ~]# ip rule show
0: from all lookup local
32762: from all to 10.191.88.33 lookup eth3table
32763: from all to 10.191.88.1 lookup eth2table
32764: from 192.200.235.93 lookup eth3table
32765: from 192.200.235.82 lookup eth2table
32766: from all lookup main
32767: from all lookup default
##ip route show table eth2table
[root@localhost ~]# ip route show table eth2table
default via 192.200.235.81 dev eth2
10.191.88.1 via 192.200.235.81 dev eth2
#ip route show table eth3table
[root@localhost ~]# ip route show table eth3table
default via 192.200.235.81 dev eth3
10.191.88.33 via 192.200.235.81 dev eth3
说明:
可能必须标签是我再回过头看的时候猜想的,目前没有具体环境,也不敢冒然动现网,做个标记,有做过测试确实只需要那么四行的请留言说下。