nicolaka/netshoot 镜像中内置了很多下图中有列举网络定位的工具,平时也会遇到一些网络问题,这里简单记录下
docker pull nicolaka/netshoot
1. 一个集群有4个节点,但是只有一个节点上的kube-ovn pod 访问 k8s svc 10.233.0.1:443 失败,但是这个节点上访问 10.233.0.1:443 又是 ok 的
在 kube-ovn-cni 内抓了一下包,发现流量已经到 ovn0了,表示流量已经到node上了,而且从node上发起 curl -k 10.233.0.1:443
又是没问题的
这里打算先尝试下一个工具,
tcptraceroute
tcpdump -i any host 10.222.0.120 -netvv
在 ovn0 抓到一个包,从 10.233.0.1 发给 10.222.0.120 的,意思是 443 端口是不可达的。
对比了出问题的节点的ovn0的sysctl设置和其他环境,以及kube-ipvs0 没有任何区别。
node <--> pod 是完全ok的。
但是异常情况下, 回的是不可达
对比了下 iptables 规则,发现顺序上有些是不一样的,但是内容基本没啥区别,
但依然 iptables -F
清理了一下,并重启了 kube-proxy 以及 kube-ovn-cni。
netcat
Purpose: a simple Unix utility that reads and writes data across network connections, using the TCP or UDP protocol. It's useful for testing and troubleshooting TCP/UDP connections. netcat
can be used to detect if there's a firewall rule blocking certain ports.
这个工具正好可以用来检测 tcp/udp 的链接,是否被 防火墙拦截了
netgen
Purpose: netgen
is a simple script that will generate a packet of data between containers periodically using netcat
. The generated traffic can be used to demonstrate different features of the networking stack.
netgen <host> <ip>
will create a netcat
server and client listening and sending to the same port.