Daryl's TCP/IP Primer

Addressing and Subnetting on the Near Side of the 'Net

[<--Prev] [Next-->]
[Printable Version] [Daryl's ColdFusion Primer] [About Daryl] Bookmark and Share
Google
 
Daryl's TCP/IP Primer on Facebook

11. Network Address Translation (NAT)

Network Address Translation, or NAT, is accomplished using software that can hide one or more subnets behind a single IP address. NAT software is typically found in newer Internet routers and almost always used in firewalls and proxy servers. NAT is not the same as an HTTP Proxy server. HTTP Proxy servers must be configured on the client side. Once configured, your Web browser asks the HTTP proxy to make connections to the Internet on your behalf; as far as the Web site you're connecting to knows, it's the proxy server that's reading the Web page, not your browser. NAT is an effect of the HTTP proxy in this case; the requests from all of the browsers using the HTTP proxy appear to be coming from the proxy server, not from the workstation. The workstation does not need to be using IP addresses that are routable to the Internet; in fact, it is normal to use addresses that are reserved for this purpose, such as 10.x.x.x (see Tips and Tricks, later in this document.) "Transparent" NAT is easier to implement (since nothing needs to be changed at the workstations). However, "configured" NAT (e.g., HTTP proxy servers) often add additional features, such as Web page caching.

NAT software accomplishes three basic things: I like to refer to NAT routers as "transparent TCP proxy routers." Transparent, because unlike HTTP proxies, NAT routers do not need any configuration nor application software support to work with most TCP-based protocols. NAT routers will proxy outbound connections "automagically."

For every outbound TCP connection, the NAT router intercepts and creates its own TCP connection to the destination host. The NAT router builds a growing list of port translations. Consider two computers that open three TCP connections each to a web server to download the same Web page. At the same time, a Linux workstation opens a Telnet session to rs.internic.net:
diagram
The web server thinks the NAT router at 208.208.208.208 has two browsers running that both just opened the same document and images; the Telnet server thinks that the same computer at 208.208.208.208 opened a Telnet session to it; only the NAT software knows that three computers have seven connections open from behind it.

Transparent NAT works well for TCP connections, but due to the connectionless nature of UDP, NAT works less well for unusual UDP connections (sorry, Quake fans..!)

Since NAT routers are hiding many machines behind a single IP address, putting server(s) behind a NAT router becomes a problem, since the NAT software has no way of determining for itself what IP address to forward the inbound connection requests to. This dropping of inbound connections, while allowing outbound connections, makes NAT routers into cost-effective low-end firewalls. Though NAT routers do nothing to prevent users from downloading viruses or trojan horse programs (like the well-publicized trojan horse Back Orifice), but does go a long way toward blocking attempts to connect inbound to the running trojan horse, if accidentally or maliciously installed.

If your NAT router only supports one "real" IP address, you can only have one service on your network listening on the "well known port" for that service; you could have two Web servers listening on different ports, but not two web servers both listening on (e.g.) 208.208.208.208:80. For example, you have a LAN configured as follows:
diagram
This image created using SmartDraw. Click Here for a free trial copy.
You would configure the NAT software to listen to ports 25 and 80 on 208.208.208.208, and forward connections as follows:
"Listening" Port"Internal" Address
208.208.208.208:25192.168.1.5:25
208.208.208.208:80192.168.1.9:80


If you want to play with NAT software, and you have an old PC-compatible machine lying around (NAT is easy for routers to do and does not require much in the way of hardware), Look at two Linux-based standalone router efforts: FreeSCO at http://www.freesco.org/, or the Linux Router Project (http://linuxrouter.org/ Please, read the manual and experiment a bit with the software before sending me questions specific to FreeSCO or LRP. You'll learn more that way, and I didn't help write the program, so I probably shouldn't be the person you talk to for tech support about it, anyway. :-)

Platform Specific Infomation: Note that TCP/IP proxies are not platform-specific. In other words, it works fine to place a MS-DOS based proxy server (such as IPRoute) on a Mac network, or a Linux proxy on a Novell-based IP network. But if you only want to add software, not hardware, to your network, then here are some options I've found. (Note: I do not explicitly endorse the use of any of these products, they're merely listed here for your convenience.)

Next: The Domain Name System (DNS)
Copyright ©1996-2010 Daryl Banttari. See Disclaimer.