Monday, July 27, 2009

Enabling Persistent Routes on a Debian Host

1. su to root
2. cd to /etc/network/
3. Copy off the interfaces file to interfaces.DATE (or what have you)
4. Add lines of the following form under the primary network interface definition:

up route add -net 10.1.1.0 netmask 255.255.255.0 gw 10.2.1.1
down route del -net 10.1.1.0 netmask 255.255.255.0

So you should end up with something like this:

iface bond0 inet static
address 10.2.1.5
netmask 255.255.255.0
network 10.2.1.0
gateway 10.2.1.1
up /sbin/ifenslave bond0 eth0
up /sbin/ifenslave bond0 eth2
up route add -net 10.1.1.0 netmask 255.255.255.0 gw 10.2.1.1
down route del -net 10.1.1.0 netmask 255.255.255.0


That creates a route to the 10.1.1.x network for the host with the ip 10.2.1.5 through the 10.2.1.1 router whenever the interface goes up. (It also removes it whenever the interface goes down.)

No comments:

Post a Comment