14

Trying to do below on Ubuntu 12.04.

Trying to configure eth0 and eth1, eth0 works fine, but failed to bring eth1.

Below is the settings /etc/network/interfaces:

auto eth0 eth1

iface eth0 inet static
address 172.19.20.186
netmask 255.255.255.252
network 172.19.20.184
broadcast 172.19.20.187
gateway 172.19.20.185

iface eth1 inet static
address 172.18.182.55
netmask 255.255.254.0
gateway 172.18.182.1

up route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0
up route add -net 172.19.24.0/23  gw 172.19.20.185 dev eth0
up route add default  gw 172.18.182.1 dev eth1

When /etc/init.d/networking restart is done, giving below error:

$ /etc/init.d/networking restart
RTNETLINK answers: File exists
Failed to bring up eth1

Even ifdown eth1 and ifup eth1 giving above error.

Can anyone help how to resolve this?

1
  • Two things you may want to check 1. Could be a typo of ethI rather than eth1 2. Probably you didn't add the network interface on the virtual machine
    – user541878
    May 10, 2016 at 9:32

3 Answers 3

15

I think you only need one default gateway. You have set up 3: gateway 172.19.20.185, gateway 172.18.182.1 and up route add default gw 172.18.182.1 dev eth1.

Try the following interfaces file:

auto eth0 eth1

iface eth0 inet static
  address 172.19.20.186
  netmask 255.255.255.252

iface eth1 inet static
  address 172.18.182.55
  netmask 255.255.254.0
  gateway 172.18.182.1
  up route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0
  up route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0

EDIT: Try this to manually configure the interfaces, so we can see where is the error.

  1. Shut down all interfaces: ifconfig eth0 down; ifconfig eth1 down; ifconfig eth2 down; ifconfig eth3 down
  2. Configure eth0: ifconfig eth0 172.19.20.186 netmask 255.255.255.252 up
  3. Configure eth1: ifconfig eth1 172.18.182.55 netmask 255.255.254.0 up
  4. Set up default gateway: route add default gw 172.18.182.1
  5. Set up first static route: route add -net 172.19.26.0/23 gw 172.19.20.185 dev eth0
  6. Set up second static route: route add -net 172.19.24.0/23 gw 172.19.20.185 dev eth0
6
  • Thanks for you response back. Tried the option that you provided, but still it is giving the same error. Is there any drivers need to be installed for eth1
    – Test1234
    Jun 6, 2013 at 18:01
  • Yes eth1 is there and also eth2 and eth3 is also there. If trying to configure eth2 and eth3 instead of eth1 it is giving the same error. Below is the snapshot for ifconfig -a eth1 eth1 Link encap:Ethernet HWaddr 6c:3b:e5:b1:40:4d inet addr:172.18.182.55 Bcast:172.18.183.255 Mask:255.255.254.0 inet6 addr: fe80::6e3b:e5ff:feb1:404d/64 Scope:Link
    – Test1234
    Jun 6, 2013 at 18:31
  • ifup and ifdown is showing the same error......ipconfig -a for eth2 and eth3 is below....eth2 Link encap:Ethernet HWaddr 6c:3b:e5:b1:40:4e BROADCAST MULTICAST MTU:1500 Metric:1...... eth3 Link encap:Ethernet HWaddr 6c:3b:e5:b1:40:4f BROADCAST MULTICAST MTU:1500 Metric:1 ........Resart the sever but still same issue
    – Test1234
    Jun 6, 2013 at 19:10
  • 1
    1.Shut down all interfaces: ifdown eth0 eth1 eth2 eth3 For this step it is giving below error...... ifdown: interface eth1 not configured ifdown: interface eth2 not configured ifdown: interface eth3 notconfigured ......for other step 2 to step 6 it is not giving any error
    – Test1234
    Jun 6, 2013 at 19:46
  • Excellent...tried to connect the ip address and it is working, problem got solved...thanks a bunch, you steps helped in solving the problem
    – Test1234
    Jun 6, 2013 at 20:04
7

Sometimes flushing the interface before bringing it up works:

ip addr flush dev enp2s0
1
  • Since I was messing with routes, it possibly hung somewhere and this one-liner solved the thing entirelly. Thanks.
    – SkyRaT
    Mar 17, 2017 at 13:34
0

Most probably your NetworkManager is in conflict with the /etc/network/interfaces. I am not sure about the dhcp case, but if you have setup the static IPs using the NetworkManager GUI, then these interfaces would have been defined in two separate place, hence the conflict.

Try disabling your Network Manager using following commands.

exec sudo -i
systemctl stop NetworkManager.service
systemctl disable NetworkManager.service
mv /lib/systemd/system/NetworkManager.service NetworkManager.service.res

you can enable your network manager again by

exec sudo -i
mv /lib/systemd/system/NetworkManager.service.res  NetworkManager.service
systemctl enable NetworkManager.service
systemctl start NetworkManager.service

after that your configuration from /etc/network/interfaces would be taken on reboot.

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.