When two machines wish to use TCP/IP to communicate with each other, they generally specify the destination by using a combination of the IP address and a port. For example, World Wide Web communication is done on port 80. To make this work, when you type http://www.mommabears.com, TCP/IP looks at www and automatically translates this to http://www.mommabears.com:80.
There are 65,536(=2^16) available ports. The first 1,024 ports and a number of others are assigned to specific TCP/IP services such as www, FTP, and more. Widely used services such as TCP/IP, the Web, FTP, and e-mail all have assigned ports. A more complete list of TCP and UDP ports can be found on the Internet at http://www.isi.edu/in-notes/iana/assignments/port-numbers. Web servers listen on port 80. When you try to reach Momma Bears’ Bears with http://www.mommabears.com, the associated Web server hears the message and returns Momma Bears’ Web site as a message to your computer.
But the Momma Bears’ Web server doesn’t answer on port 80. If it did, it would clog up the channel (port 90), preventing others from reaching the Momma Bears’ Web site. Fortunately, when you type in http://www.mommabears.com, TCP/IP also sends an unassigned port number to the Momma Bears’ Web server. The server uses this port number to send the web site back to the host, which leaves port 80 free for further incoming requests.
Routing to the Internet is like zip or postal codes: It allows your message to find its destination. After all, when you use Netscape or some other Web browser to connect to Yahoo’s Web site, your machine knows nothing about the actual physical location of the Yahoo’s Web server. Your ISP translates www.yahoo.com into an IP address. And somehow, the request makes it to Yahoo, and Yahoo’s response finds its way back to you.
Let’s start with a simple example of routing. You are connected to a small corporate local area network (LAN) that has an Internet connection. The Internet connection is made through a router connected to the corporate LAN and your company’s connection to its ISP. Each router acts as gateway. As a gateway, it has a connection and an IP address on your LAN. It also has an IP address assigned by you ISP.
Because your LAN has only a single connection to the outside world through the router, routing is a simple matter. Each machine on the Internet is configured with a default gateway, which is the IP address of the router on you LAN. Whenever a host on the LAN wants to connect with a computer outside the local network, it sends the request to the gateway IP address, i.e., the router. The router is responsible for redirecting the information to your ISP.
In this way, the entire outside world is a black box: All outward-bound information is simply sent to the router as if the router encapsulated the entire beyond the LAN.
Consider the ISP’s LAN. Here you see two routers: Router A, which connects the ISP’s LAN to the connection to the local LAN, and Router B, which connects the ISP’s LAN to the connection to the Internet.
Since each network needs a default gateway, Router B is the ISP’s default gateway. When a host on the ISP’s LAN is trying to connect to the Internet, it sends the information to Router B.
Routing can become extremely complex in large organizations with multiple sites, multiple LANs, and multiple connections to the Internet. In these cases, routing has to be carefully designed to ensure the most efficient routing of information in the most secure manner possible. For instance, two remote locations may have a direct connection between them in addition to their own connections to the Internet. It wouldn’t make sense to route packets between these sites through the public Internet. This is both inefficient and an unnecessary security hole.
Complex routing of large networks is beyond the scope of this book and belongs in tomes dedicated to networking. The discussion in this chapter should provide sufficient background for understanding the typical network routing environment in which most Linux users will find themselves.