Improved DNS resolving for laptops?
Petter Reinholdtsen
pere@hungry.com
Fri Jul 23 09:53:00 GMT 2004
My laptop moves from network to network. The network configuration is
updated using DHCP, but the DNS resolver info is not as easy to
update. The file /etc/resolv.conf is updated by the DHCP client, but
the programs do not re-read this file once they are started. This is
a problem for long-lived programs, and for my laptop this means it is
a problem for most programs (hibernate works. :).
Here is an idea on how to make it possible to solve this, without
affecting all users of the resolver functions. The idea consist of
two parts:
- Every time a DNS lookup fail, (or only when a specificed time
period has elapsed since the last check), stat /etc/resolv.conf,
and if this file changed, reread it by calling res_init().
- Make the new behaviour optional using a flag in /etc/host.conf.
This way only the hosts in need of this dynamic rebinding would
enable it, and the others would keep working as before.
There could also be a flag to make the resolver check the timestamp of
resolv.conf ever X seconds. This would make sure programs start using
the new content even if the old DNS server is still replying to
queries.
Do you think this would work?
There is a similar problem with /etc/localtime when moving my laptop
from timezone to timezone, but I'm not sure how that could be solved
without stat()ing the file every time localtime() is called. And I
don't want that.
More information about the Libc-alpha
mailing list