Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > /etc/hosts problem

/etc/hosts problem
Thread Tools
Fresh-Faced Recruit
Join Date: Jun 2003
Status: Offline
Reply With Quote
Apr 8, 2004, 08:39 AM
 
Hello
I don't know why this happs:

#test
#this works:
127.0.0.1 apple.com
#this not:
127.0.0.1 www.apple.com
any idea?

thanks
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 8, 2004, 02:23 PM
 
The way you have it...if both of them are in the file, it stops at first resolution.

The correct syntax would be:

127.0.0.1 apple.com www.apple.com localhost
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Grizzled Veteran
Join Date: Sep 2000
Location: New Jersey, USA
Status: Offline
Reply With Quote
Apr 10, 2004, 08:05 AM
 
Just for my knowledge, hosts file allows you to apecify or prevent access to ceertain sites, right?

I had someone show me that he added about 50-100 items to this file to block pop-ups apparently. I did tell him to just turn it on in safari, but he thought he'd use his Unix instead. Afterwards, his mail and ichat apps took a minute to launch on first launch after boot. Subsequent launches were ok, but I did finally pinpoint the issue to this file. Upon, resetting it back to an original file with limited text, issue resolved.

Could there be a bad command in there that was hanging any internet app? (not browsers though). Or just too many entries?
Dual 2.0 G5/2.5GB/ATI 9800 Pro | MacBook Pro 2.16 Gore Duo/2GB/ATI X1600
     
Dedicated MacNNer
Join Date: Jul 2002
Location: Norway
Status: Offline
Reply With Quote
Apr 10, 2004, 02:09 PM
 
It isn't a good idea using /etc/hosts for banner blocking
Mac Pro 2 x 2.8 GHz Quad-Core, Nvidia GeForce 8800GT
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 11, 2004, 08:57 PM
 
No, you got it all wrong.

/etc/hosts is used solely for name resolution.
using it will just "short circuit" DNS resolution (depending on how lookupd is configured)

Now, you can trick your computer and prevent sites from loading by mapping something like

127.0.0.1 ad.server.com
127.0.0.1 something.else.com


in which case any requests to either ad.server.com or something.else.com would just go to your localhost.

/etc/hosts is not used for allowing or denying hosts access in or out of your machine.
(Last edited by Kristoff; Apr 11, 2004 at 09:03 PM. )
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Dec 1999
Location: Plainview, NY
Status: Offline
Reply With Quote
Apr 11, 2004, 09:22 PM
 
Originally posted by Kristoff:
/etc/hosts is not used for allowing or denying hosts access in or out of your machine.
well, if he didn't specify a dns server then he could selectively allow access by only defining allowed sites in /etc/hosts (or netinfo's /machines directory more ideally)...
     
Grizzled Veteran
Join Date: Sep 2000
Location: New Jersey, USA
Status: Offline
Reply With Quote
Apr 12, 2004, 07:54 AM
 
so are we saying that adding 127.0.0.1 whatever.com for said sites will block their appearance?
Dual 2.0 G5/2.5GB/ATI 9800 Pro | MacBook Pro 2.16 Gore Duo/2GB/ATI X1600
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 12, 2004, 11:24 AM
 
No, that's not what I said.

By default, OS X has lookupd to get info from NetInfo, not from flat files, unless you change the lookupd configuration.

If you want to block sites, you need to add a rule to IPFW.

ipfw add deny tcp from <blocked.domain> to any

etc, etc....

ipfw is what blocks sites. /etc/hosts is for name resolution
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Dec 1999
Location: Plainview, NY
Status: Offline
Reply With Quote
Apr 12, 2004, 09:01 PM
 
Originally posted by mrchin:
so are we saying that adding 127.0.0.1 whatever.com for said sites will block their appearance?
your syntax is not correct, but yes, that's why there are lists of ad servers pre-mapped to 127.0.0.1 that one can download and import. i run one, for example, and imported it into netinfo.

http://www.macwrite.com/criticalmass...ts-panther.php
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 13, 2004, 12:45 AM
 
I still don't get why you would bastardize lookupd when ipfw is the tool designed for that purpose....

(and that syntax is correct)

address hostname1 hostname2 alias1 alias2, etc
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Elite
Join Date: Dec 1999
Location: Plainview, NY
Status: Offline
Reply With Quote
Apr 13, 2004, 01:48 AM
 
Originally posted by Kristoff:
I still don't get why you would bastardize lookupd when ipfw is the tool designed for that purpose....

(and that syntax is correct)

address hostname1 hostname2 alias1 alias2, etc
ah, so it is. i had it in my head that it was backwards

anyway, using host files to combat ads is common because others take the time to craft and populate host files for the lazy amongst us, namely me. then i download them, import them into netinfo, and enjoy the result.
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 13, 2004, 06:59 PM
 
but, you could just as easily download an IPFW ruleset and thereby use the proper application (a firewall).

But, whatever lifts your skirt.
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Apr 21, 2004, 01:47 PM
 
Originally posted by mrchin:
so are we saying that adding 127.0.0.1 whatever.com for said sites will block their appearance?
Essentially, yes. 127.0.0.1 maps to the IP address of your own machine. So, when a web page asks for an ad from ads.server.com, your hosts file would tell your browser to get it from your own machine. Since your machine does not have that ad on it, the ad will not appear. It's not really the way it was intended to work, but it gets the job done.

Incidentally, this is a good joke to play on someone. If you know their homepage is listed as my.yahoo.com, for example, you can map requests for my.yahoo.com to go to www.microsoft.com or something. They won't know what happened...
Scott Genevish
scott AT genevish DOT org
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Apr 21, 2004, 02:25 PM
 
Why would you associate with people who would let you have unfettered access to anything in their /etc directory?
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Fresh-Faced Recruit
Join Date: Jul 2004
Status: Offline
Reply With Quote
Apr 11, 2005, 07:58 PM
 
Originally posted by Kristoff:
Why would you associate with people who would let you have unfettered access to anything in their /etc directory?
good point.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:24 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2