User Name
Password
AppleNova Forums » Genius Bar »

Modifying hosts file...please help.


Register Members List Calendar Search FAQ Posting Guidelines
Modifying hosts file...please help.
Thread Tools
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2005-02-05, 13:40

So I did a search and found an old thread I remembered that had directions for modifying the hosts file. I downloaded a modified hosts file that CubeDude linked to in this thread. I added a few specific URLs to the file, then followed the directions that Brad gave, replaced the old hosts file with the modified one, ran "lookupd -flushcache" in Terminal, and nothing seems to have happened. There are still ads on all the pages I go to and I can still access the sites that I added to the file myself. What am I doing wrong?
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-02-05, 13:42

Quit and relaunch your browser.

That's a step that I often forget too.
  quote
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2005-02-05, 13:51

Unfortunately, it's not so simple as that. First, I was logged in as root to change the file, so I've logged out and back in in my regular account and I've quit and reopened the browser a couple of times. It's possible that the ads I'm seeing are coming from servers that aren't on the list, since I've noticed a couple of missing image icons on pages, but if that's the case, PithHelmet did a much better job blocking ads and I'll go back to that. Of course that still doesn't explain why I can still get to sites I added myself. I put in lines to match all the others that were there, i.e. "127.0.0.1 nameofsite.com" but going to nameofsite.com works just fine.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-02-05, 13:59

Use used the root user?! Well, there's your problem! Logging in as the room user can futz up all kinds of things, especially in the Finder. Repair permissions! Zap the PRAM! Defrag your hard drive! And recompile your kernel!



No, you don't need to do all that, but using root in the GUI is a very bad idea and can cause unexpected problems, especially in the Finder.

Okay, now that that's said and done:

Fire up Terminal and show us what this command gives you:
lookupd -configuration

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2005-02-05, 16:28

First off, FMI (for my information), how would have modified the file without logging in as root? I tried doing it through my own administrator account, but couldn't save (as I expected). I still know relatively little about working in a CLI.

Second off, lookupd -configuration gives the following:
ConfigSource: default
LookupOrder: Cache NI DS
MaxIdleServers: 4
MaxIdleThreads: 2
MaxThreads: 64
TimeToLive: 43200
Timeout: 30
ValidateCache: YES
ValidationLatency: 15
_config_name: Global Configuration

LookupOrder: Cache FF DNS NI DS
_config_name: Host Configuration

LookupOrder: Cache FF NI DS
_config_name: Service Configuration

LookupOrder: Cache FF NI DS
_config_name: Protocol Configuration

LookupOrder: Cache FF NI DS
_config_name: Rpc Configuration

TimeToLive: 60
ValidateCache: NO
_config_name: Group Configuration

TimeToLive: 300
ValidateCache: NO
_config_name: Initgroup Configuration

LookupOrder: Cache FF DNS NI DS
_config_name: Network Configuration

EDIT: I know working in root can be risky, so I am always careful to do only what I came to do (not that I log in as root very often; only occasionally).
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-02-06, 01:53

Hmm. That is odd indeed. Everything appears to be in the correct order.

How did you create the hosts file? TextEdit? Get info on the file and make sure it isn't retaining the .txt extension.

