From e5417cbf82054130be127bcf76f9c71f9fb73970 Mon Sep 17 00:00:00 2001 From: Marc Fonvieille Date: Thu, 26 Feb 2004 20:28:51 +0000 Subject: [PATCH] Add a section about static route configuration (this addition contains an ASCII art diagram, I'll add a graphic version ASAP). PR: docs/63310 Submitted by: Al Hoang --- .../handbook/advanced-networking/chapter.sgml | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.sgml b/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.sgml index 4887355ae7..919e9ff0cc 100644 --- a/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.sgml +++ b/en_US.ISO8859-1/books/handbook/advanced-networking/chapter.sgml @@ -455,6 +455,133 @@ host2.example.com link#1 UC 0 0 however. + + + + + Al + Hoang + Contributed by + + + + + Setting Up Static Routes + + + Manual Configuration + + Let us assume we have a network as follows: + + + INTERNET + | (10.0.0.1/24) Default Router to Internet + | + |Interface xl0 + |10.0.0.10/24 + +------+ + | | RouterA + | | (FreeBSD gateway) + +------+ + | Interface xl1 + | 192.168.1.1/24 + | + +--------------------------------+ + Internal Net 1 | 192.168.1.2/24 + | + +------+ + | | RouterB + | | + +------+ + | 192.168.2.1/24 + | + Internal Net 2 + + + In this scenario, RouterA is our &os; + machine that is acting as a router to the rest of the + Internet. It has a default route set to 10.0.0.1 which allows it to connect + with the outside world. We will assume that + RouterB is already configured properly and + knows how to get wherever it needs to go. (This is simple + in this picture. Just add a default route on + RouterB using 192.168.1.1 as the gateway.) + + If we look at the routing table for + RouterA we would see something like the + following: + + &prompt.user; netstat -nr +Routing tables + +Internet: +Destination Gateway Flags Refs Use Netif Expire +default 10.0.0.1 UGS 0 49378 xl0 +127.0.0.1 127.0.0.1 UH 0 6 lo0 +10.0.0/24 link#1 UC 0 0 xl0 +192.168.1/24 link#2 UC 0 0 xl1 + + With the current routing table. RouterA + will not be able to reach our Internal Net 2. It does not + have a route for 192.168.2.0/24. One way to alleviate + this is to manually add the route. The following command + would add the Internal Net 2 network to + RouterA's routing table using 192.168.1.2 as the next hop. + + &prompt.root; route add network 192.168.2.0/24 192.168.1.2 + + Now RouterA can reach any hosts on the + 192.168.2.0/24 + network. + + + + Persistent Configuration + + The above example is perfect for configuring a static + route on a running system. However, one problem is that the + routing information will not persist if you reboot your &os; + machine. The way to handle the addition of a static route + is to put it in your /etc/rc.conf + file: + + # Add Internal Net 2 as a static route +static_routes="internalnet2" +route_internalnet2="network 192.168.2.0/24 192.168.1.2" + + The static_routes configuration + variable is a list of strings seperated by a space. Each + string references to a route name. In our above example we + only have one string in static_routes. + This string is internalnet2. We + then add a configuration variable called + route_internalnet2 + where we put all of the configuration parameters we would + give to the &man.route.8; command. For our example above we + would have used the command: + + &prompt.root; route add network 192.168.2.0/24 192.168.1.2 + + so we need "network 192.168.2.0/24 192.168.1.2". + + As said above, we can have more than one string in + static_routes. This allows us to + create multiple static routes. The following lines shows + an example of adding static routes for the 192.168.0.0/24 and 192.168.1.0/24 networks on an imaginary + router: + + static_routes="net1 net2" +route_net1="network 192.168.0.0/24 192.168.0.1" +route_net2="network 192.168.1.0/24 192.168.1.1" + + + Routing Propagation routing propagation