1

I'm currently coding a network configuration role used by Ansible to customize our fresh new virtual machine that came from our Debian 11 template.

I got a weird issue while I try to set up and configure 2 physical network interfaces. When i deploy a new VM from my template, it has 2 separate vmnics, from a debian perspective it means it has only ens3 and ens4 (i don't use any bond or subinterfaces at all).

Here's the simple interfaces configuration file I setup:

# 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

auto ens3 iface ens3 inet static address 10.0.0.1/24 gateway 10.0.0.254 dns-nameservers 10.230.100.1 dns-search mydomain.net

auto ens4 iface ens4 inet static address 192.168.0.1/24 gateway 192.168.0.254 dns-nameservers 10.230.100.1 dns-search mydomain.net

Then, when i restart networking.service through systemctl or better, when i reboot the machine, configuration is well set from ip a perspective but it has issues from journalctl perspective :

févr. 16 14:04:53 MY-HOST systemd[1]: Starting Raise network interfaces...
févr. 16 14:04:53 MY-HOST  ifup[1100]: RTNETLINK answers: File exists
févr. 16 14:04:53 MY-HOST  ifup[1078]: ifup: failed to bring up ens4
févr. 16 14:04:53 MY-HOST  systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
févr. 16 14:04:53 MY-HOST  systemd[1]: networking.service: Failed with result 'exit-code'.
févr. 16 14:04:53 MY-HOST  systemd[1]: Failed to start Raise network interfaces.

Once i reboot the server, I still have a lot of these issues but configuration seems well set up

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 50:6b:8d:d0:c0:3d brd ff:ff:ff:ff:ff:ff
    altname enp0s3
    inet 10.0.0.1/24 brd 10.0.0.255 scope global dynamic ens3
       valid_lft 2147483506sec preferred_lft 2147483506sec
3: ens4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 50:6b:8d:8a:24:94 brd ff:ff:ff:ff:ff:ff
    altname enp0s4
    inet 192.168.0.1/24 brd 192.168.0.255 scope global dynamic ens4

Moreover, if i manually sudo ifdown ens4 then sudo ifup ens4 i got the following error :

ifdown: interface ens4 not configured
RTNETLINK answers: File exists
ifup: failed to bring up ens4

I figure out that if I comment out auto ens4 in my interfaces file, i do not have any error but when i reboot, ens4 isn't up so that's not a solution for me...

My question is : How can i fix it ? do i miss something in my interfaces configuration ? or is there a mistake i didn't see ?

Thanks a lot !

motorbass
  • 167

2 Answers2

1

Can you try this:

auto ens3
allow-hotplug ens3
iface ens3 inet static
  address 10.0.0.1/24

auto ens4 allow-hotplug ens4 iface ens4 inet static address 192.168.0.1/24

Restart or reboot than try to ping 10.0.0.1 and 192.168.0.1

If that work's config your dns, nameserver, gateway etc..

Check this post and edit /etc/resolve.conf for nameserver

Debian 11 dhcp assigning ip to more than one interface

network devices/interfaces informations

Check the Debian NetworkConfiguration:

Debian NetworkConfiguration

CHECK THIS TOO:

Adding two default gateways in Debian interfaces file

Maybe this post can help:

how to configure 2 network interfaces with different gateways

Z0OM
  • 3,149
  • After rebooting, ping works. After adding gateway then restart the service/reboot the server i got the same error as i had in my original post. The same when i add dns, nameserver parameters too.. (i tried to add one by one, and reboot between every change i made) – motorbass Feb 16 '23 at 16:44
  • Yes it's class A, so as it include all subnets between 10.0.0.0 to 10.255.255.255 and following our subnets management i can properly use 10.0.0.1 /24 if needed ;) for example if i use a 10.200.5.X /24 i got the same error. And yes i can ping the gateway, what's weird to me is that configuration seems ok (i mean "ip a" shows the proper configuration I set) but networking.service shows a lot of red while restarting the service or rebooting the server.. – motorbass Feb 16 '23 at 16:59
  • Nope, it seems that if i only have iface and address parameter it's ok, from the moment i set another parameter (gateway/dns..) it fails for the second interface. in any cases configuration is still ok but networking.service goes red in logs – motorbass Feb 16 '23 at 17:05
1

Finally found the real explanation here :

By default, you can only have one default gateway on a system.

After testing i can confirm one gateway is ok, 2 are not. But in any case, it seems that the following route are default created once network configuration is setup :

enter image description here

So in my case, i probably don't need to create default route as explained.

motorbass
  • 167