To modify the file without using root or the Terminal, simply navigate to /etc in the Finder (Go -> Go to Folder...), drag the file to your desktop (it'll make a copy), edit it and save it, drag it back into /etc while holding the option key. This will copy it back, asking you to authenticate.

There's always a way to get things done without resorting to the root user. All you have to do is ask.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
SledgeHammer
Senior Member
 
Join Date: May 2004
 
2005-02-06, 10:20

Well, thanks for the help. I'm not sure what the deal is. At first it was reading the .txt extension, but I figured that out and fixed it. Didn't seem to make a difference though. Oh well. I guess I'll just go back to Pith Helmet...maybe try this again some other time.
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-02-06, 13:13

Pfft. Don't think that I give up that easily! E-mail me your file. brad@applenova.com
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2005-02-07, 11:37

Check your e-mail.
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2005-02-07, 14:21

Quote:
Originally Posted by Brad
Pfft. Don't think that I give up that easily! E-mail me your file. brad@applenova.com
I guess with most emails you aren't so lucky as to be the first one to pick 'brad' as the user

Now ast3r3x...RARELY is that taken
  quote
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2007-12-25, 11:12

Bump!

So I'm trying to update my hosts file in Leopard and now it just doesn't seem to be working at all. I should have left it alone after upgrading but I have been seeing to many ads left over. So I went to edit my hosts.txt file and found most of the ads I wanted to block were listed in my hosts files already.

There were two hosts files in my /etc folder and so I deleted the one that was empty. I ended up having to change the permission so that everyone had read only access I also added Administrators to the list with read only access.

Well then to the next step of running "lookupd -flushcache" from Terminal but I get a message back saying: -bash: lookupd: command not found So did Apple change the commands in Terminal?

What am I missing? Now none of my ads are being blocked. I've tried rebooting and still nothing.

Leopard 10.5.1, MB CD 2GHz

Louis L'Amour, “To make democracy work, we must be a nation of participants, not simply observers. One who does not vote has no right to complain.”
Visit our archived Minecraft world! | Maybe someday I'll proof read, until then deal with it.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2007-12-25, 11:28

Quote:
Originally Posted by turtle2472 View Post
Well then to the next step of running "lookupd -flushcache" from Terminal but I get a message back saying: -bash: lookupd: command not found So did Apple change the commands in Terminal?
Yes.

Code:
dscacheutil -flushcache
  quote
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2007-12-25, 11:45

Thanks!

Now my ads are all blocked again but they all have an error message instead of just being blank.
Quote:
Not Found

The requested URL /servlet/ajrotator/7441/932/viewHTML was not found on this server.
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2007-12-25, 11:48

Quote:
Originally Posted by turtle2472 View Post
Thanks!

Now my ads are all blocked again but they all have an error message instead of just being blank.
Are you running a local web server?
  quote
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2007-12-25, 14:42

Not at this house. I'm at my mom's now and there is no server or anything here. I don't even have the web sharing turned on on this MB either.

Louis L'Amour, “To make democracy work, we must be a nation of participants, not simply observers. One who does not vote has no right to complain.”
Visit our archived Minecraft world! | Maybe someday I'll proof read, until then deal with it.
  quote
Ryan
Veteran Member
 
Join Date: May 2004
Location: Promise Land of Trustafarians
 
2007-12-25, 15:32

Quote:
Originally Posted by turtle2472 View Post
Not at this house. I'm at my mom's now and there is no server or anything here. I don't even have the web sharing turned on on this MB either.
Is the hosts file set to send adservers to 0.0.0.0 or 127.0.0.1?

Either way, you might try turning the webserver on your MacBook on and setting the .htaccess file to send an empty string of text in place of a 404 error. Be sure to set the firewall to block incoming requests to port 80.
  quote
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2007-12-25, 19:27

Quote:
Originally Posted by Ryan View Post
Is the hosts file set to send adservers to 0.0.0.0 or 127.0.0.1?

Either way, you might try turning the webserver on your MacBook on and setting the .htaccess file to send an empty string of text in place of a 404 error. Be sure to set the firewall to block incoming requests to port 80.
I'll try turning on the web server. Here's a snippet of my hosts file:
Quote:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
#
# Reminder from Brad:
# on 10.3 and up, run "lookupd -flushcache" after making changes
#
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# begin the blockage!
0.0.0.0 www.doubleclick.net
0.0.0.0 ad.doubleclick.net #remove this for atomfilms problems
0.0.0.0 ad.preferences.com
0.0.0.0 ads.doubleclick.com
Edit: turns out the issue is because my web server was on and I needed to turn it off. This isn't an issue on my Mini though. Is this because of changes in Leopard?

Louis L'Amour, “To make democracy work, we must be a nation of participants, not simply observers. One who does not vote has no right to complain.”
Visit our archived Minecraft world! | Maybe someday I'll proof read, until then deal with it.
  quote
turtle
Lord of the Rant.
Formerly turtle2472
 
Join Date: Mar 2005
Location: Upstate South Carolina
 
2008-04-12, 23:08

Any new updated hosts files out there? Just want to update mine and thought I'd check for anyone who keeps theirs more updated than I have.
  quote
dmegatool
Custom User Title
 
Join Date: Jul 2006
Location: At home
 
2008-05-07, 20:07

Bump !
Hey guys I want to block a site. I want to block www.MySite.com so I edited the host file and it works. The problem is that I can use a link like www.MySite.com/FuckYouHostFile.html to acces the site

Edit: Wuh !?!? It's working now. I played a little bit with it and then, wanted to make it as it was. And now it works. The only difference is that I added www.MySite.com instead of MySite.com in the host file. Rep point for me !

Dave Mustaine :"God created whammy bars for people who don't know how to solo."
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2008-05-07, 21:54

Quote:
Originally Posted by dmegatool View Post
It's working now. I played a little bit with it and then, wanted to make it as it was. And now it works. The only difference is that I added www.MySite.com instead of MySite.com in the host file.
You need to add an entry for every sub-domain to block. You can't do wildcard matches in the hosts file.

For example, to block some ad servers, you have to block a slew of domains like this:

Code:
0.0.0.0 adserver.com 0.0.0.0 images.adserver.com 0.0.0.0 a1.adserver.com 0.0.0.0 a2.adserver.com 0.0.0.0 a3.adserver.com 0.0.0.0 a4.adserver.com 0.0.0.0 a5.adserver.com
Alternatively, you can put many domains on a single line:

Code:
0.0.0.0 adserver.com images.adserver.com a1.adserver.com a2.adserver.com
...and so forth.

The quality of this board depends on the quality of the posts. The only way to guarantee thoughtful, informative discussion is to write thoughtful, informative posts. AppleNova is not a real-time chat forum. You have time to compose messages and edit them before and after posting.
  quote
Banana
is the next Chiquita
 
Join Date: Feb 2005
 
2008-05-07, 22:59

Out of curiosity, is there a particular reason for not incorporating support for wildcard match in hosts file?
  quote
Brad
Selfish Heathen
 
Join Date: May 2004
Location: Zone of Pain
 
2008-05-07, 23:28

Short of being consistent with how other systems do it, I have no idea.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP : loading a multi-dimensional file with a loop drewprops Genius Bar 6 2005-02-03 23:05
Modified Hosts File? SledgeHammer General Discussion 1 2005-02-02 20:34
CSI: htaccess file drewprops Genius Bar 3 2004-09-21 15:52
iView MediaPro and the file system chucker Genius Bar 0 2004-09-05 13:24
Different file systems with OS X... Purgatos General Discussion 13 2004-08-15 12:48


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 05:57.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova