74

I have a Debian system working as a wireless router with eth0 and wlan0. Now I added an additional network manually on eth1 with ifconfig:

alix:~# ifconfig eth1 192.168.0.2 netmask 255.255.255.0
alix:~# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG        0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
192.168.3.0     0.0.0.0         255.255.255.0   U         0 0          0 wlan0
alix:~# ping 192.168.0.254
PING 192.168.0.254 (192.168.0.254) 56(84) bytes of data.
64 bytes from 192.168.0.254: icmp_req=1 ttl=64 time=0.537 ms
64 bytes from 192.168.0.254: icmp_req=2 ttl=64 time=0.199 ms
64 bytes from 192.168.0.254: icmp_req=3 ttl=64 time=0.188 ms
^C
--- 192.168.0.254 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2005ms
rtt min/avg/max/mdev = 0.188/0.308/0.537/0.161 ms

Everything works fine as you can see.

Now I would like to make the configuration permanent. Therefor I added the following section to /etc/network/interfaces:

alix:~# sed -n '/iface eth1/,/^$/p' /etc/network/interfaces
iface eth1 inet static
  address 192.168.0.2
  netmask 255.255.255.0

But when I try to start the network I get the following error:

alix:~# ifconfig eth1 down
alix:~# ifup -v eth1
Configuring interface eth1=eth1 (inet)
run-parts --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/hostapd
ip addr add 192.168.0.2/255.255.255.0 broadcast 192.168.0.255     dev eth1 label eth1
RTNETLINK answers: File exists
Failed to bring up eth1.

When I run the ip command manually I get the same error:

alix:~# ip addr add 192.168.0.2/255.255.255.0 broadcast 192.168.0.255     dev eth1 label eth1
RTNETLINK answers: File exists

What is wrong with the command? And how can I tell Debian to do the right thing?

ceving
  • 3,461
  • 5
  • 21
  • 30

3 Answers3

102

I got it that I had to flush the device before bringing it up:

# ip addr flush dev eth1

Clearing manually set interface configuration information like this is mentioned in the Ubuntu Server Guide.

αғsнιη
  • 40,939
  • 15
  • 71
  • 114
ceving
  • 3,461
  • 5
  • 21
  • 30
  • I still receive a (slightly different) error `RTNETLINK answers: No such process Failed to bring up eth1` BUT my Eth1 is correctly assigned now AND is UP/UP. – harperville Sep 10 '15 at 14:11
  • yeah, same problem here: `RTNETLINK answers: No such process Failed to bring up eth1` – Drew Feb 21 '17 at 05:50
  • 14
    Even if your answers solves the problem. It would be great if you could tell what it actually does. What is this RTNETLINK file that exists? – humanityANDpeace May 17 '17 at 07:19
  • @ceving: please can you explain twhat is `RTNETLINK answers file`? Also, after flushing, my network card is not taking a new ip automatically, how to ask dhcp a new ip? – realtebo Aug 14 '18 at 07:58
  • 1
    @realtebo @humanityANDpeace Inspect the kernel manual about [netlink](http://man7.org/linux/man-pages/man7/netlink.7.html) and [rtnetlink](http://man7.org/linux/man-pages/man7/rtnetlink.7.html). But I doubt you really want to know. This is an error message the `ip` tool gets from the kernel. And instead of translating the message into something useful for end users, `ip` passes it just through. But if you really want to know the internals, use the `Ask Question` instead of the `Add Comment` button. – ceving Aug 14 '18 at 08:43
  • 3
    One caveat is that this clears all scopes, which is not always what you want. (I found that out the hard way) – Semimono Oct 05 '18 at 19:17
  • "ifconfig eth1 down" does not dissociate IP address from interface. It just brings interface down. In pre "ip" times I was using "ifconfig eth1 0.0.0.0" to remove address. This may be useful to those who work on old systems. – Mariusz Zieliński Dec 27 '21 at 17:34
15

Using ip addr flush will work, but it will also clear any and all addresses set on that interface - possibly including the one that you are using, if you're logged in to a remote machine. This may lock you out of your device.

RNETLINK answers: File exists happens when you're trying to add a rule that conflicts with an existing rule. I would guess that OP was encountering this because they had already set the address with ifconfig. This error can usually be resolved by converting the add command to a similarly structured change or replace command.

It's much safer to use ip addr change or ip addr replace instead.

alerone
  • 151
  • 1
  • 4
  • 1
    This is no option for someone using just `ifup` and `ifdown`, because the command is hard wired in those scripts. – ceving Jul 31 '20 at 14:14
  • @alerone using "sudo ip addr change" will throw me this output. "Not enough information: "dev" argument is required." I/We need more info to use ur idea. It would be nice. – Pranav Oct 28 '20 at 06:17
  • This answer explained my issue, I had conflicting routes in my /etc/network/interfaces – kasi Apr 29 '21 at 12:18
  • @Pranav You must complete the command with the required parameters. For example `sudo ip addr change 192.168.0.10 dev eth0`. In your case the missing parameter seems to be the name of network interface (the device). Also, you can read the online help with this command `ip addr help`. – Daishi Oct 13 '22 at 21:59
-2

I had a similar problem that by the time I had played the 10,000 moneys scene was exactly this, and I had been trying to add the missing stuff to /e/n/i.d/etho

But studying the man page for interfaces, I noted that ALL of the set of examples had only 2 lines of real data, the ipv4 address/24, and a gateway line specifying the address of my router. So I stripped my eth0 file down to that, and rebooted, and worked perfectly.

Gene
  • 1