82

I had this problem when I got my new Wi-Fi dongle and have seen a few people with the same issue. Basically when I have one interface configured and want to swap to the other one, it throws up this error:

RTNETLINK answers: File exists
Failed to bring up eth0

or something similar.

/etc/network/interfaces file:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.1.2
    netmask 255.255.255.0
    gateway 192.168.1.1

iface wlan0 inet static
    address 192.168.1.3
    netmask 255.255.255.0
    gateway 192.168.1.1
Peter Mortensen
  • 2,004
  • 2
  • 15
  • 18
theo-brown
  • 2,082
  • 1
  • 16
  • 13

8 Answers8

84

If the solution provided by @theoB610 still doesn't work, then you might have to flush the wlan0 device before ifup and ifdown.

sudo ip addr flush dev wlan0

This is a problem not too specific to Raspberry Pi, a similar problem occurred and was solved in wired networks in here (from where I derived the solution for my problem with the Pi).

Ébe Isaac
  • 1,011
  • 2
  • 9
  • 12
46

I think a solution can be found in this blog post Solving “RTNETLINK answers: File exists” when running ifup; it certainly fixed it for me.

Basically you can only have one gateway assigned in your interfaces file. Remove any duplicate lines that determine the gateway so that it only appears once.

Modified /etc/network/interfaces file:

auto lo
iface lo inet loopback

auto eth0 iface eth0 inet static address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1

iface wlan0 inet static address 192.168.1.3 netmask 255.255.255.0 #gateway 192.168.1.1 <= Either comment or remove this line

All credit to Lennart for solving this issue!

theo-brown
  • 2,082
  • 1
  • 16
  • 13
15

I solved by:

sudo ifup --ignore-errors wlan0

after this command ifdown and ifup started work properly.

mauretto
  • 251
  • 2
  • 4
1

steps:

1 check-> ip route (if ip route default is other than your required interface then, follow 2d & 3rd step)

2 sudo ip route del default (delete that default interface)

3 sudo ip route add default via ip_address dev interface_name (add your required interface like this)

Shan-Desai
  • 1,541
  • 2
  • 13
  • 28
0

I stumbled across this while messing around with VMWare vCenter. If you're in the same boat, you should have installed the VMWare Tools, perl, and net-tools with your package manager before making the Template/Snapshot of the VM.

turiyag
  • 101
0

We use ifdown to remove RTNETLINK and ifup again

ifdown wlan0
ifup wlan0
0

In my case, I had another connection still running - once I took that interface down with ifdown eth0, the one I was interested in (wlan0) came up cleanly.

I don't recommend using the --ignore-errors option

tamale
  • 101
  • 1
0

Force de/configuration

ifdown --force --verbose ethX && ifup --force --verbose ethX
techraf
  • 4,353
  • 10
  • 32
  • 43
Nico
  • 11