I have installed, configured DNS server(local instance of Dnsmasq) which resolves to localhost as I want, all OK.
When I go offline, it stops working, because OS X empty content of resolv.conf and ignore attempt to reflect changes in this file.
Any idea, how to configure DNS even when offline?
Similar issue(unresolved): http://blog.steamshift.com/geek/leopard-lookupd-and-local-web-development-sites
Main motivation is ease development of RoR application which uses subdomains as account keys. And you can not use 127.0.0.1 *.yourapp.local in /etc/hosts. Some guy registered domain smackaho.st and srt DNS for it like .smackaho.st at 127.0.0.1 but still, you can not use it when you are working offline.
EDIT: tried scutil command, but it seems you can change DNS if offline
NOTE: when you have all interfaces down, you cannot set DNS servers in Pref. panel.
Best Answer
SEE UPDATE BELOW!
I also enjoy using Dnsmasq on my local machine, and I had this problem too. Here is the solution:
From
man 5 resolver
:/etc/resolver/
is not present by default; you must create it yourself.Also from the man page:
So if you wanted all dns queries for the top level domain of
dev
to be routed to the local nameserver, you would:configd
does not alter files in/etc/resolver/
, so this setting will persist through network changes and reboots.UPDATE 17 July 2012
Unfortunately, as of OS X Lion, the top resolver (as shown by
scutil --dns
) disappears when no interfaces are active:Notice that resolver #1 is empty, but that the /etc/resolver derived nameserver entry remains.
It turns out that since you can specify the resolver domain directly in the /etc/resolver/ file, specifying the special Internet root domain
.
causes the creation of a global resolver entry that looks like:Now all DNS queries are routed to localhost, even when offline.
Of course, you will still have to resolve your chosen domains as 127.0.0.1 using something like dnsmasq's --address option:
In summary:
cf. http://opensource.apple.com/source/configd/configd-395.11/dnsinfo/dnsinfo_flatfile.c