FreeBSD Static Routing Configuration
Q. How do I configure FreeBSD for static routing? I'd like to set default route to 60.1.2.3 and static route for network 192.168.1.0/24 using 192.168.1.254 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 60.1.2.3:
defaultrouter="60.1.2.3"
Create static routing for lan network 192.168.1.0/24, append following two lines:
static_routes="lan"
route_lan="-net 192.168.1.0/24 192.168.1.254"
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 192.168.1.0/24 192.168.1.254" : Specify roting network and router IP address
- defaultrouter="60.1.2.3" : 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
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_
passed to a route add operation at boot time. For example, setup static routing as follows:
| network | router IP |
| lan (192.168.1.0/24) | 192.168.1.254 |
| mumoffice (10.0.0.0/8) | 10.30.110.5 |
| foo 169.254.1.1 | via loopback (lo0) |
Add following to /etc/rc.conf
static_routes="lan mumoffice foo"
route_lan="-net 192.168.1.0/24 192.168.1.254"
route_mumoffice="-net 10.0.0.0/8 10.30.110.5"
route_foo="-host 169.254.1.1 -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.
Further readings:
- See man pages - mrouted, router and rc.conf
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Linux / UNIX FAQ:
- Solaris UNIX Add Static Routes
- Linux Set Up Routing with ip Command
- Linux setup default gateway with route command
- Setting Up a CentOS / Red Hat Linux DHCP Client
- FreeBSD Disable /etc/rc.d Services Which Started Up At Initial Boot Time
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Please do not use the comment form to ask for help / question. Ask your question on the excellent Linux tech support forum. Thank you very much for stopping by our site!
Tags: /etc/rc.conf, default routing, defaultrouter, freebsd default route, freebsd firewall, freebsd routing, freebsd static route, freebsd static routes, freebsd static routing, ip address routing, ip routing, network routing, route command, route_lan, routing multicast, setup static routing, static_routes ~ Last updated on: February 3, 2008



Recent Comments
Today ~ 1 Comment
Today ~ 1 Comment
Today ~ 3 Comments
Today ~ 1 Comment
Yesterday ~ 3 Comments