Interview Prep/Networking/Containers, Kubernetes, IPv6 and packet captures

`tcpdump -i eth0` fails with `tcpdump: eth0: You don't have permission to capture on that device (socket: Operation not permitted)`.

BeginnerTroubleshootingContainers, Kubernetes, IPv6 and packet captures
Answer

Likely causes → Packet capture needs CAP_NET_RAW (and CAP_NET_ADMIN for promiscuous mode). You're not root, or you're in a container that drops those capabilities.

Diagnose →

id
getcap $(which tcpdump)
capsh --print | grep -i net_raw      # inside a container

Fix → Run with sudo. In containers, use a debug container with the capability rather than adding it to the app:

docker run --rm -it --net container:myapp --cap-add NET_RAW --cap-add NET_ADMIN nicolaka/netshoot tcpdump -ni eth0

Prevent → Keep a known debugging image (netshoot) and a documented, audited way to use it, instead of shipping tcpdump in app images.

All Networking questions Roadmap: Networking for DevOps

More on Containers, Kubernetes, IPv6 and packet captures