12.5. Networking Configuration with Systemd-networkd

12.5.1. Network Interface Configuration

[Note]

Note

Udev may assign random Network Card Interface names for some network cards such as enp2s1. If you are not sure what your Network Card Interface name is, you can always run ip l after you have booted your system. It is important that the Name variable in /etc/systemd/network contain the correct Network Card Interface name (e.g. Name=enp2s1 or Name=eth0) or systemd will fail to bring up your network interface.

12.5.1.1. Static Network Interface Configuration

systemd-networkd uses /etc/systemd/network for configuration files. Refer to systemd.network(5) and systemd.netdev(5). Configure a network interface with a config file. Adjust Name= as required:

cd /etc/systemd/network &&
cat > static.network << "EOF"
[Match]
Name=enp2s0

[Network]
Address=192.168.1.1/24
Gateway=192.168.1.2
EOF

The values of these variables must be changed in every file to match the proper setup.

The Name variable defines the interface name, for example, eth0. It is required for all network device configuration files.

The Gateway variable should contain the default gateway IP address, if one is present. If not, then comment out the variable entirely.

For more information see the systemd.netdev man page.

12.5.1.2. Connecting to a network with DHCP

systemd-networkd uses /etc/systemd/network for configuration files. Refer to systemd.network(5) and systemd.netdev(5). Configure a network interface with a config file. Adjust Name= as required:

cd /etc/systemd/network &&
cat > dhcp.network << "EOF"
[Match]
Name=enp2s0

[Network]
DHCP=yes
EOF

systemd-networkd will automatically configure /run/systemd/network/resolv.conf when using DHCP. If you did not manually create /etc/resolv.conf, create a symlink:

ln -sv /run/systemd/network/resolv.conf /etc

12.5.2. Using Timesyncd

Systemd includes a simple NTP client daemon, systemd-timesyncd, though it is disabled by default. If you want to enable it, you will first need to add a required user and group:

groupadd -g 78 systemd-timesync
useradd -g systemd-timesync -u 78 -d /dev/null -s /bin/false systemd-timesync

Then, actually enable systemd-timesyncd so that it will run on system boot:

systemctl enable systemd-timesyncd

You can configure systemd-timesyncd by editing /etc/systemd/timesyncd.conf.

Continue to Making the CLFS System Bootable.