前幾天,出現了沒法跨主機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
網絡沒有問題了
以上代理