Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've followed these instructions for setting up a local DNS server on my mac, and using it to server wildcard subdomains on localhost. It's a really nice thing:

One weakness, though: I'm sometimes trying to work offline, and the local BIND instance is only consulted when you have a live connection with in the DNS server list.

Is there a way to achieve this effect offline?

share|improve this question is offline. You can always connect to = localhost. The only thing you need is the loopback interface aka localhost aka I'm not an osx buff, and I don't have enough cred here to make a comment... What exactly is meant by "work offline"? A safari mode? – Ярослав Рахматуллин Jun 16 '11 at 12:43
I'm working on a site that uses subdomains-- using that trick above, I can fake that on localhost, so I have one.mydomain.local, and two.mydomain.local, etc, all resolving to But it only works when I have an active connection. By offline, I just mean not connected to any network – Ross M Karchner Jun 17 '11 at 2:59
just make sure "lo", the loop-back is up. ifconfig lo up or whatever (where whatever is something like ifconfig lo up; route add -net gw netmask -- but you should not have to do this manually) – Ярослав Рахматуллин Jun 17 '11 at 3:11
Localhost is fine-- what I want is my locally running instance of BIND to be consulted for domain lookups, even when I'm not online. – Ross M Karchner Jun 17 '11 at 11:08

3 Answers 3

You need to set your resolver configuration to use for that local domain:

sudo mkdir /etc/resolver
sudo vim /etc/resolver/local

Add the following lines to the /etc/resolver/local configuration:

search_order 1

The name of the configuration file "local" is the name of your search domain. (Mine happens to be "dev"; if you followed that tutorial, yours would be "local".)

You can then go into your System Preferences / Network configuration and remove the custom DNS server you had set there for The above resolver configuration means your localhost DNS will only be consulted for "local" domains.

More details in this helpful serverfault answer.

share|improve this answer

The thread A small bit of hardware hacking == No Wi-Fi suggests using a hardware loopback device ($6.79 on Amazon).

This might be a solution to trick OS X into thinking it has a valid network connection.

This also requires using a static IP address, since there is no DHCP server.


share|improve this answer
I'm buying it now to see if this works. Have you actually tried this, along with the local DNS thing? – Barnabas Kendall Jul 4 '11 at 22:07
Hope this works for you. But no, I never had this problem, nor a Mac. Did you try just connecting a network cable to the card and using a static IP? – harrymc Jul 5 '11 at 5:59
This is interesting-- but there has to be a software solution, right? – Ross M Karchner Jul 6 '11 at 16:49
Hmmmm.... maybe. – harrymc Jul 6 '11 at 17:40

Perhaps I am missing something, but you seem to be overlooking the /etc/hosts file completely. Unix operating systems will reference /etc/hosts before making DNS requests. localhost resolves to because it is specified so in /etc/hosts!

You can edit /etc/hosts with any text editor, but you'll need root privileges.

sudo open -a TextEdit /etc/hosts one.mydomain.local two.mydomain.local
share|improve this answer
The idea is to not have to manually tend /etc/hosts-- I want anything.local to resolve to – Ross M Karchner Jul 7 '11 at 14:38
/etc/hosts is not very helpful when you're developing sites that use dynamic subdomains, like On my local DNS server I have a zone for *.dev so if I just rename ".com" to ".dev" then it goes to my localhost server. – Andrew Vit Jul 31 '11 at 21:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.