21

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?

6 Answers 6

12

Edit your configuration file to remove the indentation 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 access the server console or able to reboot the server if something goes wrong.

3
  • 3
    running sudo ifdown eth0 gives ifdown: interface eth0 not configured and running sudo ifdown eth0 && ifup eth0 gives the same
    – wolfgang
    Sep 22, 2015 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, 2015 at 19:31
  • 1
    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, 2015 at 6:38
7

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.

1
  • 2
    Correct answer for me, too. Apr 24, 2020 at 15:19
2

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

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.

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.

0

correct me if i am wrong...

but if you are setting up config for a manual connection, then why are you using:

auto eth0

?

the auto = automatic not manual.

just take out the auto line in your interfaces file and then add in:

pre-up /sbin/ip link set eth0 up
post-down /sbin/ip link set eth0 down

and sub in your device for eth0 and if you have more than one, add the 2 lines for each device.

ALSO

you can't duplicate a gateway

so only list the gateway once

ALSO

you can't have mixed config on the same device

so if you are manually setting up your ipv4, your ipv6 for the same device must be set up manually as well.

here is my interfaces file as an example:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
iface enp3s1f0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 1.1.1.1 1.0.0.1

iface enp3s1f1 inet static
        address 192.168.0.101
        netmask 255.255.255.0
        dns-nameservers 1.1.1.1 1.0.0.1

iface enp3s1f1 inet6 static
        address 2600:6000:7a00:ab:123:1234:1234:abc
        netmask 64
        dns-nameservers 2606:4700:4700::1111 2606:4700:4700::1001

iface enp3s1f0 inet6 static
        address 2600:6000:7a00:ab:123:1234:1234:abd
        netmask 64
        dns-nameservers 2606:4700:4700::1111 2606:4700:4700::1001

pre-up /sbin/ip link set enp3s1f0 up
pre-up /sbin/ip link set enp3s1f1 up
post-down /sbin/ip link set enp3s1f0 down
post-down /sbin/ip link set enp3s1f1 down

fom tooley

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .