How to fix dnsmasq after an Ubuntu upgrade

I mentioned before in Desktop Linux suckage: DNS caching that I use dnsmasq as a local DNS cache to work around lame ISP DNS, because Linux doesn't tolerate lame DNS as well as Mac OS will. (I never even noticed I had a problem until I switched from Mac OS to Linux.)

Using dnsmasq as a local DNS cache worked well, and I had no trouble until I upgraded to Ubuntu 8.10. Here, for my own reference next time I upgrade, is what I needed to do to fix things. (I'm assuming that this breakage will happen on every upgrade, because it would be rather sad if literally the only difference I noticed between 8.04 and 8.10 is that my local DNS cache stopped working.)

The symptom was that "nameserver" was missing from /etc/resolv.conf. Hasty optimistic fool that I was, I manually reinserted the missing line, and all was well... for several hours, when my DHCP lease was renewed. At which point it appears dhcp3-client rewrote /etc/resolv.conf for me.

(I really wish the perpetrator had had the decency to write a comment in /etc/resolv.conf saying what was going on. It might also have been nice to make the file read-only, as an added hint that humans shouldn't waste their time editing the file.)

So the real fix, it seems, is to edit /etc/dhcp3/dhclient.conf and uncomment this line:

prepend domain-name-servers;

I thought the daemon (dhclient3) might watch its configuration file for changes, but it didn't appear to. The daemon also appears to die if you send it SIGHUP, a signal those daemons too stupid to notice changes to their configuration files used to take as an indication that they should re-read their configuration.

Anyway, this – though perhaps more forceful than necessary – did the trick and saved me from wasting any more time on this nonsense:

sudo /etc/init.d/networking restart

Yeah, I know: "here's a nickel, kid".