Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using NetInfo as replacement for /etc/hosts Network
I've been searching the net now since installing OSX Final for a way to use my hosts file in my /etc folder like I do under Linux for developing websites (i.e. in the hosts file I create "" and then use apache and http headers so that in a browser returns a locally created website).

Looking in the /etc/hosts file you are told that the file isn't consulted unless you change your lookupd configuration. Lookupd is handled by NetInfo. And hence my problem: I had no idea how to change the order in NetInfo to look at the flat file /etc/hosts before going to DNS.

Read the rest of this article if you'd like more info on using NetInfo as at hosts file...

After realizing I was overcomplicating things I found a better way to achieve the exact same result in a way I actually like better than editing a /etc/hosts file: using NetInfo!

I went into the "Utilities" folder in "Applications" and double-clicked the "Netinfo Manager", then clicked the lock and provided my password. The next thing I did was I noticed that / Machines (clicking the "/" in the left pane then the "Machines" in the middle pane) showed me the same listing of and localhost as the hosts file did. So, I clicked in the right pane the entry "Localhost" and then clicked the double-folder icon to duplicate this entry. I duplicated the entry as many times as I needed, then double-clicked the value "localhost" in the bottom window for each duplicated entry and changed it to what I wanted, i.e. ""

This has the same effect as having "" in the /etc/hosts file under linux.

Just thought I'd pass this along.
  • Currently 3.00 / 5
  You rated: 3 / 5 (8 votes cast)

Using NetInfo as replacement for /etc/hosts | 10 comments | Create New Account
Click here to return to the 'Using NetInfo as replacement for /etc/hosts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Quicker way (niload)
Authored by: robh on Mar 29, '01 06:57:20AM

You can load your /etc/hosts into NetInfoManager's database like this...

