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 local DHCP server. This standard configuration is pre-installed as /usr/lib/systemd/network/20-wired.network and should not be edited.

Proceed as follows:

1. Use the command ip addr show to 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 name 10-end0-static.network.
The number 10 at the beginning of the file name 10-end0-static.network determines the order in which systemd-networkd processes this file compared to other files. This allows the priority to be controlled.
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. Use ip addr show and ip route show to check the IP address and routing.
These settings ensure that the static IP configuration in the 10-end0-static.network file is given priority over the DHCP settings in the 20-wired.network file.