19

I recently installed Debian 12.7 on a fresh storage, this is a headless server with no desktop environment.

I checked the NetworkConfiguration documentation of Debian and I saw this:

4 ways to configure the network

  • The interfaces configuration file at /etc/network/interfaces (this page): for basic or simple configurations (e.g. workstation)
  • NetworkManager: This is the default for Laptop configuration
  • Systemd: Debian reference Doc Chapter 5
  • Netplan: Debian reference Doc Chapter 5

And now I'm confused because I don't understand what part apply to my installation.

The system uses the default configuration so the answer may be straightforward, but let's assume that I connect to a machine that I don't know and I want to identify the network configuration.

How to identify the way that a Debian (or another Linux distro) system use to configure its network stack?

My attempts

/etc/network/interfaces

The file exists:

root@serveur:~# cat /etc/network/interfaces
# 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
allow-hotplug enp2s0
iface enp2s0 inet dhcp
# This is an autoconfigured IPv6 interface
iface enp2s0 inet6 auto

NetworkManager

The service doesn't exist:

root@serveur:~# service network-manager status
Unit network-manager.service could not be found.

Update: as shown in this answer from Z0OM, it should be service NetworkManager status instead, but the result is the same.

Systemd

One file exists but its content is commented:

root@serveur:~# ls -lrth /etc/systemd/network/
total 0

root@serveur:~# cat /etc/systemd/networkd.conf 
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the networkd.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# See networkd.conf(5) for details.

[Network]
#SpeedMeter=no
#SpeedMeterIntervalSec=10sec
#ManageForeignRoutingPolicyRules=yes
#ManageForeignRoutes=yes
#RouteTable=

[DHCPv4]
#DUIDType=vendor
#DUIDRawData=

[DHCPv6]
#DUIDType=vendor
#DUIDRawData=

Netplan

There is no conf:

root@serveur:~# ls -lrth /etc/netplan/
ls: cannot access '/etc/netplan/': No such file or directory

Observations

This system uses /etc/network/interfaces and Systemd to configure the networking?

3
  • 1
    NetworkManager is called that, case sensitive. Commented Oct 23, 2024 at 22:30
  • Also: It's very possible you have both. For example since NetworkManager is great at Wi-Fi and systemd-networkd is good at static stuff like DHCP Ethernet config (pretty much all the same), they can run at the same time and just need to be told not to manage each-other's interfaces. It does mean they know about the interfaces they don't manage, e.g. loopbacks often in the trivial case. Commented Oct 23, 2024 at 22:42
  • 1
    Yup, and vice versa they both have things they are not good at: NetworkManager is a bit trigger-happy about flushing the entire configuration and starting from scratch, and difficult to configure without GUI, while systemd-networkd is bad at handling dynamic configuration with weird VPN setups, and is missing GUI configuration for weird VPN setups. ifupdown (/etc/network/interfaces) mostly was first, and is still sufficient for a lot of servers -- if the IP address never changes, it is a bit silly to run a service for that. Commented Oct 24, 2024 at 2:51

4 Answers 4

11

It depends on what you choose during the installation / packages / environment / standard.

Personally, I always leave the network unconfigured during installation, whether it's a client, server, desktop/tower, or laptop, and I configure everything in /etc/network/interfaces.

/etc/network/interfaces and networking.service

This file is used for configuring network interfaces in Debian and other systems

Check /etc/network/interfaces for basic configurations.

For @Bob comment and Answer:

/etc/network/interfaces is actually managed/read by ifupdown which is invoked by networking.service in a modern install. So that's the better way to check if it's enabled/in-use, as it's possible to have stray /etc/network/interfaces files left over even if the system has been configured to use a different method.

Check the status of networking.service with:

systemctl status networking.service

Check if is enable:

systemctl is-enabled networking.service

NetworkManager

If your system uses NetworkManager, it manages the connections over its own tools.

Check if NetworkManager is running systemctl status NetworkManager

systemd-networkd

If the system is using systemd-networkd, configuration will be located in /etc/systemd/network/ check for the status

Check for systemd-networkd configuration

Current state of the network interfaces managed by systemd-networkd:

networkctl
networkctl status
networkctl status --all

Status of the systemd-networkd service with:

  • Active or inactive
  • Logs and error messages
  • Additional status information
