[arch-general] Detect broken DHCP setup

Leonid Isaev leonid.isaev at jila.colorado.edu
Tue Sep 5 23:09:13 UTC 2017


On Wed, Sep 06, 2017 at 12:09:52AM +0200, Giovanni Santini via arch-general wrote:
> On that device I am using *systemd-networkd + systemd-resolved* for the
> network setup. However, I saw no real method to check if the DHCP
> configuration is valid (while NetworkManager provides an element through
> DBus inspection).
> Does anyone has some knowledge about it?

What does it mean a valid DHCP setup? By reconnection you mean that your client
re-request a lease from the server? Also, dbus has nothing to do with dhcp
settings...

In any case, my advice is to get rid of NetworkManager as well as systemd-*
tools. If you want a robust dhcp setup on a simple client with a single network
card, use dhcpcd (no need even for netctl) because it provides link status
detection. But don't use dhcpcd at .service provided with the package, instead
replace it with:
->--------
$ cat /etc/systemd/system/dhcpcd\@.service
[Unit]
Description=dhcpcd on %I
Wants=network.target
Before=network.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device

[Service]
Type=simple
ExecStart=/usr/bin/dhcpcd -4qB -t 0 %I

[Install]
WantedBy=multi-user.target
-<--------
The crucial part is "-Bt 0" which makes dhcpcd wait forever for a lease (read
the manpage for other options you might need, for example, in my setup I
constrain the demon to only deal with ipv4). My (compatible with read-only root
filesystem) /etc/dhcpcd.conf is:
->--------
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
slaac private
noipv4ll
nohook wpa_supplicant
nohook resolv.conf
-<--------
these are mostly default settings. Maybe you need to add "nomtu" in case your
ISP does something idiotic with this setting (mine does :)). Oh, and hardcode
the DNS settings in /etc/resolv.conf, so a broken dhcp server has no control
over them.

HTH,
-- 
Leonid Isaev


More information about the arch-general mailing list