From owner-freebsd-doc@FreeBSD.ORG Tue Feb 24 08:30:17 2004 Return-Path: Delivered-To: freebsd-doc@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB02B16A4CE for ; Tue, 24 Feb 2004 08:30:17 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D641443D2D for ; Tue, 24 Feb 2004 08:30:17 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i1OGUHbv059772 for ; Tue, 24 Feb 2004 08:30:17 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i1OGUH4L059771; Tue, 24 Feb 2004 08:30:17 -0800 (PST) (envelope-from gnats) Resent-Date: Tue, 24 Feb 2004 08:30:17 -0800 (PST) Resent-Message-Id: <200402241630.i1OGUH4L059771@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-doc@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, hoanga@mac.com Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5B28316A4CF for ; Tue, 24 Feb 2004 08:29:01 -0800 (PST) Received: from samsara.bebear.net (pc1.doctorm-unet.ocn.ne.jp [220.110.95.89]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEAF143D1D for ; Tue, 24 Feb 2004 08:29:00 -0800 (PST) (envelope-from al@bebear.net) Received: by samsara.bebear.net (Postfix, from userid 1001) id D83452E0BF; Wed, 25 Feb 2004 01:28:58 +0900 (JST) Message-Id: <20040224162858.D83452E0BF@samsara.bebear.net> Date: Wed, 25 Feb 2004 01:28:58 +0900 (JST) From: hoanga@mac.com To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: docs/63310: Configuring Static Routes example for Handbook X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: hoanga@mac.com List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2004 16:30:18 -0000 >Number: 63310 >Category: docs >Synopsis: Configuring Static Routes example for Handbook >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-doc >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Tue Feb 24 08:30:17 PST 2004 >Closed-Date: >Last-Modified: >Originator: Al Hoang >Release: FreeBSD 5.2.1-RC2 i386 >Organization: Doctor M >Environment: System: FreeBSD samsara 5.2.1-RC2 FreeBSD 5.2.1-RC2 #1: Wed Feb 18 23:23:59 JST 2004 root@samsara:/usr/obj/usr/src/sys/SAMSARA i386 >Description: How to configure static routes in FreeBSD for the Handbook >How-To-Repeat: >Fix: Setting up static routes Setting up static routes in FreeBSD Manual configuration Let's assume you have a network as follows: INTERNET | (10.0.0.1/24) Default Router to Internet | |Interface xl0 |10.0.0.10/24 +------+ | | Router A | | (FreeBSD gateway) +------+ | Interface xl1 | 192.168.1.1/24 | +--------------------------------+ Internal Net 1 | 192.168.1.2/24 | +------+ | | Router B | | +------+ | 192.168.2.1/24 | Internal Net 2 In this scenario, Router A is our FreeBSD 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 Router B 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 B using 192.168.1.1 as the gateway). If we look at the routing table for A we would see something like the following: % 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. A 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 add. The following command would add the Internal Net 2 network to A's routing table using 192.168.1.2 as the next hop. % route add network 192.168.2.0/24 192.168.1.2 Now A can reach any hosts on the 192.168.2.0/24 network. Persistent Configuration The above example is great for configuring a static route on a running system. However, one problem is that the routing information will not persist if you reboot your FreeBSD machine. The way to handle adding a static route is to put it in your /etc/rc.conf file. Example configuration: # 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. The string references to another configuration variable that will be named route_....... In our above example we only have one string in static_routes. This string is internalnet2. We then need a configuration variable called route_internalnet2 where we add all of the configuration parameters we would give to the route command. For our example above we would have used the command % 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". We could have more than one string in static_routes. This would allow us to create multiple static routes. The following snippet shows an example of adding static routes for the 192.168.0.0/24 and 192.168.1.0/24 on an imaginary router. the following: 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" >Release-Note: >Audit-Trail: >Unformatted: