6.6. Making Static Routes Persistent

You don't want to have to retype all those route commands every time there's a power blip, or when you make hardware changes. Aren't there some nice configuration files for permanently enshrining your static routes?

Of course there are. On Debian, add them to /etc/network/interfaces in the stanza for their corresponding interface:

	auto eth1
	iface eth1 inet static
	address 192.168.10.100
	netmask 255.255.255.0
	gateway 22.33.44.55
	broadcast 192.168.10.255

	up route add -net 172.16.5.0/24 gw 192.168.10.100 eth1
	up route add -net 172.24.0.0/24 gw 192.168.10.100 eth1
	down route del -net 172.24.0.0/24
	down route del -net 172.16.5.0/24

On Fedora, create a /etc/sysconfig/network-scripts/route-* file, like this:

	##/etc/sysconfig/network-scripts/route-eth1
	192.168.10.0/24 via 172.24.0.25
	172.16.5.0/24 via 172.24.0.25

This uses ip command-type syntax. It is important to use the correct filename, with your correct device name, or it won't work. Take the device name from its own configuration file, like /etc/sysconfig/network-scripts/ifcfg-eth1.

On Fedora, don't use /etc/network/static-routes. That was deprecated several releases ago, and no longer works.

Your routers will need a default gateway if there is another route out of your network, like an Internet connection. If there is no Internet or link to another separate network, they won't need default gateways.