0

I'm trying to add one main IP, two extra IP and one IP6. Here is my interfaces file located at /etc/network/interfaces:

source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
allow-hotplug ens192
iface ens192 inet static
        address 23.227.198.250/26
        gateway 23.227.198.194
        dns-nameservers 8.8.8.8
        dns-search deb12.domain.com
auto ens192:0
iface ens192:0 inet static
        address 23.227.198.253
        gateway 23.227.198.194
auto ens192:1
iface ens192:1 inet static
        address 23.227.198.254
        gateway 23.227.198.194
iface ens192 inet6 static
        address 2a02:748:4000:6::0199/64
        gateway 2a02:748:4000:6::1

Then I restart networking using the command below: output of the command systemctl restart networking:

Job for networking.service failed because the control process exited with error code.
See "systemctl status networking.service" and "journalctl -xeu networking.service" for details.

Then journalctl -x says:

Subject: A start job for unit networking.service has begun execution
Defined-By: systemd
Support: https://www.debian.org/support
A start job for unit networking.service has begun execution.
The job identifier is 412.
ifup[2057]: RTNETLINK answers: File exists
ifup[2048]: ifup: failed to bring up ens192:1
systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Subject: Unit process exited
Defined-By: systemd
Support: https://www.debian.org/support
An ExecStart= process belonging to unit networking.service has exited.
The process' exit code is 'exited' and its exit status is 1.
systemd[1]: networking.service: Failed with result 'exit-code'.
Subject: Unit failed
Defined-By: systemd
Support: https://www.debian.org/support
The unit networking.service has entered the 'failed' state with result 'exit-code'.
systemd[1]: Failed to start networking.service - Raise network interfaces.
Subject: A start job for unit networking.service has failed
Defined-By: systemd
A start job for unit networking.service has finished with a failure.
The job identifier is 412 and the job result is failed.

the output of systemctl status networking:

 networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-11-20 04:53:15 EST; 3min 15s ago
       Docs: man:interfaces(5)
    Process: 2048 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
    Process: 2074 ExecStopPost=/usr/bin/touch /run/network/restart-hotplug (code=exited, status=0/SUCCESS)
   Main PID: 2048 (code=exited, status=1/FAILURE)
        CPU: 18ms
systemd[1]: Starting networking.service - Raise network interfaces...
fup[2057]: RTNETLINK answers: File exists
ifup[2048]: ifup: failed to bring up ens192:1
systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: networking.service: Failed with result 'exit-code'.
ystemd[1]: Failed to start networking.service - Raise network interfaces.

I could not find any solution for this issue on web. It means a lot to me if you could help me to resolve this issue.

I've tried rewriting the network file and checked if I have any typo in it. Also, vim does not highlight the comments in the file (I've deleted the comments while posting here), So I'm thinking that maybe the OS does not recognize this file as it should be. I also checked the chmod and chown of this file and everything is fine.

Something strange has happened, even though I receive the error (mentioned above), I can ping all IPs (V4 and V6) from my local network. Also, I can ping google IPv4 and IPv6 from this server.

2
  • Do you mean that I can ignore the error message? Commented Nov 28, 2023 at 12:12
  • Made an answer. Commented Nov 28, 2023 at 12:33

1 Answer 1

1

There is only one default gateway: the default gateway used in the default route, which is what gateway controls. The second time the network configuration tools attempt to add a default route with the same metric etc. this triggers an RTNETLINK answers: File exists error.

Just keep the first instance of:

        gateway 23.227.198.194

and delete the two duplicates.

Note: better bring down the interface (using ifdown ens192) before doing changes to the configuration to avoid a desynchronization between the ifupdown tool's state and the actual network state. Of course one should keep a way to access the system if it's a remote access (or else reboot).


Information below is not needed to solve the problem, it's just a remark telling that ens192:0 and ens192:1 could and should be completely avoided, but this remark can be ignored.

There's no reason to use so-called alias interfaces (they are not interfaces, they are labels attached to the additional addresses). Today ifupdown uses iproute2: ip link, ip addr internally and not ifconfig, the only known remaining "customer" of these fake interfaces handled through the older API (netdevice(7)): ifconfig is obsolete on Linux and should not be used anymore by tools or humans. It should be replaced with ip link and ip addr which use the newer kernel API (rtnetlink(7)). For example to display an IPv4 address with such compatibility label (and not the other addresses on the same interface) one can use for example:

ip -details addr show dev ens192 label ens192:0

But of course, just doing:

ip addr show dev ens192

will display all 3 addresses on the interface.

You can remove the :0 and :1 everywhere in the configuration and leave only ens192. ifupdown will just add the addresses as usual (and without a label, so making them not displayed with ifconfig anymore). Beside, that would be the only method for IPv6 (though the extra :x would be ignored) since so-called alias interfaces on Linux are a workaround for IPv4 and not for IPv6 which never required them (ifconfig for IPv6 uses a different syntax with add and del instead).

1
  • I was searching on the web for about a week and your solution acted like a silver bullet. This is really amazing. IT WORKED!!!!! I fixed the error, and it works like a charm, let's call it abracadabra. I madly recommend this solution for all who have the same issue. I greatly appreciate your precious your help. @A.B Commented Nov 29, 2023 at 9:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.