How to debug systemd-networkd?

6

2

I would like to use systemd-networkd to configure my networking on Ubuntu.

I added an /etc/systemd/netwoek/host0.network file

[Match]
Name=host0

[Network]
Address=10.5.1.1/24
Gateway=10.5.1.254

to configure my host0:

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: host0@if14428: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d6:fa:2e:69:dd:30 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 169.254.229.86/16 brd 169.254.255.255 scope link host0
       valid_lft forever preferred_lft forever
    inet6 fe80::d4fa:2eff:fe69:dd30/64 scope link
       valid_lft forever preferred_lft forever

But, as seen above it is not configured with 10.5.1.1 despite restarting systemd-networkd, enabling it, rebooting. Each time the address is from APIPA (as if there was no DHCP, which is not configured there).

In no other places is networking configured (notably in /etc/network/interfaces, which is empty)

WoJ

Posted 2017-03-11T13:46:00.327

Reputation: 1 580

Did you look at the output of networkctl yet? What about systemctl status systemd-networkd? – Daniel B – 2017-07-26T11:08:02.283

Answers

14

From https://coreos.com/os/docs/latest/network-config-with-networkd.html :

Enable debugging manually

mkdir -p /etc/systemd/system/systemd-networkd.service.d/

Create Drop-In /etc/systemd/system/systemd-networkd.service.d/10-debug.conf with following content:

[Service]
Environment=SYSTEMD_LOG_LEVEL=debug

And restart systemd-networkd service:

systemctl daemon-reload
systemctl restart systemd-networkd
journalctl -b -u systemd-networkd

Anon

Posted 2017-03-11T13:46:00.327

Reputation: 830

2systemctl edit systemd-networkd is slightly faster as it creates automatically the needed folder and doesn't need daemon-reload. – Max – 2019-10-31T13:35:54.840

For some reason I had to reboot before debugging was activated for systemd-networkd. Just mentioning it in case someone else struggles. (Yes, I tried reloading and restarting - multiple times.) Running systemd 243. – hansfn – 2019-12-09T10:10:36.500

0

The previous answers are great to find out what is running and what isn't, and restarting the service.

I'd add (from How to enable if it's disabled):

systemctl enable <your.service.here>

e.g. systemd-networkd

Also, I'm not sure what Name=host0 matches. I guess something, since it shows up in 2: host0@if14428 under ip addr. But using and interface name, or MAC address, as it appears in ip link is a safer bet.

Lubo Diakov

Posted 2017-03-11T13:46:00.327

Reputation: 41

host0 is in fact an interface name -- it's the default name on systemd-nspawn containers for the "inside" half of a veth pair. – user1686 – 2018-07-21T16:28:59.287

this is a useless answer, if i were you i'd remove it – nhed – 2019-08-15T00:25:45.353