Score:0

Can't correctly bring up a second network interface on Debian 11

cn flag

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 !

A.B avatar
cl flag
A.B
You're attempting to use two default routes by using twice `gateway` => something will fail. Can you describe more thoroughly your network topology?
inframan avatar
cn flag
Hi, yeah that's what i figure out on friday while reading this article https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System - at the moment i have 2 network interface configured with DHCP, then once my customization is done, i have to change those interfaces to a different subnet (so 2 interfaces on the same subnet, but we dont want to use alias/bond, so that's why we got 2 different interfaces)
Score:0
cn flag

EDIT

I figured out that Debian can have only one default gateway, if you need more you have to configure routes. https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.