Why are routes set in /etc/network/interfaces not added when the interface comes up?
3
votes
2
answers
5067
views
Here is my interfaces file:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth0:0
iface eth0:0 inet static
address 10.20.8.231
netmask 255.255.255.0
gateway 10.20.8.1
up /sbin/route add 1.2.3.4 gw 10.20.8.1
down /sbin/route del 1.2.3.4 gw 10.20.8.1
From the multiple examples I have found online this should add routes when eth0:0 comes up but for some reason I can't get it to work.
When I try to bring up the interface with
**Thank you for your assistance.**
ifup eth0:0
I get:
RTNETLINK answers: File exists
Failed to bring up eth0:0.
Then, ifconfig
shows eth0:0 is up but route -n
does not show the new route. In fact it shows the exact same routes I had before. Nothing changed.
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.20.8.1 0.0.0.0 UG 0 0 0 eth0
10.20.8.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
This config is to be used on remote systems that can only be accessed via SSH. The whole idea is to keep eth0 set to dhcp as a backup when the site's network is changed (happened twice already) rendering the static ip unaccessible. The problem with this is that SSH (used by built in processes) uses the default route via eth0 and that doesn't work as the firewall (not managed by us) has been set to allow ssh only for the static IP on eth0:0.
Note: In the example above 1.2.3.4 represents our ssh server and I am trying to route traffic via eth0:0 for that single host but after testing I may want to set the default route to use eth0:0 instead, but I also tried that and it failed the same way. I was using this line:
up route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.20.8.1
**Thank you for your assistance.**
Asked by TCZ8
(1109 rep)
Dec 21, 2015, 03:58 PM
Last activity: May 24, 2025, 04:29 PM
Last activity: May 24, 2025, 04:29 PM