On my notebook running Gentoo, I set up the following things:
- Kernel with all necessary settings and modules
- WPA_Supplicant
- Systemd
- Systemd-Networkd
Almost everything works as expected, the connection to my WiFi is established and stable. The only problem is, that I can't get systemd-networkd to act as a DHCP client to receive a valid IPv4 address.
This is my /etc/systemd/network/50-dhcp.network
:
[Match]
Name=*
[Network]
DHCP=yes
As I understood, this will trigger a DHCP call for every network interface. Also, there should not be any additional DHCP client software necessary (see here for example).
So, if I don't install any additional software, just nothing will happen after being connected to the WiFi. ifconfig
shows:
wlp59s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 280 bytes 21542 (21.0 KiB)
RX errors 0 dropped 232 overruns 0 frame 0
TX packets 8 bytes 2304 (2.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
There's also nothing useful in the journal, but this line:
... wlp59s0: Configuring with /etc/systemd/network/50-dhcp.network
Next thing I tried was installing DHClient. It won't work automatically, but if I issue just dhclient
, it works and I get an IP address within the desired range. The journal says:
... dhclient[407]: DHCPREQUEST for 192.168.0.35 on wlp59s0 to 255.255.255.255 port 67
... dhclient[407]: DHCPDISCOVER on enp58s0u1u2 to 255.255.255.255 port 67 interval 3
... dhclient[407]: DHCPACK of 192.168.0.35 from 192.168.0.1
... dhclient[407]: bound to 192.168.0.35 -- renewal in 348891 seconds.
... dhclient[407]: Can't create /var/run/dhcp/dhcpclient.pid: No such file or directory
... dhclient[407]: DHCPDISCOVER on enp58s0u1u2 to 255.255.255.255 port 67 interval 6
I'd like to have this happen automatically once connecting to my WiFi. Can you please show me where my mistake is? I've been searching quite a while, but I didn't find any clue.
One more note: If I install dhcpcd (instead of/alongside dhclient), in fact I am getting an IP address automatically, but that one seems to be created quite randomly and doesn't belong to my net. Journal says:
... systemd-networkd[234]: wlp59s0: Configuring with /etc/systemd/network/50-dhcp.network
...
... dhcpcd[343]: wlp59s0: connected to Access Point: my.wlan.ssid
... dhcpcd[343]: wlp59s0: IAID d0:fe:1b:39
... dhcpcd[343]: wlp59s0: soliciting a DHCP lease
... dhcpcd[343]: wlp59s0: probing for an IPv4LL address
... dhcpcd[343]: wlp59s0: using IPv4LL address 169.254.211.13
... dhcpcd[343]: wlp59s0: adding route to 169.254.0.0/16
(But, as stated before, I thought I just wouldn't need any additional DHCP client? Anyway, the result with DHCPCD is not the desired one.)