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


Won't work | 19 comments | Create New Account
Click here to return to the 'Won't work' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Won't work
Authored by: gidds on May 26, '04 10:36:57AM

That's what you'd do on many Unixes, but Mac OS X gets all its hosts info from the NetInfo database, bypassing the /etc/hosts file. On my machine, the file has the following comment: "By default, lookupd gets information from NetInfo, so this file will not be consulted unless you have changed lookupd's configuration."

---

Andy/



[ Reply to This | # ]
Eh, sure it does.
Authored by: vykor on May 26, '04 10:56:16AM

Hmm...on OS X 10.3, that statement is misleading. I've been using the hosts file ever since installation of Panther to block ads, etc, and it's worked fine. I believe in prior system versions you had to run some terminal magic to detach hosts from NetInfo, but now it's definitely a part of the check sequence.

You also should run " lookupd -flushcache " once you add the entry to the hosts file. Or restart your machine. Either way, that makes the new DNS entry stick.



[ Reply to This | # ]
Eh, sure it does.
Authored by: JohnnyMnemonic on May 26, '04 01:31:29PM

Hm. Even after I "lookupd -flushcache", "host" still resolves to a real IP. Do I need to do something else to get the /etc/hosts config loaded? I seem to recall something about NetInfo too--maybe not applicable to Pantherl, but in any case it's not working.



[ Reply to This | # ]
other option? re: Eh, sure it does.
Authored by: webbix on Jun 07, '04 12:27:08PM
try adding to '/etc/hosts.deny'

I read this comment previously but gave it little attention as I keep 'load images' off anyway.

However, using Webmin and playing around with PortSentry I excluded my test machine with the rule I had and ended up doing a web search to find where I was getting blocked. PortSentry with the config I chose (FreeBSD/Mac OS X) had added the IP to the 'hosts.deny' file and it did block all but file sharing and web access (not sure why those worked).

This is the command to Kill the host from PortSentry

KILL_ROUTE="route add -net $TARGET$ -netmask 255.255.255.255 127.0.0.1 -blackhole"

However, please use only at your own risk NOT as recommendation.

[ Reply to This | # ]
Won't work
Authored by: mzarra on May 26, '04 11:03:36AM

I disagree with the way that this works. I routinely put information in to my /etc/hosts file and use it to access internal machines that are not configured with a DNS Name. I have also blocked sites by routing their DNS name to localhost.



[ Reply to This | # ]
Default lookup order
Authored by: gatorparrots on May 27, '04 03:00:55AM
The comments within the /etc/hosts file are more than likely incorrect and have been since 10.2. They should largely be ignored, but I suppose it's all in how you installed your operating system. If yours is an upgrade installation, you may not have the same lookup order as those who have done cleans installs of Panther or Jaguar.

To check your current lookup order, simply execute this command:

lookupd -configuration
By default under Panther, the lookup order is as follows:
LookupOrder: Cache FF DNS NI DS
_config_name: Host Configuration
So, flat files (FF) are searched before DNS, meaning that by default the /etc/hosts file should be consulted before name-to-IP-address resolution is ever attempted.

These articles do a good job showing the default lookup orders of 10.1, 10.2, and 10.3:
http://www.macwrite.com/criticalmass/%20mac-os-x-hosts-panther-pf.php
http://www.macwrite.com/criticalmass/mac-os-x-hosts-regrouped.php
(Really, they should be prerequisite reading before attempting to change the lookup order or mess with the hosts file.)

[ Reply to This | # ]

Default lookup order
Authored by: ether on May 27, '04 01:39:22PM

My machine has run through the upgrade sequence from 10.1--10.3.3.
The config info is:

LookupOrder: CacheAgent NIAgent DNSAgent NILAgent
_config_name: Host Configuration
name: hosts

so I guess whether it works _does_ depend on whether you've
done a clean install or not.



[ Reply to This | # ]