Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle resolv.conf file changes #118

Open
lathiat opened this issue May 11, 2017 · 3 comments
Open

Handle resolv.conf file changes #118

lathiat opened this issue May 11, 2017 · 3 comments
Labels
wide-area DNS-SD queries using unicast DNS

Comments

@lathiat
Copy link
Contributor

lathiat commented May 11, 2017

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
Copy link
Contributor Author

lathiat commented May 11, 2017

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

@aragilar
Copy link

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.

@ktamp
Copy link

ktamp commented Jul 26, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wide-area DNS-SD queries using unicast DNS
Projects
None yet
Development

No branches or pull requests

4 participants