niload -m hosts / < /etc/hosts
(run as root if your admin doesn't have enough privileges).

The '-m' means merge the new hosts in with the existing ones.

The same procedure works for these:
aliases, bootptab, bootparams, ethers, exports, fstab, group, hosts, networks, passwd, printcap, protocols, resolv.conf, rpc, services, mountmaps.

[ Reply to This | # ]
Case Sensitivity
Authored by: Anonymous on Mar 29, '01 08:18:06PM

I had need of just this functionality this morning. Thanks for the tip, but there's a caveat:

I'm one of two Mac guys in a PC-only shop. Where the Windows people can access their desktop development servers using URLs like "http://joe2kserver/" thanks to WINS, my workaround has been modifying my hosts file.

I used the tip above to add the entries that were in my OS 9.1 hosts file to OS X's NetInfo. I discovered (during a presentation, unfortunately) that unlike the hosts workaround, NetInfo entries are case sensitive. So http://joe2kserver/ works, but http://JOE2KSERVER/ does not.

My workaround was to duplicate each of the entries and make an all-caps version. Is there a better way?

[ Reply to This | # ]
additional Hints thread
Authored by: j-beda on May 11, '01 03:35:33PM
There is a similar hint here that might be of interest:

[ Reply to This | # ]
additional Hints thread
Authored by: j-beda on May 15, '01 03:14:57PM
CDDB/freedb and ad blocking tricks
Authored by: j-beda on May 11, '01 03:49:08PM
What I would like to do is modify the way iTunes (and other programs) access the database of song titles. There are instructions for doing so in OS 9.1 by playing with the hosts here:, but no instructions for OS X.

Can I just take my hosts file from 9.1 (which also includes a bunch of ad blocking stuff) and use "niload" to merge it into netinfo? Or is the 9.1 hosts file in a different format than the etc/hosts file should be? There are directions for the format of the 9.1 file at Apple's site. Are there any resources for the fomat of the file for Mac OS X anywhere?

[ Reply to This | # ]

Doesn't work with DNS addresses?
Authored by: NeilFaiman on Mar 22, '02 10:55:45PM
My Mac is has a domain name ( and IP address ( Because of the way NAT translation works in my DSL modem/router, that IP address only works from the Internet outside my LAN. From my side of the router, I have to refer to my machine as (or -- seems to access the modem itself instead. This means that if I write a web page with absolute links, I can't test it locally.

I thought that the trick described here might be the solution to this problem. If I defined to be in NetInfo Manager, then references to from the Internet should get the registered IP address (, which works from the Internet; and references from my own machine should get the address from NetInfo Manager (, which works from my machine.

The only problem is that the NetInfo Manager definition doesn't seem to do anything. It shows up fine in NetInfo Manager, but when I refer to from my machine, it still gets resolved to

Is there any way to make domain name references on my machine get resolved to the NetInfo Manager mapping rather than the DNS value?

[ Reply to This | # ]

Doesn't work with DNS addresses?
Authored by: Hypertext on Mar 23, '02 04:06:15AM

I find that DNS does not work for me either. I have a domain name pointing to my IP. However, I am not going thru a router. My iBook using Mac OS X is directly connected to a hub which is connected to my dsl modem. I use the builtin pppoe sfwr in OS X to connect. I changed the apache file to refer to my web server as (where mydomain is my domain name of course). However, when I try to go to my web page using my domain it fails to work. Also, when I try to ping the IP that is automatically assigned to the PPPoE sfwr it does not reply. However, I am able to browse the internet just fine and am able to ping any other web site url just fine. I can also ping localhost. When I ping I get replies. In my web browser, If I try to access my web pages on my web server I can do so via localhost. so if I type into my web browser it takes me to my web page. when I use nslookup from the command prompt in OS X, it is able to do a reverse lookup on my IP. However, I am unable to ping my IP or my domain name. However, I found that when I hooked my laptop up to my friends cable modem and didn't use PPPoE but instead used a direct TCP/IP connection things worked fine. So I think something is going on with PPPoE. However, I do not understand what is actually happenning and how to force things to work. If anyone has any ideas on this I would appreciate it and it appears that others would also appreciate it. I suspect this same issue that is affecting my DNS is also preventing the original posters DSl/router stuff from working. If anyone has any idea how I can resolve this please let me know how to do it. I tried changing stuff in netinfo to no avail. I also tried modifying /etc/hosts file to no avail. Modifying httpd.conf has no effect on the situation either. I know that if you are not running in single user mode that /etc/hosts is not referrenced. Instead apparently, lookupd is referrenced and is accessed via netinfo. I still have not figured out this netinfo stuff though. I am used to Linux and the command line way of doing things. If anyone can help explain why DNS is not working via PPPoE then please let me know. you can e-mail me at If I find out how to do it I will post it to this forum so others will also have the benefit of the additional knowledge.

[ Reply to This | # ]
The advice here didn't work for me, but this did...
Authored by: cdbaby on May 23, '02 04:34:57PM
I was psyched to find this thread, but for some reason, using the graphic NetInfo manager didn't work for me. Even tried rebooting but my changes didn't stick.

BUT - found another page on the subject here that does work:

His advice seems a little strange, and I admit that I don't understand it, but it DOES work for me, whereas the other things mentioned here didn't, maybe because I'm trying to force a domain name for a box across the room like this: testdomain.test anotherdomain.test

SO FIRST - go EDIT your /etc/hosts file the way you would under Linux or BSD. (like the above.) Add your entries there.

THEN - go follow that weblink above and do his advice. It works.

[ Reply to This | # ]
get TMA
Authored by: ppmax on May 24, '02 01:35:01AM

The Moose's Apprentice (TMA) is a great little tool that does many things for you...including fixing an issue with the lookupd order.

get it at

just for reference my osx box:
sits behind a router on an internal lan
can be accessed by any of 3 different IP addresses and domain names
serves two public websites (apache virtural domains)
working inbound and outbound sendmail (tied to one of my domain names)

i believe most of the issues people have can be fixed by downloading ad installing TMA. for the adventurous, you can fix the lookupd order by hand.

open up netinfo manager and add an entry called locations
check out this picutre for reference:

good luck

[ Reply to This | # ]
The advice here didn't work for me, but this did...
Authored by: briank on Jan 23, '07 04:28:02PM
A couple of dead links in this thread...but the topic is still alive and well, 6 years later into 10.3-10.4! There are actually a couple of things that must be done in combination for all this work. While niload will get your hosts file into NetInfo, if lookupd is using the cache (which is by default in 10.3.9), your changes may take hours to go into effect. Here's an up-to-date link that explains all the necessary changes:

The changes work as advertised, but only if you actually read the entire document and check your lookupd lookup order for Hosts (by default, DNS is consulted before NetInfo, so niload is useless if you are trying to resolve local domains locally unless you also change the order of lookup so that NI comes before DNS).

Important to note: At a minimum, you will need to flush your lookupd cache for any Host changes to NetInfo to take effect:

lookupd -flushcache

Also, consider using the -d switch with niload. Otherwise, multiple localhost entries in your /etc/hosts file (important for a number of internal operations and at boot time) won't make it into your NetInfo database.

[ Reply to This | # ]