avahi icon indicating copy to clipboard operation
avahi copied to clipboard

Handle resolv.conf file changes

Open lathiat opened this issue 8 years ago • 4 comments

We should monitor and reload /etc/resolv.conf if changes are detected, because either

(a) The servers may change, or (b) The file may not yet be available during early startup as the network connection is not yet established

This information is used in two main areas, (1) publish-resolv-conf-dns-servers, (2) as the list of servers to query for wide area DNS queries.

Ideally this would be done with inotify and not polled, but we also need to consider the chroot helper.

This would also avoid errors being logged on startup currently even if neither of these features are actually used. Refer to #63 and #59.

lathiat avatar May 11 '17 20:05 lathiat

When fixing the errors about loading resolv.conf, we also need to note that errors are produced both by load_resolv_conf and avahi_chroot_helper_get_file

lathiat avatar May 11 '17 20:05 lathiat

As a suggestion, adding a dbus API which allows setting nameservers/search domains would mean the resolv.conf reading could be done in a separate, low-privileged service (as it would only need to read the file, and send the dbus messages), and could reduce the need to have different paths to handle the chroot and non-chroot cases. That would also mean that avahi could be told about DNS-SD domains independent of "normal" search domains.

aragilar avatar Jun 27 '21 04:06 aragilar

Since #159 is marked as a duplicate of this, I have to write here that what is really needed is that avahi-daemon.service restarts/refreshes e.g. every 10 seconds.

This way Avahi would always find network printers / scanners /multifunctionals that had just been switched on. It would also find computers which had just been turned on and which have enabled e.g. the sftp service in order for the home folders to be browsable using Nautilus.

In order to facilitate the above without editing avahi-daemon.service, one has to set a cron job or create and enable a systemd timer. For the systemd timer, creating avahi-daemon-timer.service and avahi-daemon-timer.timer in /usr/lib/systemd/system and enabling avahi-daemon-timer.timer would do the trick.

avahi-daemon-timer.service:

[Unit] Description=avahi-daemon timer Requires=avahi-daemon.sevice

[Service] Type=oneshot ExecStart=/usr/bin/systemctl restart avahi-daemon.service

[Install] WantedBy=multi-user.target

avahi-daemon-timer.timer:

[Unit] Description=avahi-daemon timer timer

[Timer] OnBootSec=30s OnUnitActiveSec=10s Unit=avahi-daemon-timer.service

[Install] WantedBy=multi-user.target

ktamp avatar Jul 26 '23 14:07 ktamp