Compared
NAT vs PAT
NAT rewrites addresses as packets pass a router. Static NAT maps one inside address to one outside address for good. Dynamic NAT lends outside addresses from a pool. PAT shares one outside address among many devices and tells their conversations apart by port: what nearly every home and office router does.
Side by side
| Static NAT | Dynamic NAT | PAT | |
|---|---|---|---|
| Maps | One inside address to one outside address, fixed | Inside addresses to addresses from a pool, as devices connect | Many inside addresses to one outside address |
| Tells conversations apart by | Address | Address | Source port |
| Outside addresses needed | One for each device | One for each device talking at the same time | One |
| The outside can start a connection | Yes: the way to publish a server | No fixed mapping to aim at | No, unless a port forward says where it goes |
| Runs out when | Never: the mapping is fixed | The pool is empty: the next device is refused | The ports of the one address are used up |
| On Linux (iptables, nat table) | SNAT, with DNAT for the inbound half | SNAT to a range of addresses | MASQUERADE, or SNAT to one address |
| Also called | One-to-one NAT | Pool NAT | NAT overload, NAPT, masquerading |
Each one explained
- NAT
- A router rewriting addresses as packets pass, usually to hide many private devices behind one address.
- Static NAT, dynamic NAT and PAT
- One address for one device (static), addresses from a pool as devices go out (dynamic), or one address shared by port (PAT).
- Port forward
- One port on the router's public address passed to one device and port inside.
- Private addresses
- Address ranges any organisation may use inside, never routed on the internet: 10/8, 172.16/12, 192.168/16.
See the difference on real machines
Each lab is a small network of real Linux machines in your browser.
- NAT explained: static, dynamic and PAT on one router
- NAT: share one public address across a whole building
- Port forwarding: let the internet reach one machine behind NAT
Open NAT explained: static, dynamic and PAT on one router