What is NAT? Home routers and port forwarding
Your laptop, phone and television each have their own address at home, yet websites see all of them under one. That is NAT, Network Address Translation, at work: the router rewrites packet addresses at the edge of your network so that several privately addressed IPv4 devices share one external IPv4 address. It usually changes port numbers as well, which is how it keeps simultaneous connections apart.
What the router does with an outgoing request
Imagine a laptop at 192.168.1.20 opening a website. Its packet reaches the router, which replaces the laptop’s internal address and port with its own external address and a port it chooses, and records that mapping in a table. The website sees only the external address and replies to it. The router looks up the mapping and passes the reply to the laptop, even if a phone on the same network contacted the same site at the same moment.
This is a simplified picture of the common address and port translation, and exact behaviour depends on the router. RFC 3022 describes the basic NAT model.
Why a connection from outside usually fails
The mapping table is filled by outgoing connections. A request that arrives from outside unprompted matches no entry, so the router has no device to hand it to. To host a service you add a port forwarding rule that sends an external port to a chosen local device and port. External TCP port 8443, for example, could point to an internal web application.
The rule must name the right transport, because TCP and UDP ports are separate. Before you open one, make sure the service is kept up to date, requires authentication and really needs to be reachable from the Internet.
NAT hides addresses but does not decide what is allowed
Translation describes how addresses are rewritten and how replies are matched to connections. A firewall policy decides which traffic is permitted. A home router usually does both, which makes them easy to confuse.
Do not rely on NAT as your only security boundary. A forwarding rule, an automatic port-mapping feature or a configuration mistake can change what is exposed without your noticing.
Port forwarding is set up but still does not work
Check in this order:
- Confirm the server’s local address and that it answers from another device on the same LAN.
- Check the port and transport in the router’s rule, then the firewall on the server itself.
- Compare the external address shown in the router with the address an Internet site sees for you. If they differ, another router or the provider’s carrier-grade NAT (CGNAT) sits upstream, and a rule on your home router alone may not be enough.
- Test from outside. The 2ip port checker gives you an outside view of the port.
An open result does not prove that the application behaves correctly or uses strong authentication, so test the service itself and not only the port number. Do not switch off the whole firewall to diagnose the problem. Look at the one narrow rule and at the application’s logs.