0

I installed a LEMP web server on top of a Debian Buster template given by my server provider OVH.

The server has connectivity problem : from time to time the ping is lost, then it needs a hard reboot from OVH technicians.

I reinstalled the OS template three times from scratch. I ran processors and memory tests which resulted OK. I ran file system check. OVH support is overbooked and not reachable, due to the huge fire that destroyed a datacenter last week..., so that I can't grab any information from there.

Then I realized that systemd-networkd.service and networking.service are alternatively actives at reboot. Below are some sample output of the machine.

Before hard reboot yesterday, while still connected in ssh:

   root@srv:~# systemctl | grep network
      cloud-init-local.service  loaded active exited    Initial cloud-init job (pre-networking)                                      
    ● networking.service        loaded failed failed    Raise network interfaces                                                     
      network-online.target     loaded active active    Network is Online                                                            
      network-pre.target        loaded active active    Network (Pre)                                                                
      network.target            loaded active active    Network

root@srv:~# systemctl status networking.service 
    ● networking.service - Raise network interfaces
       Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Mon 2021-03-15 10:32:32 CET; 2h 24min ago
         Docs: man:interfaces(5)
      Process: 710 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
     Main PID: 710 (code=exited, status=1/FAILURE)
    
    Mar 15 10:32:31 srv dhclient[747]: DHCPREQUEST for 111.222.333.213 on enp3s0f0 to 255.255.255.255 port 67
    Mar 15 10:32:31 srv dhclient[747]: DHCPACK of 111.222.333.213 from 111.222.333.253
    Mar 15 10:32:32 srv ifup[710]: /etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf
    Mar 15 10:32:32 srv dhclient[747]: bound to 111.222.333.213 -- renewal in 40762 seconds.
    Mar 15 10:32:32 srv ifup[710]: bound to 111.222.333.213 -- renewal in 40762 seconds.
    Mar 15 10:32:32 srv ifup[710]: RTNETLINK answers: File exists
    Mar 15 10:32:32 srv ifup[710]: ifup: failed to bring up enp3s0f0
    Mar 15 10:32:32 srv systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
    Mar 15 10:32:32 srv systemd[1]: networking.service: Failed with result 'exit-code'.
    Mar 15 10:32:32 srv systemd[1]: Failed to start Raise network interfaces.

After hard reboot yesterday :

root@srv:/etc/systemd/network# systemctl | grep network
cloud-init-local.service                                                                                         loaded active exited    Initial cloud-init job (pre-networking)                                      
networking.service                                                                                               loaded active exited    Raise network interfaces                                                     
network-online.target                                                                                            loaded active active    Network is Online                                                            
network-pre.target                                                                                               loaded active active    Network (Pre)                                                                
network.target                                                                                                   loaded active active    Network


