Sub topic 9
NAT: sharing one public address, and common ports and protocols
This chapter assumes you know what a private IPv4 address is and what DHCP and DNS do. It covers how a router lets many devices share one public address, and how port numbers identify network services.
How NAT works
Network Address Translation (NAT) rewrites the addresses in packets as they cross the router. Your devices use private addresses such as 192.168.1.x. These addresses cannot be routed on the internet. Your ISP gives the router one public address, and NAT lets every device share it.
Most SOHO routers use port address translation (PAT), also called NAT overload. The router keeps a translation table. When a device sends a packet out, the router replaces the private source address and port with its public address and a unique port. When the reply returns, the router looks up that port and forwards the packet to the right device.
NAT has two side effects that matter on the exam:
- It hides internal addresses. Unsolicited inbound traffic has no table entry, so the router drops it. This works like a basic firewall, but NAT is not a security feature on its own.
- It breaks inbound connections to internal servers. To host a service, you need port forwarding, which is covered in a later chapter.
Ports and protocols
An IP address finds a device. A port number, from 0 to 65535, finds the service on that device. Each service has a well-known port. Most protocols use TCP, which is reliable and connection-oriented. Others use UDP, which is faster and has no delivery guarantee. Some use both.
| Port | Protocol | Transport | Purpose |
|---|---|---|---|
| 20/21 | FTP | TCP | File transfer (data/control) |
| 22 | SSH | TCP | Encrypted remote shell, also SFTP |
| 23 | Telnet | TCP | Unencrypted remote shell |
| 25 | SMTP | TCP | Sending email between servers |
| 53 | DNS | UDP/TCP | Name resolution |
| 67/68 | DHCP | UDP | Server/client address assignment |
| 80 | HTTP | TCP | Web pages |
| 110 | POP3 | TCP | Downloading email |
| 143 | IMAP | TCP | Syncing email on the server |
| 161/162 | SNMP | UDP | Device monitoring |
| 389 | LDAP | TCP/UDP | Directory services |
| 443 | HTTPS | TCP | Encrypted web traffic |
| 445 | SMB | TCP | Windows file sharing |
| 3389 | RDP | TCP | Windows Remote Desktop |
Common mistakes
- Treating NAT as encryption. It only changes addresses.
- Mixing up DHCP ports. The server listens on 67 and the client uses 68.
- Confusing POP3 with IMAP. POP3 usually downloads mail to one device. IMAP keeps mail on the server so several devices can see it.
Exercise
A user's laptop (192.168.1.20) and phone (192.168.1.21) both browse the web at once through one router with a single public address. What lets the router send each reply to the correct device? Also, which port would you check if a coworker cannot open a Remote Desktop session?
Show answer
The router's NAT translation table maps each outbound connection to a unique public-side port, so it can send each reply back to the right private address. For Remote Desktop, check TCP port 3389.