File exists error while restarting network interface (Debian)

user3581369 asked:

I’m running a Debian GNU/Linux 8 server for school assignments.

While trying to do service networking restart, it gave me this error:

root@server:~# service networking restart
[warn] Running /etc/init.d/networking restart is deprecated because it may not re-enable some interfaces ... (warning).
[....] Reconfiguring network interfaces...RTNETLINK answers: File exists
Failed to bring up eth0.
done.

Here is the /etc/network/interfaces file:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address 193.191.187.47
        netmask 255.255.255.128
        gateway 193.191.187.62
        post-up arp -f /etc/ethers

iface eth0 inet6 static
        address 2001:6a8:2880:a077::47
        netmask 64
        gateway 2001:6a8:2880:a077::1

I haven’t changed anything about this config lately. I’ve been working on my postfix SMTP assignment and opening some ipv6 ports with ip6tables. Can any of this cause the problem?

Cheers

My answer:


RTNETLINK answers: File exists is a confusing error that occurs when you try to add an IP address to an interface that already has that same IP address. It’s not exactly a “file” that exists, but the IP.

As the script mentioned, it is deprecated. What is happening is that it is not bringing the interfaces down properly and not removing the existing IPs from them. You should be restarting interfaces by another method.

The current method in Debian is to use ifdown and ifup to stop and start individual interfaces. For example:

ifdown eth0; ifup eth0

Note that (unlike the other answer) we always try to bring the interface back up with ifup, even if ifdown reports a failure. You don’t want to get locked out of remote access to the system simply because something went wrong, if you can avoid it (though it’s not always avoidable).


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.