[arch-general] Detect broken DHCP setup
Good morning, tl;dr: I was wondering what could be the best way to check a DHCP setup. Briefly: our landlord provides us Wifi through a telephonic company service. However, the routers placed in the building after some time lose the DHCP settings. While I can fix it on my computer with a reconnection, such a method is not applicable to my Raspberrys. On one I have Raspbian, on the other ArchLinuxARM. While I found a possible solution for the Raspbian, for ALARM I have some doubt. 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? To be fair, I am asking as I am sure the 'ping Google DNSs and if it is screwed restart the networking, use this as a cron job' will likely work, but I was interested in a more elegant way to approach it (like the NetworkManaged DBus introspection). Thanks in advance to all! -- Giovanni Santini My blog: http://giovannisantini.tk My code: https://git{hub,lab}.com/ItachiSan My GPG: 2FADEBF5
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@.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
Il 06/09/2017 01:09, Leonid Isaev via arch-general ha scritto:
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...
I know DBus has nothing to do with DHCP; what I meant is that NetworkManager shows in its DBus interface when the DHCP configuration is not valid, so people can reset it. And almost, what I would do is to restart the connection.
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@.service provided with the package, instead replace it with: ... -<-------- 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: ... 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.
Thanks a lot for the configuration files and the suggestions! If there's no better solution I can go for them! :) I still noticed that systemd exposes a DBus network interface (*org.freedesktop.network1*) which should have proper information but I found very little documentation online (if none) regarding it... -- Giovanni Santini My blog: http://giovannisantini.tk My code: https://git{hub,lab}.com/ItachiSan My GPG: 2FADEBF5
On Wed, Sep 06, 2017 at 11:27:13AM +0200, Giovanni Santini via arch-general wrote:
Il 06/09/2017 01:09, Leonid Isaev via arch-general ha scritto:
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...
I know DBus has nothing to do with DHCP; what I meant is that NetworkManager shows in its DBus interface when the DHCP configuration is not valid, so people can reset it. And almost, what I would do is to restart the connection.
But what does it mean "not valid" and "restart connection"? Does it mean that the lease expires and you need to obtain a new one, so you restart NM? Or the system can not reach the network beyond the gateway?
Thanks a lot for the configuration files and the suggestions! If there's no better solution I can go for them! :) I still noticed that systemd exposes a DBus network interface (*org.freedesktop.network1*) which should have proper information but I found very little documentation online (if none) regarding it...
Again, when it comes to network settings, there is nothing to expose over dbus. systemd and NM have this obscure concept of a "system being online" but it is nothing more than a simple ping fedoraproject.org. This test fails in many legitimate cases which makes it useless... Cheers, -- Leonid Isaev
On 09/06/2017 06:19 PM, Leonid Isaev via arch-general wrote:
Again, when it comes to network settings, there is nothing to expose over dbus. systemd and NM have this obscure concept of a "system being online" but it is nothing more than a simple ping fedoraproject.org. This test fails in many legitimate cases which makes it useless...
Are you referring to NetworkManager's connectivity check? Because that checks to see if http://www.archlinux.org/check_network_status.txt returns the body content "NetworkManager is online", see /usr/lib/NetworkManager/conf.d/20-connectivity.conf and NetworkManager.conf(5) for details. It is a pretty robust check, unless archlinux.org is offline or banned by a proxy/filter. -- Eli Schwartz
participants (3)
-
Eli Schwartz
-
Giovanni Santini
-
Leonid Isaev