Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Mac OS X Snow Leopard Server as my network router. Is it possible to set a global host in its /etc/hosts file, like:

that redirects all requests (e.g. browsing from the whole network to that IP? So I don't have to set it at all client machines?

share|improve this question

The hosts file is simply something local to a machine.

Therefore, if you have a computer that queries, it will first look in its host file, find nothing then query its DNS server. The DNS will look in its local zones, find nothing and send a recursive query (?... need to double check) to it's linked DNS servers and then if it finds nothing, it will send a query to the root zones.

At no point are DNS services on a machine influenced by their own hosts file. So if you add it, it will simply be for the server and only the server.

That being said, IF that server is the DNS server for the network, you can easily insert a new zone for and an A/Cname record for www or just *, followed by a value of, this should do what you want for the entire network.

share|improve this answer

Not generally. Resolving is done on the host -- meaning if you lookup on machine A, it's machine A's resolving rules that determine the IP for that address, not the router's.

Machine A will check its own hosts file, and then it'll check with DNS. (Other resolving systems could be in use.)

If your router serves as the local DNS for your network, then you can enforce this -- either through local zone records, if you are using a full-on DNS server like BIND, or by specially configuring a caching DNS server like DNSmasq to check its local hosts file first.

For DNSmasq (commonly used on OpenWRT and DD-WRT router firmwares), add expand-hosts to the /etc/dnsmasq.conf file to enable this functionality.

share|improve this answer

You must log in to answer this question.