IOTTMCO

Intuitively Obvious to the Most Casual Observer

Quirk of resolv.conf

I’m jotting this down here so I don’t forget it - I’ve been bit for the third time by this same not-quite-bug which is almost impossible to debug if you don’t already know what’s causing it.

The DNS resolution configuration file resolv.conf is read once by each process upon initialization (for most programs, at least). This appears to be a trade-off between the need to be able to change it without rebooting, and the obvious speed requirement for calls to gethostbyname(3) and so on. The unfortunate result of this is that updates to resolv.conf won’t be reflected in running programs.

You don’t want to start programs with resolv.conf not yet initialized. If you’re using dhcp, the resolv.conf will be blank until the connection is properly established, and so programs started before the connection is established may still see the old file with no name servers listed. Trying to debug this is rather unpleasant - some programs aren’t affected (firefox, for example, seems to run res_init(3) repeatedly of its own accord), and those that are don’t mention that they’re not seeing any nameserver, they just say they couldn’t resolve the domain name.