
1、查看路由规则:
输入:route -n
输出:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.4.7.254 0.0.0.0 UG 100 0 0 eth0
10.4.7.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
172.7.21.0 10.4.7.21 255.255.255.0 UG 0 0 0 eth0
172.7.22.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
2、添加路由规则(当没有配置flannel时,10.4.7.22上去ping 172.7.21.2时不通<怎么去实现pod之间跨主机通信>,通过配置路由规则实现)
在10.4.7.22上:route add -net 172.7.21.0/24 gw 10.4.7.21 dev eth0
在filter链上的forword上加:iptables -t filter -I FORWORD -d 172.7.21.0/24 -j ACCEPT