systemctl status systemd-networkd

Netplan

Netplan is often used on systems that are configured for cloud environments

From @Jörg W Mittag comment:

Also note that Netplan is a frontend which allows you to describe the desired network configuration in an abstract manner. It does not configure network devices itself. It renders a concrete configuration for either or both of NetworkManager and systemd-networkd

Check for Netplan configurations in /etc/netplan/

About Netplan

Network configuration on Ubuntu is handled through Netplan, which provides a high-level, distribution-agnostic way to define how the network on your system should be set up via a YAML configuration file.

It does not directly configure network devices, it generates specific configurations for backends like NetworkManager and systemd-networkd based on the defined settings in YAML files. This allows users to define their desired network configuration in a more user-friendly manner, which is then translated into the appropriate configuration for the underlying networking system

Your system uses /etc/network/interfaces and networking.service for network, and systemd doesn’t seem to be managing the network.

NetworkManager and Netplan are not in use.

Sea also

5
  • 4
    /etc/network/interfaces is actually managed/read by ifupdown which is invoked by networking.service in a modern install. So that's the better way to check if it's enabled / in use, as it's possible to have stray /etc/network/interfaces files left over even if the system has been configured to use a different method. Commented Oct 24, 2024 at 10:14
  • @Bob do you mean "systemctl status networking.service" ? Commented Oct 24, 2024 at 10:44
  • Sure. That would let you know when it last ran too. Commented Oct 24, 2024 at 10:51
  • @Bob I changed it because I thought it would be clear for the OP, sorry for my mistake Commented Oct 24, 2024 at 11:03
  • 1
    Also note that Netplan is a frontend which allows you to describe the desired network configuration in an abstract manner. It does not configure network devices itself. It renders a concrete configuration for either or both of NetworkManager and systemd-networkd. Commented Oct 24, 2024 at 14:24
4

If the command line tools were installed you could try the control app for each of them.

For Network Manager it would be:

nmcli general status

For systemd-networkd it would be:

networkctl status

For Netplan it would be:

netplan status
2

As an addendum to Z0OM's answer, note that the simple existence of /etc/network/interfaces does not necessarily mean anything. Rather, you want to check for the existence of the ifupdown package, or the networking.service systemd service that invokes ifup in a standard install.

Otherwise, it's possible that ifupdown has been removed or disabled but the config files still exist.

0
0

I discovered this question while searching for something else, but had just developed a solution for my own use in Debian. I think it answers the OP's question:

How to identify the way that a Debian (or another Linux distro) system use to configure its network stack?

This is a rather simple-minded answer I think. It assumes that the software being used to manage the network runs as a service under systemd, and so amounts to listing all systemd units, and applying grep filters:

$ string1=$(systemctl list-units --all | grep -Ei 'networking\.|NetworkManager\.|networkd\.' | grep 'service' | grep -E 'running')  
$ string2=$(systemctl list-units --all | grep -Ei 'networking\.|NetworkManager\.|networkd\.' | grep 'service' | grep -Ev 'dead')  
$ if [ -n "$string1" ]; then echo ${string1::24}; else echo ${string2::20}; fi 

As it turns out - for the versions of Debian 'bookworm' that I use at least, there are only 3 network services to choose from :

Note that Netplan isn't installed in my default installation, but could probably be accommodated under this scheme.

  • NetworkManager.service
  • systemd-networkd.service
  • networking.service

If you list those services, you see the following as the default setup (using NetworkManager) :

$ systemctl list-units --all | grep -Ei 'networking\.|NetworkManager\.|networkd\.' | grep 'service'  

  networking.service                     loaded    active   exited    Raise network interfaces
  NetworkManager.service                 loaded    active   running   Network Manager
  systemd-networkd.service               loaded    inactive dead      Network Configuration

However, if you disable & mask NetworkManager in favor of ifupdown/networking.service, you will see the following. Note that the networking.service status does not change. :

$ systemctl list-units --all | grep -Ei 'networking\.|NetworkManager\.|networkd\.' | grep 'service' 

  networking.service                     loaded    active   exited    Raise network interfaces
  NetworkManager.service                 masked    inactive dead      NetworkManager.service
  systemd-networkd.service               loaded    inactive dead      Network Configuration

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.