前几天,出现了没法跨主机ping通容器的状况,致使一个node机网络中断,没法访问,排查过程以下。node
[root@node2 ~]# ping 10.1.19.3 PING 10.1.19.3 (10.1.19.3) 56(84) bytes of data. 64 bytes from 10.1.19.3: icmp_seq=1 ttl=64 time=0.122 ms 64 bytes from 10.1.19.3: icmp_seq=2 ttl=64 time=0.073 ms
能够ping通,进行下一步docker
[root@node1 ~]# ping 10.1.19.3 PING 10.1.19.3 (10.1.19.3) 56(84) bytes of data. ^C --- 10.1.19.3 ping statistics --- 14 packets transmitted, 0 received, 100% packet loss, time 12999ms
没法ping通,检查代理机
[root@node1 ~]# etcdctl ls /coreos.com/network/subnets /coreos.com/network/subnets/10.1.91.0-24 /coreos.com/network/subnets/10.1.93.0-24 /coreos.com/network/subnets/10.1.94.0-24 /coreos.com/network/subnets/10.1.19.0-24 /coreos.com/network/subnets/10.1.77.0-24
网段配置是正常的,已经含有10.1.19.0-24 段了
[root@node2 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.19.51 0.0.0.0 UG 100 0 0 eth0 10.1.19.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0 192.168.19.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
配置不完整,缺乏flannel路由配置
[root@node2 ~]# route add -net 10.1.0.0 netmask 255.255.0.0 dev flannel0 [root@node2 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.19.51 0.0.0.0 UG 100 0 0 eth0 10.1.0.0 0.0.0.0 255.255.0.0 U 0 0 0 flannel0 10.1.19.0 0.0.0.0 255.255.255.0 U 0 0 0 docker0 192.168.19.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
建立完成以后没确认网络是否通了
echo "1" > /proc/sys/net/ipv4/ip_forward
包不会被iptables的forward规则拦截网络
sudo iptables -P FORWARD ACCEPT
[root@node1 ~]# ping 10.1.19.3 PING 10.1.19.3 (10.1.19.3) 56(84) bytes of data. 64 bytes from 10.1.19.3: icmp_seq=1 ttl=61 time=0.444 ms 64 bytes from 10.1.19.3: icmp_seq=2 ttl=61 time=0.288 ms ^C --- 10.1.19.3 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.288/0.366/0.444/0.078 ms
网络没有问题了
以上代理