

Tcpdump is a very powerful tool for capturing and analyzing network packets. It implements system-level APIs to facilitate faster access. Linux is a very popular operating system for applications involving network communication. Internally, tcpdump makes use of the libpcap library to convert the raw byte stream to pcap format. Wireshark is a graphical user interface (GUI) application that reads and analyzes PCAP files. The captured data is then piped to wireshark of inspection.The captured output can be viewed on the console or saved as a pcap file. This command will attach a container which includes tcpdump to the pod and capture traffic on eth0 interface. –-target here is the container to be debugged. kubectl -n myns debug -i nginx-9456bbbf9-97gjc -image=nicolaka/netshoot –-target=nginx - tcpdump -i eth0 -w - | wireshark -k -i. K8s (from k8s v1.23) provide a way to attach temporary containers to a running pod and run debugging utilities. Target container, and redirects the output to the Wireshark instance

Ksniff uses kubectl to upload a tcpdump binary (packet sniffer) to the Wireshark to capture traffic on a specific pod within a cluster. Ksniff is shipped as a kubectl plugin that allows using tcpdump and Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark

Ephemeral debug container (available from k8s v1.23 only).ksniff (will need to run privileged pod).If you are not able to download tcpdump on the container then you will have to include it in the image.(which will add unnecessary bloat to the image) pcap file to your local workspace and open it on wireshark(which can understand pcap). Rather than reading using tcpdump, you can export the. To read and analyze captured packet 0001.pcap file use the command with -r option tcpdump -r 0001.pcap Incase you have the capability to install tcpdump on the running container, you can download and run it. Once captured, it can be easily read using tcpdump or on GUI tools like wireshark. To find all the IP addresses your application is talking to, you will have to capture the network traffic on the pod's network interface.
