Wednesday, March 11, 2009

FreeBSD Static Routing Configuration

FreeBSD Static Routing Configuration
by Vivek Gite

Q. How do I configure FreeBSD for static routing? I'd like to set default route to and static route for network using router. How do make configuration persistence?

A. You can use FreeBSD route command to setup a default route / gateway. You need to edit /etc/rc.conf configuration file to setup static and default routing.

FreeBSD Static Routing Configuration
Open /etc/rc.conf file using a text editor:
# vi /etc/rc.conf
Set default router IP to
Create static routing for lan network, append following two lines:
Save and close the file. Where,

static_routes="lan" : Set to the list of static routes that are to be addedat system boot time.
route_lan="-net" : Specify roting network and router IP address
defaultrouter="" : Set a default route to this host name or IP address. It is recommended that you use an IP address.
Restart FreeBSD networking service to update routing information:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart

To view routing table, enter:
# netstat -r
# netstat -rn

How do I add multiple static routes?
For each whitespace (blank space) separated element in the value, a route_ variable is assumed to exist whose contents will later be
passed to a route add operation at boot time. For example, setup static routing as follows:

network router IP
lan (
mumoffice (
foo via loopback (lo0)

Add following to /etc/rc.conf
static_routes="lan mumoffice foo"
route_foo="-host -iface lo0"
FreeBSD Multicast Roting Configuration
Multicast routing requires that support be compiled into the kernel with the following option:
options MROUTING
In addition, the multicast routing daemon, mrouted must be installed and configured to set up tunnels and DVMRP via /etc/mrouted.conf. See mrouted page at offical FreeBSD project page for more information.

No comments: