Setting up a static IP address
To configure a static IP address with systemd-networkd, create a configuration file in the /etc/systemd/network/ directory. In this configuration file, the corresponding network settings for the network interface are defined and parameters such as IP address, gateway and DNS server are specified. After restarting the system, the systemd-networkd service automatically adopts the settings. Create a separate configuration file with the individual network settings for each network interface.
By default, the Ethernet interfaces are configured to obtain an IP address from a DHCP server. This standard configuration is pre-installed as /usr/lib/systemd/network/20-wired.network and should not be edited. Configuration files under /etc/systemd/network overwrite the settings under /usr/lib/systemd/network/
Proceed as follows:
- 1. Use the command
ip addr showto determine the available Ethernet interfaces. - Examples of available Ethernet interfaces:
lo, end1, end0 - 2. Create a configuration file in the directory
/etc/systemd/network/, for example with the name10-end0-static.network. - The number 10 at the beginning of the file name
10-end0-static.networkdetermines the order in whichsystemd-networkdprocesses this file compared to other files. This allows the priority to be controlled. The numbering is only relevant within the respective directory and not across directories.
sudo nano /etc/systemd/network/10-end0-static.network - 3. Insert the following content and adjust the values to your network requirements:
[Match]
Name=end0
[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1- 4. Save and close the configuration file.
- 5. Reload the configuration files with the following command without restarting the network service.
networkctl reload- 6. Check whether the configuration has been loaded correctly. Display the network status with
networkctl status. Useip addr showandip route showto check the IP address and routing.
- These settings ensure that the static IP configuration in the
10-end0-static.networkfile is given priority over the DHCP settings in the20-wired.networkfile.