Network Address Translation (NAT)
- is an OSI cross-layer process, involving layers 3 (IP) and 4 (TCP, UDP, etc) and in some cases also layer 7 (application)
NAT - Common Traits
Every TCP packet contains a source IP address, source port, destination IP address, and destination port. All types of NAT create NAT mappings using these values. For example, a connection from an internal client with IP 192.168.0.1 using port 56876 may go to a website IP 56.45.78.89 (destination IP address) on port 80 (destination port) using IP of 45.34.78.98 (translated source IP) and port 56876 (source port). NAT creates a mapping using these 4 values to the 192.168.0.1 internal client for that specific connection. When packets come back from the website to the router using the same values associated with that mapping NAT forwards the packets to the internal client.
Don’t confuse NAT Restriction with NAT Translation – For example, a Full Cone NAT only looks at the destination port when choosing whether to accept the connection or not (the restriction). When it does the actual the NAT translation however, it always uses the 4 values mentioned above.
NAT - Categories
- Static NAT - the NAT mappings are manually set up and are usually associated with inbound types of NAT
- Dynamic NAT - the NAT mappings are automatically set up on demand and are usually associated with outbound types of NAT
NAT - Translation Methods
see: https://www.youtube.com/watch?v=FExZvpVvYxA&t=1014s
|
Translation Method |
Category |
Description |
|---|---|---|
|
STATIC |
| |
|
DYNAMIC |
| |
|
DYNAMIC |
| |
|
DYNAMIC |
|
NAT - Translation Methods Comparison
Let’s say the NAT device has public IP address 5.5.5.5 and it assigned an internal computer with a private IP address 10.0.0.2
-model/?---mixed/other-layers/network-address-translation-(nat)/nat.png)
Let’s also say that the NAT device contains a STATIC mapping
|
Internal IP |
Internal Port |
External IP |
External Port |
|---|---|---|---|
|
10.0.0.2 |
8992 |
5.5.5.5 |
3333 |
Let’s also say that the NAT device contains the following DYNAMIC mappings
|
Internal IP |
Internal Port |
External IP |
External Port |
Destination IP |
Destination Port |
|---|---|---|---|---|---|
|
10.0.0.2 |
8992 |
5.5.5.5 |
3333 |
4.4.4.4 |
80 |
|
10.0.0.2 |
8888 |
5.5.5.5 |
2222 |
3.3.3.3 |
8080 |
Given the STATIC and DYNAMIC mappings above, let’s simulate incoming packets sent to the NAT device of each of the following Translation Methods
|
Packet Details |
Translation Methods | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
Packet Number |
Source IP |
Source Port |
Dest IP |
Dest Port | |||||
|
1 |
4.4.4.4 |
80 |
5.5.5.5 |
3333 |
PASS |
PASS |
PASS |
PASS | |
|
2 |
3.3.3.3 |
8080 |
5.5.5.5 |
3333 |
PASS |
PASS |
PASS |
DROP | |
|
3 |
3.3.3.3 |
22 |
5.5.5.5 |
3333 |
PASS |
PASS |
DROP |
DROP | |
|
4 |
9.8.1.2 |
23 |
5.5.5.5 |
3333 |
PASS |
DROP |
DROP |
DROP | |
|
5 |
9.8.1.2 |
23 |
5.5.5.5 |
22 |
DROP |
DROP |
DROP |
DROP | |