 |
 |
Does OSX have a hosts file?
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2004
Status:
Offline
|
|
Does OSX have something like the Windows hosts file that you can modify to block ads?
|
|
12.1" Powerbook G4
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2003
Location: Minnesota
Status:
Offline
|
|
Is /etc/hosts what you are looking for?
You can edit it by going to the terminal and entering
pico /etc/hosts
CTRL-O saves
CTRL-X quits
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Nov 2001
Location: Trafalmadore
Status:
Offline
|
|
If you are using Safari considering using PithHelmet to block ads.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
Or the built-in add blocking in OmniWeb, or the nice little AddBlocker Extension in FireFox...
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
LOL.....
"something like the Windows hosts file"...
That is so rich! What a ham!
Dude, the hosts file on Unix systems dates back to the 70s...long before there was a Microsoft.
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Dec 2000
Status:
Offline
|
|
It is kind of weird that the OS X Network pane doesn't seem to have support for adding a hosts file via the GUI, when the OS 9 one did, though.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2001
Location: Sitting in front of computer
Status:
Offline
|
|
I took a look at my hosts file and saw this in it
##
# Host Database
#
# Note that this file is consulted when the system is running in single-user
# mode. At other times this information is handled by lookupd. By default,
# lookupd gets information from NetInfo, so this file will not be consulted
# unless you have changed lookupd's configuration.
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
I read this as you need to use NetInfo not edit the Hosts file.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
Yeah...using NetInfo is really easy.
Fire up the NetInfo Manager and click on the "Machines" node.
Click "New" and add a property called ip_address where you put the ip, and a property called name which can be multivalued and has the name(s) you want that ip to resolve to.
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Feb 2004
Status:
Offline
|
|
Originally posted by Kristoff:
LOL.....
"something like the Windows hosts file"...
That is so rich! What a ham!
Dude, the hosts file on Unix systems dates back to the 70s...long before there was a Microsoft.
Sorry "dude" we are not all computer historians like yourself 
|
|
12.1" Powerbook G4
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Mar 2000
Location: New York, NY, USA
Status:
Offline
|
|
Originally posted by Terri:
I took a look at my hosts file and saw this in it
##
# Host Database
#
# Note that this file is consulted when the system is running in single-user
# mode. At other times this information is handled by lookupd. By default,
# lookupd gets information from NetInfo, so this file will not be consulted
# unless you have changed lookupd's configuration.
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
I read this as you need to use NetInfo not edit the Hosts file.
Nope. /etc/hosts works just fine. Apple is moving OS X away from Netinfo and towards standard Unix, like /etc/hosts.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: May 2004
Location: norway
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
Truth be told, CSS-based blocking really is better. Aside from allowing for more control over what is displayed, the browser will still download the ad, so it will usually still count as an impression. This ensures that the site displaying the ads doesn't get hurt, though the ad company does since the statistics aren't as valid.
Ahem. The /etc/hosts file in OSX does not work by default, except at bootup (the responsibility is then handed over to NetInfo). However, there is a way to turn it back on, though it requires a fair bit of Terminal hackery.
WHAT TO DO:
Most of the following will require you to use sudo in the Terminal. If it asks for a password, give it your own password. You should be able to paste this into the Terminal.
Code:
sudo mkdir /etc/lookupd
sudo echo "LookupOrder Cache FF DNS NI" > /etc/lookupd/hosts
WHAT THIS DOES:
The first line makes a directory called /etc/lookupd, which is where the machine will look for the file you're about to create. This is in the hidden directory /etc, so it too will be hidden.
The second line creates a file /etc/lookupd/hosts, and puts the single line "LookupOrder Cache FF DNS NI" into it. You could have done this with any text editor (though you'd have to use sudo), but since there's only one line in the file this gets it over with in a single command.
Do NOT confuse /etc/lookupd/hosts with /etc/hosts. /etc/lookupd/hosts exists only to tell the machine what order to look up DNS hostnames in.
HOW IT WORKS:
"Cache FF DNS NI" causes the machine to first look in the list of DNS names it has looked up recently through other means; that's what "Cache" is. "FF" stands for Flat File; in other words, /etc/hosts; that's the next place it looks. "DNS" is the usual hostname server scheme; it takes third priority. "NI" is NetInfo; the last place it will look, only after it hasn't found the name elsewhere.
In any case, once you've done this, you can use /etc/hosts normally. The syntax is exactly like it was on Windows (which, given that Windows stole it from BSD, should come as no surprise).
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Don Pickett:
Nope. /etc/hosts works just fine. Apple is moving OS X away from Netinfo and towards standard Unix, like /etc/hosts.
I'm sorry, but this is just bollocks.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Mar 2000
Location: New York, NY, USA
Status:
Offline
|
|
Originally posted by Angus_D:
I'm sorry, but this is just bollocks.
Well, considering that every site I've put into /etc/hosts gets blocked, looks like it works just fine to me. And Apple is moving away from Netinfo, but, as I'm not on an OS X machine right now, I can't tell you where to look to see the proof.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
The only reason /etc/hosts works is because that's how lookupd is configured --which is done through NetInfo. And the only reason it's configured that way is because so many people complained that /etc/hosts didn't work--without bothering to read how to do it via NetInfo.
lookupd is configured in NetInfo via
/locations/hosts/LookupOrder
and can have any combination of: CacheAgent, FileAgent (/etc/hosts), NIAgent (NetInfo), DNSAgent, NullAgent where the order determines precedence.
In the current version of lookupd on OSX, I believe the order is hardcoded as FileAgent, CacheAgent, NIAgent, DNSAgent --which means that there wont be a node in NetInfo unless you add one--thereby changing the defaults.
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Mar 2000
Location: New York, NY, USA
Status:
Offline
|
|
Originally posted by Kristoff:
The only reason /etc/hosts works is because that's how lookupd is configured --which is done through NetInfo. And the only reason it's configured that way is because so many people complained that /etc/hosts didn't work--without bothering to read how to do it via NetInfo.
lookupd is configured in NetInfo via
/locations/hosts/LookupOrder
and can have any combination of: CacheAgent, FileAgent (/etc/hosts), NIAgent (NetInfo), DNSAgent, NullAgent where the order determines precedence.
In the current version of lookupd on OSX, I believe the order is hardcoded as FileAgent, CacheAgent, NIAgent, DNSAgent --which means that there wont be a node in NetInfo unless you add one--thereby changing the defaults.
This is what I meant when I said Apple is starting to deprecate Netinfo. It started in 10.2, and has continued.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
Originally posted by Don Pickett:
This is what I meant when I said Apple is starting to deprecate Netinfo. It started in 10.2, and has continued.
They are starting to deprecate NetInfo, but it's not entirely for the flat-file standards used by Unix. For example, last I heard the user database is going to be replaced by LDAP, a Unix standard in its own right but not the most common default.
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jun 2002
Location: UK
Status:
Offline
|
|
Code:
sudo mkdir /etc/lookupd
sudo echo "LookupOrder Cache FF DNS NI" > /etc/lookupd/hosts
You should really use >> /etc/lookupd/hosts or something because many people already HAVE hosts file and your method would overwrite it. and that's BAD!
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Nov 1999
Status:
Offline
|
|
Originally posted by VEGAN:
You should really use >> /etc/lookupd/hosts or something because many people already HAVE hosts file and your method would overwrite it. and that's BAD!
Fewer than you might think. Remember, this is /etc/lookupd/hosts, not /etc/hosts; they're very different files. The /etc/lookupd folder has never existed on OSX by default, so it cannot be there unless the user has already put it there, and the only reason to do this of which I'm aware is to enable exactly what I'm talking about.
However, you're right; using >> would have been safer. My apologies.
|
|
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Millennium:
They are starting to deprecate NetInfo, but it's not entirely for the flat-file standards used by Unix. For example, last I heard the user database is going to be replaced by LDAP, a Unix standard in its own right but not the most common default.
NetInfo is indeed generally not recommended for use for various reasons, and Apple is moving towards harmonising on their Open Directory abstraction type thingy, with OS X Server having LDAP stuff. However I certainly wouldn't expect lookupd to go away any time soon.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Don Pickett:
This is what I meant when I said Apple is starting to deprecate Netinfo. It started in 10.2, and has continued.
lookupd has been used since OS X began, and you have always been able to rearrange the agents, so I don't really understand what you mean...
And anyway, they certainly won't be moving to flat files. That would be a huge step BACKWARDS in functionality/flexibility.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Mar 2000
Location: New York, NY, USA
Status:
Offline
|
|
Originally posted by Angus_D:
lookupd has been used since OS X began, and you have always been able to rearrange the agents, so I don't really understand what you mean...
And anyway, they certainly won't be moving to flat files. That would be a huge step BACKWARDS in functionality/flexibility.
They're not moving to flat files, but they are making it easier for people used to other Unices to move to OS X, especially on the server end, by enabling /etc/hosts by default, etc. They would rather people use OS X server as they are used to using other Unices and then get seduced by the goodness underneath than be turned away by having to learn new tech off the bat.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Don Pickett:
They're not moving to flat files, but they are making it easier for people used to other Unices to move to OS X, especially on the server end, by enabling /etc/hosts by default, etc. They would rather people use OS X server as they are used to using other Unices and then get seduced by the goodness underneath than be turned away by having to learn new tech off the bat.
Right, OK, but that's not what you said. 
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Mar 2000
Location: New York, NY, USA
Status:
Offline
|
|
Originally posted by Angus_D:
Right, OK, but that's not what you said.
I said, "Apple is moving away from Netinfo," and I stand by it. There are making OS X look and act more like other Unices.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Apr 2001
Location: 127.0.0.1
Status:
Offline
|
|
Originally posted by Don Pickett:
I said, "Apple is moving away from Netinfo," and I stand by it. There are making OS X look and act more like other Unices.
Heheh... looking at some of my friends Linux boxes around here, I'd have to say the other Unices are being made to look and act more like OS X. 
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Originally posted by Don Pickett:
I said, "Apple is moving away from Netinfo," and I stand by it. There are making OS X look and act more like other Unices.
No, what you said was:
Originally posted by Don Pickett:
Nope. /etc/hosts works just fine. Apple is moving OS X away from Netinfo and towards standard Unix, like /etc/hosts.
They are not moving towards "standard Unix" like flat files. They are also not moving towards "standard Unix" in general, they are developing new technologies like System Configuration, Open Directory, etc, which are more flexible and future-proof than "standard Unix".
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|