Sampling Is Simple

Thursday, November 09, 2006
How NAT Works

When a client on the internal network contacts a machine on the Internet, it sends out IP packets destined for that machine. These packets contain all the addressing information necessary to get them to their destination. NAT is concerned with these pieces of information:

  • Source IP address (for example, 192.168.1.35)
  • Source TCP or UDP port (for example, 2132)

When the packets pass through the NAT gateway they will be modified so that they appear to be coming from the NAT gateway itself. The NAT gateway will record the changes it makes in its state table so that it can a) reverse the changes on return packets and b) ensure that return packets are passed through the firewall and are not blocked. For example, the following changes might be made:

  • Source IP: replaced with the external address of the gateway (for example, 24.5.0.5)
  • Source port: replaced with a randomly chosen, unused port on the gateway (for example, 53136)

Neither the internal machine nor the Internet host is aware of these translation steps. To the internal machine, the NAT system is simply an Internet gateway. To the Internet host, the packets appear to come directly from the NAT system; it is completely unaware that the internal workstation even exists.

When the Internet host replies to the internal machine's packets, they will be addressed to the NAT gateway's external IP (24.5.0.5) at the translation port (53136). The NAT gateway will then search the state table to determine if the reply packets match an already established connection. A unique match will be found based on the IP/port combination which tells PF the packets belong to a connection initiated by the internal machine 192.168.1.35. PF will then make the opposite changes it made to the outgoing packets and forward the reply packets on to the internal machine.

Translation of ICMP packets happens in a similar fashion but without the source port modification.

Source : Nat
posted by realme @ 1:41 AM  
0 Comments:
Post a Comment
<< Home
 
Writing is Difficult things but Copy Paste is Easy one, so what do want to choose?? Up to You...
About Me

Name: realme
Home:
About Me:
See my complete profile
Previous Post
Archives
The Note

Life like A Bird, free for flaying around the word.

Links
Powered by

Free Blogger Templates

BLOGGER