How to identify internal ports and external ports that are mapped by NAT by the router

nat;portrouter

For example, my HTTP port 80 is opened and mapped by the router to port 42300 facing outwards.

Is there a way to identify , let's say my port 150 that is open for connection is mapped into what external port without accessing the router?

I understand that I would be able to set how the router map certain internal ports manually to the external ports that I want.

Best Answer

Not easily, though you should reconsider how you visualise this. It is more helpful to visualise it the other way around, as we are looking at incoming connections - this is why this is referred to as port-forwarding:

Ports are opened on the router's public IP address and forwarded to an address and port of an internal resource.

So your router has port 42300 open and is listening on this port on its public IP, and will forward any incoming connections to port 80 on the internal server.

Your question is therefore better phrased as "How can I determine which port on my router gets forwarded to port 150 on my internal server". Because of the way this works, the connection needs to be initiated from an external source, to the public IP address on the right port.

As you don't know the right port, and cannot access the router to see what it is, then your only option is to try them all and see which one connects through.

You can use the nmap tool to do this.

Related Question