Skip to content

Instantly share code, notes, and snippets.

@r0mdau
Last active May 3, 2024 13:21
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save r0mdau/93ec268ad1ffeeaf99d80eba9e9ea84d to your computer and use it in GitHub Desktop.
Save r0mdau/93ec268ad1ffeeaf99d80eba9e9ea84d to your computer and use it in GitHub Desktop.
How to get tcpdump for containers inside Kubernetes pods
# find the kube node of the running pod, appear next to hostIP, and note containerID hash
kubectl get pod mypod -o json
# -> save hostIP
# -> save containerID
# connect to the node and find the pods unique network interface index inside it's container
docker exec containerID /bin/bash -c 'cat /sys/class/net/eth0/iflink'
# -> returns index
# locate the interface of the node
ip link |grep ^index:
# -> returns interface
# then GO tcpdump !
tcpdump -i interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment