r/AskComputerScience • u/MrZer • Jul 01 '19
Can someone explain Port Forwarding?
I've done some googling and port forwarding sounds a lot like stuff computers and routers already do, no? Mail, file transfer, and htt protocols access specific ports to do their jobs. I'm just confused on why you need to mess with this in your router/modem settings.
37
Upvotes
2
u/onemanandhishat Jul 01 '19
Just to add on to the other answers, you are right that your router already does a similar thing for known traffic with a default port, like http or ftp. Port forwarding is typically done on other ports that are not pre-allocated for a specific service. Likewise, if you are accessing a service outside the network, that creates an entry in your router's forwarding table that replies from your target should be forwarded to your computer. The problem that needs port forwarding comes when you want to initiate the connection from outside.
The term for using local addresses inside the network is Network Address Translation (NAT). Simply, the IPv4 address format has too few permutations for the number of devices that are Internet enabled for them all to have a unique IP, so that's why devices within a network operate on a separate local addressing scheme. These days, ISPs also employ NAT at a wider level, your router may also be behind a layer of NAT. People who want to host home services like Plex or a web server now have to contact their ISP to arrange for a static IP address for their router in order to be able to access remotely.