16

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?

Radu Rădeanu
  • 174,089
  • 51
  • 332
  • 407
Test1234
  • 193
  • 1
  • 1
  • 9

3 Answers3

18

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
Eric Carvalho
  • 55,453
8

Sometimes flushing the interface before bringing it up works:

ip addr flush dev enp2s0
Eliah Kagan
  • 119,640
Rohit Sehgal
  • 81
  • 1
  • 1
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.