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

10.4: Host name resolution works as expected UNIX
At one time, OS X didn't consult the hosts file before doing a DNS lookup. In 10.3 and 10.4, it does. You can check the name resolution order of your Mac using Terminal; enter the following:
lookupd -configuration
Look for the following in the output:
LookupOrder: Cache FF DNS NI DS
_config_name: Host Configuration
The FF (flat file) refers to your hosts file (/etc/hosts), and Tiger does check its contents before going to DNS and Netinfo. Just a little FYI for those who may not have realized that 10.4 fixed things.
    •    
  • Currently 3.00 / 5
  You rated: 5 / 5 (4 votes cast)
 
[24,691 views]  

10.4: Host name resolution works as expected | 11 comments | Create New Account
Click here to return to the '10.4: Host name resolution works as expected' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Host name resolution works as expected
Authored by: jolinwarren on Mar 01, '07 08:11:52AM

Actually, this should not be labelled as a 10.4 hint... the change to consult the '/etc/hosts' file was made in 10.3 and it has worked since then. Still, there is no denying that support for the hosts file is useful!



[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: aschmidtm on Mar 01, '07 09:40:27AM
You can add ad servers to your hosts file and assign the IP of 127.0.0.1 to each of them.
Then create a blank web page and assign it as your 404 desination in /etc/httpd/httpd.conf.
Run apachectl start and if you have a good list of ad servers built up, you won't see ads anywhere.

---
[-[-[A]-]-]

[ Reply to This | # ]

10.4: Host name resolution works as expected
Authored by: TiVoFan on Mar 01, '07 09:47:22AM
This hint, combined with the information at Mike's Ad Blocking Hosts File will enable Mac users to screen out many ads while they're browsing. The idea is to map well-known ad servers to the localhost (127.0.0.1), so the ad servers never get a chance to slow you down and waste your bandwidth. I've been using it for 18 months without a glitch.

There are Mac-specific instructions to updating your hosts file, and to configuring lookupd. I was fortunate that my Macs haven't needed any tweaking, I only needed to edit the hosts file.

[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: bazcurtis on Mar 01, '07 01:21:26PM

Is their a way to search the cache like you can dig an external dns server?

Best wishes

Michael



[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: corienti on Mar 01, '07 02:31:45PM

Or, you could just use PithHelmet, a free (well, donationware) Safari plugin. I've found it to be far, far more effective than the AdBlock plugin for Firefox. Adblock on Firefox seems to catch about 80% of ads. PithHelmet on Safari catches more like 97%.
And Pithhelmet requires NO configuration whatsoever.
It's donationware but of course donation's optional. I actually donated however after using it for a little while, because it was incredibly effective.



[ Reply to This | # ]
10.4: Host name resolution works Great
Authored by: gxw on Mar 01, '07 05:17:35PM

Host name resolution works great
I've been redirecting Solitaire XL's call home feature to my web server for a while now.
192.168.2.5 lavacat.com



[ Reply to This | # ]
WTF? @#$!!! ;-P
Authored by: craigw on Mar 22, '07 03:03:14PM

This is the second time (reinstalled OS X) I've gone through the same frustrating procedure, & have to admit I don't think I solved it any faster.

So I just wanted to pass this along, in case anyone finds it useful.

Basic scenario:
Download a big hosts file from someplace.
Spend half an hour looking at it, reloading web pages that shouldn't be loading, wondering why is this hosts file not being consulted?

Answer:
It was created on a windoze machine.

Solution:
Open it in Smultron, or some other capable editor, or use your favorite method of converting text files to Mac/Unix line endings.

Suddenly it works. No more of that incredibly annoying intellitxt crap!
Do Microsoft geeks lay awake nights, trying to figure out ways to make the world a more unpleasant place? Are there bonus incentives involved?



[ Reply to This | # ]
Hosts File On MacOSX
Authored by: sweeney276 on Apr 20, '07 07:18:21AM

I'd have said that its Mac developers that are out of line. After all, standard hosts files as published on the net all work as-is with Linux and Windows, so why not MacOSX?

Since I have got this (very large) hosts file set up in Linux format is there any application which can convert it to a form acceptable by MacOSX?



[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: hasseg on Jan 04, '08 04:02:29AM

I've been trying to find the place where the name resolution order is set in Leopard, and haven't been very successful. Does anyone have any suggestions?



[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: CartoonHeroII on May 08, '08 11:56:16AM

I don't know how to find the order in Leopard, but editing /etc/hosts works fine to block files for me. i.e.

adsite.com <tab> 127.0.0.1



[ Reply to This | # ]
10.4: Host name resolution works as expected
Authored by: CartoonHeroII on May 08, '08 12:26:52PM
my bad, I had that backwards. My /etc/hosts file looks like:

127.0.0.1 <tab> www.myspace.com

and voila! myspace.com is blocked. I had to have the www's there, don't know why.

[ Reply to This | # ]