Netstat and ss Not Seeing Connection – Troubleshooting

kubernetesnetstatnetwork-namespacetcpdump

I'm trying to find which application running on Kubernetes cluster is using a specific port to communicate with RabbitMQ cluster. On RabbitMQ I see that connection is coming from 192.168.1.10:34226. 192.168.1.10 is one of Kubernetes nodes. After logging in to 192.168.1.10 I checked if connection is established from that node by tcpdump command tcpdump -i eth0 port 34226. I see traffic with both directions. Now I'm trying to find which process is making this connection. First I tried netstat:

netstat -tapn | grep 34226

and it found nothing. Then I tried ss but still nothing. Connection is established, with tcpdump I can see heartbeat packets sent to RabbitMQ and response from RabbitMQ. But netstat and ss don't report established connection.

UPDATE 1

I found that is something related to network namespaces. My question is similar to this question but I need to find PID of process which make connection from 34226 port.

Best Answer

After couple of weeks I found answer. I needed to run netstat -tapn in all namespaces with following command:

sudo ip -all netns exec netstat -tapn | grep 34226

Now I have PID number of process which start tcp connection from 34226 port.