I'm trying to find out what port is used when my computer communicates with my router. Is it the same port as is used for the service I am using, e.g. 80 when I'm using HTTP, or is there a specific port for computer-router communication?
2 Answers
There isn't any.
Ports belong to transport layer protocols such as TCP and UDP, but normal routers don't interpret those – they work on Internet layer and carry IP packets based only on their IP address, regardless of their contents. (Just like the post office, which uses only what's written on the envelope, and doesn't look for addresses inside.)
For example, your computer wants to send a DNS query packet to 192.0.1.2, over UDP.
IPv4: source=1.0.0.1, dest=192.0.1.2,
└ UDP: source_port=79846, dest_port=53,
└ DNS: ...
It adds the corresponding link-layer header (Ethernet, 802.3, Wi-Fi):
Ethernet: source=[computer's MAC], dest=[your router's MAC], type=IPv4, ├ liiink layerrr
└ IPv4: source=1.0.0.1, dest=192.0.1.2, ├ internet layer
└ UDP: source_port=79846, dest_port=53, ├ transport l-r.
└ DNS: ... ├ application l.
Your router then forwards the IP packet unchanged to the next router:
Ethernet: source=[this router's MAC], dest=[next router's MAC], type=IPv4,
└ IPv4: source=1.0.0.1, dest=192.0.1.2,
└ UDP: source_port=79846, dest_port=53,
└ DNS: ...
And so on. There are no special ports – the only thing that changes between hops is the link-layer address (the MAC address for Ethernet and Wi-Fi).
This applies even to routers performing NAT (such as your home gateway). Although they do peek inside TCP/UDP and rewrite certain port numbers (usually the source port, not the destination port), they still don't change anything about the TCP ports being end-to-end. As far as your computer is concerned, this NAT process is invisible, therefore irrelevant to this question.
(Aside: Routers do understand TCP and UDP, and can accept & initiate TCP connections. If you send packets to the router's own IP address, then it will speak regular HTTP over TCP:80, SSH over TCP:22, and so on. They just don't do it when forwarding someone else's packets.)
- 501,077
By the usual definition of "port" in this case, it refers specifically to the TCP destination port of the traffic, regardless of where in the path it is. This is 80. If you define "port" some other way, you may get some other answer for the computer-to-router communication. People use the word "port" to mean all sorts of things.
There isn't traffic from your computer to the router and also traffic from your computer to the web site. The very same packets your computer sends directly to the router are the ones that result in packets being sent to the web site. Whether you consider them the same packets or not is a matter of definition.
- 62,365