Search code examples
windowsnetwork-programmingtcp

Is there a way I can determine the source port number?


I am working on a couple of network troubleshooting scenarios and I wanted to check if there is a way I can find out what source port my PC is using to connect to a website? I am using Windows 10.

I tried using netstat -a, but this shows a lot of active connections and if my understanding is correct, the port numbers shown here are destination ports, correct?

nestat capture


Solution

  • The port numbers are clearly shown in your netstat output, i.e. TCP 10.0.0.166:2424 13.107.5.88:https means that it connected from the local IP 10.0.0.166 source port 2424 to the remote system 13.107.5.88 on port 443 (https). Note that due to NAT the source IP on the remote system will be different (i.e. your external IP address) and the source port can be different too, but the value can not be detected on the local system.