如何在K8S环境中抓POD的包
- kubectl get pod -o wide 获取pod所在的node信息
1 | ➜ Documents kubectl get pod -o wide |
- 登陆node节点,找到container查看eth0网卡的ID
1 | [ec2-user@ip-10-200-1-202 net]$ docker exec -it ae9a6df60584e797e56cc64d0df02e64d7731a0d852026fab0a76c920c608cbe cat /sys/class/net/eth0/iflink |
- 宿主机上查询对应ID的网卡设备号
1 | [ec2-user@ip-10-200-1-202 net]$ cd /sys/class/net; for i in $(ls);do echo $i ;grep 88 $i/ifindex;done |
- tcpdump 抓包即可
1 | ➜ ssh-keys git:(master) ✗ ssh -F ~/.matrix/jp/ssh.aux.config 10.200.1.202 -l ec2-user "sudo tcpdump -vvv -i enic2ad9523b38 tcp port 80 -w -" | wireshark -k -i - |