root@srv:/etc/systemd/network# systemctl status networking.service 
● networking.service - Raise network interfaces
   Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
   Active: active (exited) since Tue 2021-03-16 13:53:25 CET; 1 day 1h ago
     Docs: man:interfaces(5)
 Main PID: 714 (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   Memory: 14.3M
   CGroup: /system.slice/networking.service
           └─751 /sbin/dhclient -4 -v -i -pf /run/dhclient.enp3s0f0.pid -lf /var/lib/dhcp/dhclient.enp3s0f0.leases -I -df /var/lib/dhcp/dhclient6.enp3s0f0.leases enp3s0f0

root@srv:/etc/systemd/network# systemctl status systemd-networkd
● systemd-networkd.service - Network Service
   Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd-networkd.service(8)

Network configuration

root@srv:~# ls /etc/network/
if-down.d  if-post-down.d  if-pre-up.d  if-up.d  interfaces  interfaces.d

root@srv:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

# The normal eth0
allow-hotplug eth0
iface eth0 inet dhcp

# Additional interfaces, just in case we're using multiple networks
allow-hotplug eth1
iface eth1 inet dhcp

allow-hotplug eth2
iface eth2 inet dhcp

# Set this one last, so that cloud-init or user can defaults.
source /etc/network/interfaces.d/*

root@srv:~# ls /etc/network/interfaces.d/
50-cloud-init

root@srv:~# cat /etc/network/interfaces.d/50-cloud-init      
# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
auto lo
iface lo inet loopback

auto enp3s0f0
iface enp3s0f0 inet dhcp
    accept_ra 0

# control-alias enp3s0f0
iface enp3s0f0 inet6 static
    address 2001:abcd:1007:efgh::/56
    dns-nameservers 2001:abcd:3:163::1
    gateway 2001:abcd:1007:1dff:ff:ff:ff:ff
    post-up route add -A inet6 2001:abcd:1007:ef00::/57 gw 2001:abcd:1007:1dff:ff:ff:ff:ff || true
    pre-down route del -A inet6 2001:abcd:1007:ef00::/57 gw 2001:abcd:1007:1dff:ff:ff:ff:ff || true

[... plus about fifty similar lines ...]

root@srv:~# ls /etc/systemd/network

root@srv:~# ls /lib/systemd/network
80-container-host0.network  80-container-ve.network  80-container-vz.network  99-default.link

Question

  1. May something in that config be responsible of reccurent lost connectivity ?

  2. How do I make sure to reboot always with the same service, either systemd.networkd or networking ?

  3. Where do I add my static IPs in that jungle ?

I may add the following to a file in /etc/systemd/network/ (empty at the moment), but that would imply trying to start systemd.networkd and stop the other, not sure if I can do this from remote ssh..., neither if the service is properly setup !

nano /etc/systemd/network/50-default.network

[Address]
Address=FAILOVER_IP/32
Label=failover1 # optional

Or better add something like that into /etc/network/interfaces and restart networking.service ?

auto eth0:0
iface eth0:0 inet static
address STATIC_IP
netmask 255.255.255.255

auto eth0:1
iface eth0:1 inet static
address OTHER_STATIC_IP
netmask 255.255.255.255

Thanks a lot !

Side note, all the network configuration was provided by OVH in its template, and unfortunately my knowledge in that topic is very limited. Moreover the network config changes between successive versions of Debian make it even harder to learn IMHO.

1

In your /etc/network/interfaces keep only:

#source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback

See 5.3. The modern network configuration without GUI to configure a static or DHCP network configuration. E,g:

/etc/systemd/network/10-dhcp-enp3s0f0.network:

[Match]
Name=enp3s0f0

[Network]
DHCP=yes

/etc/systemd/network/10-static-eth0-0.network:

[Match]
Name=eth0:0

[Network]
Address=STATIC_IP
Gateway=gatway_here
DNS=dns_here

You have a warning:

    Mar 15 10:32:32 srv ifup[710]: /etc/resolvconf/update.d/libc: Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf

it can be solved by:

ln -s  /etc/resolvconf/run/resolv.conf /etc/resolv.conf

Archlinux wki: systemd-networkd

Debian wiki: systemd-networkd

5
  • Thanks a lot. Could you please elaborate ? 1. What about call to 50-cloud-init in interfaces ? This is where my WAN interface is currently set AFAIK. 2. Which service will apply your config if systemd-networkd is loaded but dead ? I can't figure out the whole picture, between systemd.networkd and networking ? Worth mentioning that since last reboot 2 days ago now with networking active / systemd.networkd inactive, I didn't lose connectivity (yet !). So I'm a bit frightened to reverse that...
    – Kojo
    Mar 18 at 11:44
  • 3. Last, in linked example with Buster, interfaces has a very close config to mine, and the author simply adds iface ens33 inet static address 10.1.1.1/8 in its interfaces and restart networking.service. Isn't it correct also ? Once again sorry the point I'm missing is systemd.networkd vs networking... and if interfaces file is still useful with the former ?
    – Kojo
    Mar 18 at 11:44
  • @Kojo the 50-cloud-init has no effect because source-directory /etc/network/interfaces.d is removed (I have added it commented). See my update.
    – GAD3R
    Mar 18 at 18:30
  • yep I had understood that you want to remove the include form interfaces, what I meant is will your 10-dhcp-enp3s0f0.network file have the same result as 50-cloud-init ? Tks for the symlink comment, I fixed it, but the other way ... I moved ̀/etc/resolv.conf` to /etc/resolv.conf.bak and ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf So far I could restart networking.service and the warning has gone. In synthesis what confuses me is the concurrence of 2 services, networking.service (loaded and active now) and the new systemd-networkd.service (loaded but dead). Sorry if I'm dumb!
    – Kojo
    Mar 18 at 18:58
  • @Kojo By default the systemd-networkd.service is disabled, you need to configure it then make it runing. Try to restart it then check its status.
    – GAD3R
    Mar 18 at 19:08
1

I marked @GAD3R answer as accepted because it seems to be the modern way to handle this.

However, eventually I stuck to the old setup and simply added a enp3s0f0 file to /etc/network/interfaces.d with the following config for my static IPs :

auto enp3s0f0:1
iface enp3s0f0:1 inet static
address aaa.bb.cc.232/29

auto enp3s0f0:2
iface enp3s0f0:2 inet static
address aaa.bb.cc.233/29

auto enp3s0f0:3
iface enp3s0f0:3 inet static
address aaa.bb.cc.234/29

[...]

Then restarted networking.service.

Last, not sure if fixing the missing symlink ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf was enough, but I rebooted days ago and yet I don't experiment anymore issues with network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.