Updated on Febuary 5, 2023
The Raspberry Pi OS is a Linux distribution based off of the Debian distribution. Linux has several DHCP clients. The Raspberry Pi OS has used three different DHCP clients, as their default for configuring network interfaces (Table 2). In addition, since Sept 2015, there is another DHCP client that is in every image of the Raspberry Pi OS. Each DHCP client places their network interface configuration file in a diffient directory, and the rules and syntaxes are different for each of them.
DHCP Clients | Interface Configuration File(s) | RPi Date |
---|---|---|
NetworkManager | /etc/NetworkManger/system-connections/ | Sept 2022 to Present |
dhcpcd (dhcp client daemon) | /etc/hdcpd.conf | May 2015 to Present |
dhclient (isc-hpcd-client) | /etc/network/interfaces | Pre-May 2015 |
Systemd-Networkd | /etc/systemd/network/ | Not a Default |
wpa_supplicant* | /etc/wpa_supplicant/wpa_supplicant.conf |
The original purpose of the Raspberry Pi, and still the RPi Foundation, is to teach coding to children. Many of the people using the Raspberry Pi are learning Linux. This is mass confusion for them! They can search on the Internet for how to set up a static IP address or how to use a Raspberry Pi as an Access Point, and see four different methods for configuring a network interface. On the latest image of the Raspberry Pi OS all four DHCP clients are present.
The purpose of this article to bring some clarity to the confusion of configuring a network interface and to help you decide which method is best for you.
However, before that can be accomplished, there are some basics that need to be covered.
On a home network, the Router is DHCP server. However, if you want to use the Raspberry Pi OS as an Access Point, it must have a DHCP server. You can install your own [43], or use the built-in DHCP server, dnsmasq [15].
In addition to access the Internet, a Domain Name Server (DNS) must be specified.
The Raspberry Pi OS added support for the NetworkManger on Sept 7, 2022, and they announced that at some point in time, it would become the default [1].
The NetworkManager was introduced by RedHat (now IBM) in 2004 [2]. It is now updated and maintained by the Gnone organization [39, 40].
It appears that the NetworkManger is becoming the de facto standard for most Linux distributions [1]. It is Debian's default package for managing network interfaces for laptops [4]. Some non-Debian Linux distributions are using it for servers.
NetworkManager's behavior can be modify by its configuration file "/etc/NetworkManager/NetworkManger.conf". Debian's NetworkManager.conf file is set so that it will not manage any interfaces that are declared in "/etc/network/interfaces" or the directory "/etc/network/interfaces.d".
NetworkManager's interface configuration files are in the directory: "/etc/NetworkManager/system-connections/".
NetworkManager will automatically start other services as it requires them (wpa_supplicant for WPA and 802.1x connections, pppd for mobile broadband) [37].
This is still Raspberry Pi's default method of managing network interfaces.
In the last update to Raspbian Whezzy (May 2015), the default DHCP client was switched from the Internet System Consortium's DHCP Client (dhclient) to Roy Marples' DHCP Client Daemon (dhcpcd) [53, 22].
Although dhcpcd is in Debian's repository, it has never used as a default by Debian to configure network interfaces. There is nothing in Debian's guides or documentation about dhcpcd except for a man page. However, dhcpcd is very popular, and it has been used as the default in several Linux distributions based off of Debian.
Network interface parameters are placed in the file "/etc/dhcpcd.conf".
The behavior of dhcpcd can be modified by entries in the same configuration file (dhcpcd.conf) [52, 22]. By default, dhcpcd manages every interface it finds. To exclude both eth0 and wlan0, add the following to dhcpcd.conf:
denyinterfaces eth0 wlan0
If you do not have a denyinterfaces list in dhcpcd.conf and there is another DHCP client on your system, you can end up with more than one IP address for the same interface.
You can avoid conflicting with the previous method, by not having any any network interface entries in /etc/network/interfaces or "/etc/network/interfaces.d". If there are entries in /etc/network/interfaces, you will get a second IP address for these entries.
For wireless network interfaces, dhcpcd uses the helper configuration file: "/etc/wpa_supplicant/wpa_supplicant.conf".
The previous method can optionally use the same "/etc/wpa_supplicant/wpa_supplicant.conf" file.
Do not confuse dhcpcd with dhcpd, which is ISC's DHCP server daemon.
Examples:
Raspian Wheeze used the Internet System Consortium (ISC) DHCP client, dhclient. It is in the package isc-dhcp-client. This client first appeared in 1999 [45]. It has a 23-year history. ISC stopped maintaining this client in Q1 2022 [46]. However, it is in every version of the Raspberry Pi OS. It is in Debian 11 (Bullseye), and it is actively being used for servers and simple workstations [7].
Its behavior can be modified by the configuration file: etc/DHCP/hdclent.conf.
Interface configuration parameters are placed in the file: "/etc/network/interfaces" or files in the directory, "/etc/network/interfaes.d".
Raspberry Pi Buster will not process files in "/etc/network/interaces.d" with a dot in the file name. Hence, do not use filename.conf or other extensions [add reference]. Raspberry Pi Bullseye will process files names with a dot in them. (Recheck this).
Wireless network configuration parameters are usually placed in the helper file "/etc/wpa_supplicant/wpa_supplicant.conf".
However, it is possible to put all the wireless network parameters in "/etc/network/interfaces" and not use the supplicant [25].
Raspberry Pi OS Buster has only /etc/network/interfaces file.
It has only one active line:
source /etc/network/interfaces.d
Raspberry Pi OS Bullseye has two files: /etc/network/interfaces and "/etc/network/interfaces.new". The comments in the later file (.new) say that this file is to be used with dhcpcd. What does this mean?
It has only one active line:
source-directory /etc/network/interfaces.d
The "source-directory' specification requires that file names in
the directory consist of:
A-Z, a-z, numbers, underscores, and minus sign. It will not process
a file names with a "." such as eth0.conf [man interfaces].
Examples:
Debian's NetworkManager will not manage any interfaces that are declared in /etc/network/interfaces or in the directory "/etc/network/interfaces.d". Hence, you should be able to manage some interfaces with the NetworkManager and others in /etc/network/interfaces.
However, the Raspberry Pi's implementation is not currently working, as I believe it should:
1. You can use the NetworkManager to configure eth0 and /etc/network/interfaces to configure wlan0, but all of the Wi-Fi configuration has to be in /etc/network/interfaces. The NetworkManger is blocking the wpa_supplicant.conf file.
2. If you try to use the NetworkManger to configure wlan0 and /etc/network/interfaces to configure eth0, without the eth0 cable plugged in, wlan0 will not work.
Since Debian 8 (jessie) and Raspbian jessie (9/20/2015), systemd has been the default service manager [32]. Since that time, Systemd-Networkd can be used to manage the network interfaces [9,33,34]. You create configuration files for the interfaces and place them in the directory: "/etc/systemd/network/" ([7] Section 5.3).
At the present, setting up wireless networks with Systemd-Networkd is more difficult than the other methods [add reference].
Systemd-Networkd has never been the default method of the Raspberry Pi OS to manage network interfaces. However, it appears to be the current preferred method by Debian for managing modern network interfaces without a GUI (see Section 5.3 in [7]). It is definitely a viable option. You can find articles on the Internet with Systemd-Networkd managing interfaces on the Raspberry Pi [add references].
The Raspberry Pi only has one ethernet interface, and one wireless interface. Their default names are eth0 and wlan0.
However, interfaces can be added via the USB ports. If you add another ethernet port, eth1, after you reboot, the second ethernet port may become eth0 and vice versa. To solve this problem, Linux added support for Predictable Network Interface Names [13,14]. This might should have been called consistent interface names since it is not that easy to interpret the names.In Debian Stretch, new systems by default no longer used old-style interface names such as eth0 and wlan0. Debian Stretch and Buster still retain support for the old-style names, but users are advised to upgrade before Bullseye [4].
Add reference and when this became available for the RPi.
The Internet Systems Consortium (ISC) DHCP-Server has reached the End of its Life [45]. However, ISC now has a new DHCP server: Kea-DHCP. ISC is no longer maintaining their DHCP client, isc-dhcp-client (dhclient). They have decided not to purse an DHCP client or relay [46].
Due to his ill health, Roy Marples, is no longer maintaining his DHCP client, dhcpcd [51]. Supposely, Ido Rosen, has agreed to maintain his projects [51].
Thus, it is no wonder that the NetworkManager is becoming the de facto standard for most Linux Distributions.