1

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 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.

0

I do not find particularly a good idea to place secondary IP addresses first.

The problem is far greater than you using the default route of eth0, as it is the first interface, when routing to other networks, your source IP is the DHCP IP address de facto and not 10.20.8.231.

As such I would recommend placing your static address in eth0 in lieu of eth0:0 with the following configuration:

auto eth0
iface eth0 inet static
    address 10.20.8.231
    netmask 255.255.255.0
    gateway 10.20.8.1

auto eth0:0
iface eth0:0 inet dhcp
  • I completely agree with you but and I have two issues with this.think I tried adding routes in eth0's stanza and it also failed to add the routes but I will have to restest, my memory is fuzzy (tried to many things) – TCZ8 Dec 21 '15 at 21:11
  • But it doesn't really matter as the default route will then be set to the proper IP and I won't need the extra route. – TCZ8 Dec 21 '15 at 21:19
  • The second issue is that I tried setting eth0:0 to dhcp but when I run ifconfig eth0:0 up I get the error SIOCSIFFLAGS: Cannot assign requested address and when I try ifup eth0:0 I get Bind socket to interface: No such device Failed to bring up eth0:0. googling pointed me to unresolved issues with dhclient and mac address handling issues when dealing with virtual adapters. So I am not sure what else I can do, although this solution would be ideal. – TCZ8 Dec 21 '15 at 21:25
  • now I understand the routes. try ifdown eth0:0 and then ifup eth0:0 Even if it gives the error do a ifconfig -a and check wether it worked – Rui F Ribeiro Dec 21 '15 at 23:19
0

It seems ifupdown does not play well with lower-level tools like iproute2 or net-tools. It is mentioned as warning in the official Debian documentation:

Warning

Do not use low level configuration tools such as ifconfig(8) and ip(8) commands to configure an interface in up state.

You may try to manually flush and disable your network interface before using ifupdown to fix your issue:

 # ip addr flush dev [interface_name]
 # ip link set down dev [interface_name]
 # ifdown [interface_name]
 # ifup [interface_name]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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