Systemd-networkd

Jump to: navigation, search

Tumbleweed offers network configuration through yast2 lan. Both Wicked and NetworkManager are powerful and flexible. systemd-networkd is a third option:

  1. Configuring without a GUI is more straight forward than configuring NetworkManager.
  2. Being a module of systemd, its memory and CPU usage is extremely low.
  3. systemd-networkd operates fully in the background; no user serviceable parts inside.

Configuration Examples

Minimal Home Network

See: How to Set Up a Home Network- Beginners Guide

The configuration below was tested with Tumbleweed linking to a custom Fritz!Box 7360 supplied by M-net. It incorporates a Wireless access point, Ethernet switch, DSL modem and Router in a single box.

Default name and address are fritz.box / 192.168.178.1. Other routers will use different values. However the sample configuration should work for them with appropriate changes.

Configuration Files

Define the machine's address and hostname by adding a line to /etc/hosts:

erlangen:~ # cat /etc/hosts
#
# hosts         This file describes a number of hostname-to-address
#               mappings for the TCP/IP subsystem.  It is mostly
#               used at boot time, when no name servers are running.
#               On small systems, this file can be used instead of a
#               "named" name server.
# Syntax:
#    
# IP-Address  Full-Qualified-Hostname  Short-Hostname
#

127.0.0.1       localhost

# special IPv6 addresses
::1             localhost ipv6-localhost ipv6-loopback

fe00::0         ipv6-localnet

ff00::0         ipv6-mcastprefix
ff02::1         ipv6-allnodes
ff02::2         ipv6-allrouters
ff02::3         ipv6-allhosts

192.168.178.3   erlangen.fritz.box erlangen
erlangen:~ # 

Make sure systemd-resolved.service is disabled:

erlangen:~ # systemctl status systemd-resolved.service 
● systemd-resolved.service - Network Name Resolution
   Loaded: loaded (/usr/lib/systemd/system/systemd-resolved.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:systemd-resolved.service(8)
           https://www.freedesktop.org/wiki/Software/systemd/resolved
           https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
           https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
erlangen:~ # 


If existing remove any link /etc/resolv.conf and supply file /etc/resolv.conf:

erlangen:~ # cat /etc/resolv.conf
nameserver 192.168.178.1
erlangen:~ # 

Configure the management of the wireless link wlp3s0 by adding a .network file (iwconfig will tell you the name of the link):

erlangen:~ # cat /etc/systemd/network/30-wireless.network
[Match]
Name=wlp3s0

[Network]
Address=192.168.178.3/24
Gateway=192.168.178.1

erlangen:~ #

Configure wpa_supplicant by modifying the existing file wpa_supplicant.conf:

erlangen:~ # cat /etc/wpa_supplicant/wpa_supplicant.conf
network={
    ssid="FRITZ!Box Karl Mistelberger"
    psk="......................."
}
erlangen:~ # 

Systemd Units

Make sure both wicked and NetworkManager are disabled:

erlangen:~ # systemctl list-unit-files 'wick*'
UNIT FILE             STATE   
wicked.service        disabled
wickedd-auto4.service disabled
wickedd-dhcp4.service disabled
wickedd-dhcp6.service disabled
wickedd-nanny.service disabled
wickedd-pppd@.service static  
wickedd.service       indirect

7 unit files listed.
erlangen:~ # systemctl list-unit-files 'Network*'
UNIT FILE                          STATE   
NetworkManager-dispatcher.service  disabled
NetworkManager-wait-online.service disabled
NetworkManager.service             disabled

3 unit files listed.
erlangen:~ # 

Enable systemd-networkd and wpa_supplicant; check settings as follows:

erlangen:~ # systemctl list-unit-files 'systemd-networkd*' 'wpa*'
UNIT FILE                            STATE   
systemd-networkd-wait-online.service enabled 
systemd-networkd.service             enabled 
wpa_supplicant.service               disabled
wpa_supplicant@.service              indirect
systemd-networkd.socket              enabled 

5 unit files listed.
erlangen:~ # 

Note the service for interface wlp3s0:

erlangen:~ # systemctl status wpa_supplicant@wlp3s0.service 
● wpa_supplicant@wlp3s0.service - WPA Supplicant daemon (interface wlp3s0)
   Loaded: loaded (/usr/lib/systemd/system/wpa_supplicant@.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-03-29 19:28:49 CET; 16h ago
 Main PID: 1081 (wpa_supplicant)
    Tasks: 1 (limit: 4915)
   Memory: 3.7M
   CGroup: /system.slice/system-wpa_supplicant.slice/wpa_supplicant@wlp3s0.service
           └─1081 /usr/sbin/wpa_supplicant -iwlp3s0 -c /etc/wpa_supplicant/wpa_supplicant.conf -u -t -f /var/log/wpa_supplicant.log

Mar 29 19:28:49 erlangen systemd[1]: Starting WPA Supplicant daemon (interface wlp3s0)...
Mar 29 19:28:49 erlangen systemd[1]: Started WPA Supplicant daemon (interface wlp3s0).
erlangen:~ # 

Verify

Upon rebooting systemd-networkd will be running:

erlangen:~ # journalctl -b -u systemd-networkd -o short-monotonic 
-- Logs begin at Mon 2019-03-18 17:54:36 CET, end at Wed 2019-03-27 12:53:16 CET. --
[    3.524507] erlangen systemd[1]: Starting Network Service...
[    3.567653] erlangen systemd-networkd[519]: Enumeration completed
[    3.569489] erlangen systemd[1]: Started Network Service.
[    3.971240] erlangen systemd-networkd[519]: wlan0: Interface name change detected, wlan0 has been renamed to wlp3s0.
[    4.115384] erlangen systemd-networkd[519]: wlp3s0: Could not bring up interface: Invalid argument
[    4.115650] erlangen systemd-networkd[519]: eth0: Interface name change detected, eth0 has been renamed to enp0s31f6.
[    6.161137] erlangen systemd-networkd[519]: wlp3s0: Gained carrier
[    8.175286] erlangen systemd-networkd[519]: wlp3s0: Gained IPv6LL
[    9.999213] erlangen systemd-networkd[519]: wlp3s0: Configured
erlangen:~ # 
erlangen:~ # networkctl 
IDX LINK             TYPE               OPERATIONAL SETUP     
  1 lo               loopback           carrier     unmanaged 
  2 wlp3s0           wlan               routable    configured
  3 enp0s31f6        ether              off         unmanaged 

3 links listed.
erlangen:~ # 

Disabling IPv6

Older routers, such as the THOMSON TG585 v7 don't support IPv6. Systemd-networkd will try to connect until timeout. Supress IPv6 on a link basis:

linx-paks:~ # cat /etc/systemd/network/ethernet.network 
[Match]
Name=eth0

[Network]

LinkLocalAddressing=no
IPv6AcceptRA=no

Address=10.0.0.1/24
Gateway=10.0.0.138
linus-paks:~ #