Capturing packages with Wireshark

If you execute Wireshark on your host, you will note that the vet peers are not available. This happens since each network will have its environment created by namespaces. It means that each network has its firewall rules and interfaces.

To connect Wireshark to a specific namespace first we need to get the namespace ID. By default, the namespaces are created for each node, so, we just need to get the host PID.

Based on the previous tutorial, this can be obtained with the command:

$PIDHost1=$(docker inspect -f '{{.State.Pid}}' host1)

This will create a variable PIDHost1, that stores the container namespace ID. Now, to execute commands inside a specific namespace, we just start the Wireshark inside the namespace with the command:

$ nsenter -t $PIDHost1 -n wireshark The command "nsenter -t $PIDHost1 -n " will specify the namespace to execute the command passed after -n, being the command in this example only "wireshark". This will open Wireshark with the interfaces on Host1 available to capture.

Last updated