Routing Between Three or More Networks


In all the situations up to this point, the router configuration has only needed one route. For example, our simba gateway only has one connection to the Internet, and it only serves one network. Figure 28.8 shows how this works.

Figure 28.8. The gateway simba here only needs to route packets between two networks, which are the local LAN and the Internet.


In this simple example, the hosts lion, cheetah, lynx, and puma use simba as their default gateway to communicate with systems on the Internet. Likewise, simba also has a default router, and it is set to the router at the ISP. For a dial-up PPP connection, this is transparent to you because the default route will be added automatically when the PPP connection is established, and it will be deleted automatically when the PPP connection terminates. You do not need to worry about this, but you should be aware that your gateway has a default router it uses, just as your clients that use the gateway use it as a default router.

However, sometimes you might have a more complex configuration, such as that shown in Figure 28.9. In this situation, simba acts as the default router for its own network as well as serving as the default router for falcon, which is itself a default router for another network.

Figure 28.9. A more complex gateway setup. In this case, simba acts as a default router for its own network as well as serving as the default router for falcon, which is itself a default router for another network.


In this example, in addition to serving the clients on its own network, simba is actually serving as an Internet service provider to the network served by the router falcon. This means that simba now needs to route between three networks. For this to work, you need to add another route to simba so that it knows what packets should be routed to the network served by falcon as well as how to get them there.

The network served by falcon owns a Class C address block. Notice that all the addresses on the network begin with the base address of 205.211.117. xxx. Also, notice that falcon has an IP address of 169.151.116.121. To get simba to route packets to the network served by falcon, you can add the following lines to /etc/rc.conf:

defaultroute="212.214.111.59" static_routes="falcon" falcon="-net 205.211.117.0 169.151.116.121"


In this case, the IP address 212.214.111.59 is the default router for simba. In other words, any packets that simba receives that are for hosts it doesn't know about will be sent to this router. 212.214.111.59 is the router at the Internet backbone provider that serves simba.

You have also added what is called a static route. This is an entry in the routing table that is staticit does not change. In this case, you have told simba that any packets it receives that have a destination with a base address of 205.211.117.0 should be routed to the address 169.151.116.121. This is the IP address of falcon, which itself serves as a router for another network. As you can see, all the hosts on the network served by falcon begin with an IP address of 205.211.117. xxx. Therefore, any packets that simba receives that are intended for any of these hosts will be routed to falcon rather than to the default route of 212.214.111.59. In addition, any packets received by simba that are intended for clients on its own network will be routed directly to those clients rather than sent to the default route.

In order for the static routes to take effect, you will need to reboot the system. It is recommended that you reboot the system, but if you do not want to, you can add the static routes manually so they will take effect immediately. In the previous example, this can be done with the following command from a root shell:

# route add -net 205.211.117.0 169.151.116.121





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net