I have a route that I am manually adding at each reboot:

route add -net 192.168.126.0/24 gw 192.168.1.1 dev eth1

How can I make this route persistent?

I've seen quite a few articles online that suggest adding the following to /etc/networking/interfaces:

up route add -net 192.168.126.0/24 gw 192.168.1.1 dev eth1

but when I try this, the machine comes up without this route appearing in the routing table.

Thanks in advance.

link|improve this question
feedback

2 Answers

up vote 5 down vote accepted

putting it in /etc/networking/interfaces is often the best approach, you just have to put it in the right place... you didn't specify where you put it.

iface eth0 inet dhcp
  up $COMMAND_HERE

I'm in the habit of using "ip" instead of "route". Another example:

iface eth1 inet static
  address 192.168.1.100
  netmask 255.255.255.0
  gateway 192.168.1.254
  up ip route add 192.168.126.0/24 via 192.168.1.253

Should work!

link|improve this answer
1  
under debian the package iproute provides the ip binary – ThorstenS Aug 9 '09 at 21:45
feedback
route add -net 192.168.126.0/24 gw 192.168.1.1 dev eth1

You can also add that to your /etc/rc.local

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.