1 NAT Network Address Translation
Motivation for NAT To solve the insufficient problem of IP addresses IPv6 –All software and hardware need to be updated –High cost Virtual IP Gateway –Used on IPv4 –Let more hosts connect to Internet
NAT Example local network (e.g., home network) /24 Internet Datagrams with source or destination in this network have /24 address for source, destination (as usual) All datagrams leaving local network have same single source NAT IP address: , different source port numbers NAT gateway
Private IP Addresses The following addresses are reserved for the private network –Class A : * –Class B : *.* to *.* –Class C : * to * Closed local network /24
Connection with Socket Pairs IP address + Port number = Socket address Socket pairs define a unique Internet connection. –( ,3044) and ( ,80) is a socket pair. telnet server telnet client Destination: Port Number: 80 Source: Port Number: 3044 Source: Port Number: 5001 Web page 1 Web page 2
Implementation (1/3) Outgoing datagrams –Replace (source IP address, port no.1) of every outgoing datagram to (NAT IP address, port no.2) Internt NAT gateway :80 : :8 :3345 Web server PC in LAN d: :80 s: :3345 original socket pair d: :80 s: :5001 new socket pair
Implementation (2/3) Create NAT translation table –Every (source IP address, port no.1) to (NAT IP address, port no.2) translation pair NAT translation table WAN side addr LAN side addr , , 3345 …… Internt NAT gateway :80 : :80 :3345 Web server PC in LAN
Implementation (3/3) Incoming datagrams –Replace (NAT IP address, port no.2) in the destination field with corresponding (source IP address, port no.1) stored in NAT translation table Internt NAT gateway :80 :5001 Web server PC in LAN s: :80 d: :5001 original socket pair s: :80 d: :3345 new socket pair :80 :3345
NAT Translation Table S: , 3345 D: , : host sends datagram to , 80 NAT translation table WAN side addr LAN side addr : :3345 …… S: , 80 D: , S: , 5001 D: , : NAT router changes datagram source addr from , 3345 to , 5001, updates table S: , 80 D: , : Reply arrives dest. address: , : NAT router changes datagram dest addr from , 5001 to , 3345
Advantages of NAT (1/2) Local network uses just one IP address as far as outside world is concerned –16-bit port-number field; 60,000 simultaneous connections with a single LAN-side address! Range of addresses not needed from ISP: just one IP address for all devices Can change addresses of devices in local network without notifying outside world
Advantages of NAT (2/2) Can change ISP without changing addresses of devices in local network Devices inside local net not explicitly addressable, visible by outside world (a security plus).
Controversial Issues NAT is controversial: –Cost and performance –Outside client cannot create a connection to the host in local network NAT traversal problem –Violates end-to-end argument NAT possibility must be taken into account by application designers, eg, P2P applications –Address shortage should instead be solved by IPv6 IPv6
Problems of IPv6 IPv6 and IPv4 are not compatible. All software at many layers need to be modified for IPv6 (ex: TCPv6, UDPv6, etc.) All hardware such as gateways and routers must be updated. The IPv6 header which is larger than IPv4 header will increase the traffic overhead 。
NAT Traversal Problem (1/3) Client want to connect to server with address Solution 1: statically configure NAT to forward incoming connection requests at given port to server –e.g., ( , port 5001) always forwarded to port NAT gateway Client ? server
NAT Traversal Problem (2/3) Solution 2: Universal Plug and Play (UPnP) Internet Gateway Device (IGD) Protocol. Learn public IP address ( ) + port mappings (with lease times) Automate static NAT port map configuration NAT gateway IGD :5001 :3345
NAT Traversal Problem (3/3) Solution 3: relaying (used in Skype)Skype –NATed server establishes connection from peer 1 to relay –Peer 2 connects to relay –Relay bridges packets between to connections NAT gateway peer 2 1. connection to relay initiated by NATted host 2. connection to relay initiated by client 3. relaying established peer1 NAT gateway
Making A Call on Skype Skype Client (SC) registers with Super Node (SN) –List of SNs SC contacts SN with callee ID –SN contacts other SNs to find callee SC directly contacts callee, overTCP Skype login server
Summary By using Network Address Translation (NAT), we manage networks in a simple way: –Security, insufficient IP address, cost … NAT traversal is a big problem Homework: To find and explain the method for NAT Traversal