15

This is my /etc/network/interfaces file contents

The only way this is taking effect is when the system reboots.

I'm trying to get it effected manually. My attempts below.

auto eth0
    iface eth0 inet static
           address 192.168.1.57
           netmask 255.255.255.0
           gateway 192.168.1.1
           up ip addr add 192.168.0.57/24 dev eth0 label eth0:1
           down ip addr del 192.168.0.57/24 dev eth0 label eth0:1
           up ip route add 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20
           down ip route del 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20

First tried to run sudo ifup eth0

and i receive

RTNETLINK answers: File exists
Failed to bring up eth0.

The /etc/network/interfaces only work when i reboot the system

Other than that i've tried

sudo /etc/init.d/networking restart

sudo service network-manager restart

sudo service networking restart

But none of them will bring up the changes in the interfaces file

My only option was sudo ifup eth0 and that gives the above error.

what is wrong?

10

Edit your configuration file to remove the spaces before the iface stanza so that it looks like this,

auto eth0
iface eth0 inet static
   address 192.168.1.57
   netmask 255.255.255.0
   gateway 192.168.1.1
   up ip addr add 192.168.0.57/24 dev eth0 label eth0:1
   down ip addr del 192.168.0.57/24 dev eth0 label eth0:1
   up ip route add 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20
   down ip route del 192.168.0.0/24 via 192.168.0.1 dev eth0:1 metric 20

The message you receive is just indication that the interface is already up, so you need to do ifdown before you do ifup. However, you need to be careful if you are connecting via ssh - you may lock yourself out. This is a way to do it:

sudo ifdown eth0 && sudo ifup eth0

Note, how these two commands are executed on the same line. And just a precaution, make sure you can get access to the server console or reboot the server if something goes wrong.

| improve this answer | |
  • 3
    running sudo ifdown eth0 gives ifdown: interface eth0 not configured and running sudo ifdown eth0 && ifup eth0 gives the same – wolfgang Sep 22 '15 at 19:09
  • 1
    @wolfgang, try removing spaces before iface stanza in your /etc/network/interfaces file and do ifdown/ifup again. – dtoubelis Sep 22 '15 at 19:31
  • This worked! did'nt expect spaces before iface would create such a big deal. could you please edit this into your answer so it may help someone? and there must be a sudo before ifup -> sudo ifdown eth0 && sudo ifup eth0 otherwise i get some permission denied error – wolfgang Sep 23 '15 at 6:38
2

I just ran into this problem and none of the solutions above worked for me. I couldn't change /run/network/ifstate because it was reset immediately to the former state. Also sudo ifdown eth0 && sudo ifup eth0 didn't work.

I then found out the following command:

sudo ip addr flush dev eth0

which solved the problem.

| improve this answer | |
  • Correct answer for me, too. – JohnnyFromBF Apr 24 at 15:19
1

Try to look for /run/network/ifstate, and modify it by adding eth(n)=eth(0) if you don't see the desired eth there.

Ex:

$ cat /run/network/ifstate 
eth0=eth0
lo=lo
eth3=eth3
eth1=eth1

After that use the command sudo ifdown eth(n) and then sudo ifup eth(n).

| improve this answer | |
1

To anybody else that ended up here, I had to stop all interfaces and bridges and then unload the modules before the RTNETLINK error would go away.

ifconfig eth0 down
ifconfig br0 down
rmmod e1000e              # or whatever module your nic uses
modprobe e1000e
service networking start

or just reboot.

| improve this answer | |
0

I have just spent a day on this problem with my pi. I had changed nothing but moved the box physically. My pi has a wifi connection through a WIFI dongle Realtek RTL8188CUS. Yes i have already fixed the dropout issues with some kernel module parameters, mainly "options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1" in a file /etc/modprobe.d/8192cu.conf But the pi still occasionaly used to drop out. Now i moved it seems cannot connect with a static IP 192.168.1.60. So what was problem? For me the "RTNETLINK file exists" is an issue set by me at sometime in my wireless router. I put a DNS entry in the router for 192.168.1.60 but with a low TTL value by mistake. Rather than TTL=1200 i had TTL=12. I removed the bad entry in the router and WIFI then connected after reboot. So if you are playing with static routes with Pi and the router at the same time beware you may have set something bad in the router. Its not always the PI network fault.

| improve this answer | |

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.