What is NAT?
NAT lets every device in your home share the one public IPv4 address your internet provider gives you. Your router rewrites the source address and port of each outgoing packet, keeps a table of what it changed, and uses that table to send each reply to the right device.
It exists because IPv4 addresses ran out. It also explains everyday puzzles: why you cannot reach a home camera from outside without port forwarding, why game consoles complain about strict NAT, and why video calls need extra tricks to connect directly.
Think of it like this. NAT is like an office with one phone number and a receptionist. Staff call out through the switchboard, and the receptionist notes who called whom. When the other side calls back, the receptionist checks the notes and puts the call through. An unexpected caller with no note gets nowhere unless there is a standing instruction, which is port forwarding.
Step by step
Normal
4 stepsTwo devices share one public address. The router rewrites each packet and keeps a table to send replies home.
Normal
4 stepsTwo devices share one public address. The router rewrites each packet and keeps a table to send replies home.
- 1
Private source
192.168.1.10 cannot go out as is
The laptop opens a connection from its private address. Private addresses are not routed on the internet, so a reply to it could never come back.
- 2
Translate
Swap in the public address
The router replaces the source with its one public address, 198.51.100.7, and picks a free outside port, 40001. It writes the pair into its NAT table.
- 3
Reply mapped back
Look up port 40001
The server answers 198.51.100.7:40001. The router finds that port in its table and rewrites the destination back to 192.168.1.10:51000.
- 4
Second device
Same port, no clash
Arjun's phone happens to use port 51000 too. The router gives it outside port 40002, so the two connections never mix. This port trick is what lets thousands of connections share one address.
Inbound dropped
3 stepsA computer on the internet tries to connect in. There is no table entry, so the router has nowhere to send it.
Inbound dropped
3 stepsA computer on the internet tries to connect in. There is no table entry, so the router has nowhere to send it.
- 1
Knock from outside
SYN to 198.51.100.7:3389
An unknown computer scanning the internet tries to open a remote desktop connection to your public address.
- 2
No entry, no delivery
Which device? Nobody knows
The router checks its NAT table. No inside device started a connection to that port, so it cannot know who should get it. It drops the packet.
- 3
Silence
The scanner gives up
The scanner retries and then moves on. This side effect is why NAT feels like a firewall, but it is not one: a real firewall rule is what keeps you safe, especially with IPv6, which has no NAT.
Port forwarding
3 stepsA forwarding rule lets someone outside reach one chosen device at home.
Port forwarding
3 stepsA forwarding rule lets someone outside reach one chosen device at home.
- 1
Rule set
Outside 8443 goes to the file server
Lucas adds a rule in his router: anything arriving on public port 8443 goes to the home file server at 192.168.1.50, port 443.
- 2
Inbound translated
Destination rewritten
Mateo connects to 198.51.100.7:8443 from work. This time the router has a rule, so it rewrites the destination to 192.168.1.50:443 and passes it in.
- 3
Reply translated
Source rewritten back
The file server answers. The router rewrites the source back to 198.51.100.7:8443, so Mateo's laptop sees a reply from the address it called. Only open ports you really need, and keep that device updated.
Myths and mix-ups
- NAT is not a firewall; dropping unknown inbound traffic is a side effect, and a firewall rule is what you should rely on.
- Your public IP is not always yours alone; many providers put customers behind carrier-grade NAT, sharing one address.
- Port forwarding is not needed to browse or stream; it is only for letting others connect in to you.
- IPv6 does not need NAT; every device can have its own public address behind a firewall.
Try it yourself
Run these on your own computer to see NAT at work.
Your private address (Windows)
ipconfigLikely 192.168.x.x or 10.x.x.x: the inside of the NAT.
Your private address (macOS or Linux)
ifconfigOn Linux you can also use ip addr. Look for inet.
Your public address
Open sdev.in/tools/what-is-my-ipShows the address the internet sees. If it differs from the address above, NAT is in use.
See your router's NAT table (Linux router)
sudo conntrack -LOn a Linux machine doing NAT, lists every tracked connection with its translated address and port.
NAT at a glance
- Layer
- Network (3), also rewrites transport ports
- Common form
- NAPT, also called PAT or masquerade
- Lives in
- Home routers, firewalls, provider equipment
- Private ranges
- 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
- Provider NAT range
- 100.64.0.0/10 (carrier-grade NAT)
- Defined in
- RFC 3022 (2001)
Defined inRFC 3022RFC 1918RFC 4787RFC 6598
Header fields
What NAT puts in its messages, with example values from the stories above.
IPv4
- Time to live
64- Protocol
6 (TCP)- Header checksum
recalculatedChanging an address breaks the checksum, so the router fixes it. It fixes the TCP checksum too.- Source
192.168.1.10A private address. It means nothing on the internet.- Destination
192.168.1.10Translated back to the laptop's private address.
NAT table (inside the router)
- Entry 1
192.168.1.10:51000 <-> 198.51.100.7:40001 to 203.0.113.10:443Remembers who asked, so the reply can be sent back to the right device.- Entry 2
192.168.1.11:51000 <-> 198.51.100.7:40002 to 203.0.113.10:443Same inside port as the laptop, so the router picked a different outside port.- Lookup
198.51.100.7:3389: no entry, no forwarding ruleNo match, so the router drops the packet.- Forwarding rule
198.51.100.7:8443 -> 192.168.1.50:443Set by hand in the router settings. It tells the router where inbound traffic on this port belongs.
Test yourself
What does a home router change in an outgoing packet?
Questions people ask
What is NAT in networking?
Network Address Translation: a router rewrites the addresses in packets so many devices with private addresses can share one public address. It keeps a table so replies reach the right device.
Is NAT a firewall?
No. It drops unknown inbound traffic only because it does not know where to send it. Use real firewall rules for protection, especially on IPv6, where there is usually no NAT.
What is port forwarding?
A rule on your router that sends traffic arriving on a chosen public port to one device inside, so people outside can reach it. Open only what you need.
What is carrier-grade NAT?
NAT run by your internet provider, so many customers share one public address. Your router gets an address in 100.64.0.0/10. Port forwarding on your own router then cannot work from outside.
What does strict NAT mean on a game console?
The console cannot accept inbound connections, often because of double NAT or carrier-grade NAT. Enabling UPnP, port forwarding or getting a public IPv4 or IPv6 address usually helps.