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 > where is 'hosts' file ?

where is 'hosts' file ?
Thread Tools
Forum Regular
Join Date: Oct 2004
Location: Pune, India
Status: Offline
Reply With Quote
Jul 27, 2005, 04:05 AM
 
Is there a file similat to hosts file on Windows? What is the location on OS X?
MacbookPro, iPhone 4S, iPod Touch, iPad 2
     
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Jul 27, 2005, 04:42 AM
 
According to what I have read, lookupd (launchd in Tiger) is configured to reference etc/hosts before going elsewhere, so you can go ahead and edit it as you would on any other 'NIX system. You'll probably also want to take a look at the man page for lookupd.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
Dedicated MacNNer
Join Date: Jan 2005
Location: Under Your Stairs
Status: Offline
Reply With Quote
Jul 27, 2005, 06:59 AM
 
Yes, /etc/hosts works the same as with windows.
Sieb
Blackbook
(2Ghz, 2GB, 100Gig, week 21)
     
Professional Poster
Join Date: Oct 1999
Location: :ИOITAↃO⅃
Status: Offline
Reply With Quote
Jul 27, 2005, 08:12 AM
 
Gah! Mac OS X's predecessors had an /etc/hosts file long before Windows did. So it's more like Windows now has a hosts file similar to that of OS X.

Read: A Brief History of the Internet
The Internet began in the late 1960s as an experimental wide area computer network funded by the Department of Defense's Advanced Research Projects Agency (ARPA). This network, called ARPAnet, was intended to allow government scientists and engineers to share expensive computing resources. During this period, only government users and a handful of computers were ever connected to ARPAnet. It remained that way until the early 1980s.

In the early 1980s, two main developments led to the popularization of ARPAnet. The first was the development of the Transmission Control Protocol and the Internet Protocol (TCP/IP). TCP/IP standardized connectivity to ARPAnet for all computers. The second was U.C. Berkeley's version of UNIX, known as BSD, which was the first UNIX distribution to include TCP/IP as a networking layer. Because BSD was available to other universities at minimal cost, the number of computers connecting to ARPAnet soared.
BSD, of course, is the underbelly of OS X. So OS X's roots go back to the very origins of the Internet in the early 1980s.

In the early days, when there were only a few hundred computers connected to ARPAnet, every computer had a file called hosts.txt. UNIX modified the name to /etc/hosts. This file contained all the information about every host on the network, including the name-to-address mapping. With so few computers, the file was small and could be maintained easily.

The maintenance of the hosts.txt file was the responsibility of SRI-NIC, located at the Stanford Research Institute in Menlo Park, California. When administrators wanted a change to the hosts.txt file, they emailed the request to SRI-NIC, which incorporated the requests, once or twice a week. This meant that the administrators also had to periodically compare their hosts.txt files, against the SRI-NIC hosts.txt file and, if the files were different, the administrators had to FTP a new copy of the file.

As the Internet started to grow, the idea of centrally administering hostnames and deploying the hosts.txt file became a major issue. Every time a new host was added, a change had to be made to the central version and every other host on ARPAnet had to get the new version of the file.

In the early 1980s, SRI-NIC called for the design of a distributed database to replace the hosts.txt file. The new system was known as the Domain Name System (DNS). ARPAnet switched to DNS in September 1984, and it has been the standard method for publishing and retrieving hostname information on the Internet ever since.
i.e. for the early BSD machines connected to the Internet, the /etc/hosts file was the Internet. If a machine wasn't in your /etc/hosts, you had no way to know about it.

Microsoft did not built TCP/IP networking into Windows until Windows 95, a good 12 years after OS X's forebears.

And of course, it was Tim Berners Lee in 1990, working on a NeXT machine -- OS X's direct parent -- who invented the URL, HTML, and the web browser.



-----
Anyway, yeah, you can edit /etc/hosts with something like TextWrangler, or by typing sudo pico /etc/hosts in the Terminal.
(Last edited by Mithras; Jul 27, 2005 at 08:33 AM. )
     
Clinically Insane
Join Date: Nov 1999
Status: Offline
Reply With Quote
Jul 27, 2005, 08:30 AM
 
The hosts file concept began long ago, as a part of Unix. Microsoft copied BSD's TCP/IP stack wholesale when they implemented TCP/IP for Windows (seriously; they lifted the code outright), and they took this concept with them. The two operating systems use exactly the same file format (and I suspect the same code). OSX puts it in /etc/hosts like other Unices do. Windows puts it in a different location: for NT-based versions it's in c: \windows\system32\drivers\etc\hosts (note that it has no filename extension; this is just like the BSD naming convention, but it can make editing the file problematic).

OS9 also had a kind of Hosts file, but it didn't use the BSD-style format. Instead it used the BIND format, which is normally used to define hostnames in DNS servers. This format isn't exactly nonstandard, but is more of a pain to work with. The OS9 file also had no standard location; you had to set it in the TCP/IP control panel.

By the way, if you're working with a version of OSX earlier than 10.4, please let us know. If you are, then there's one extra step you need to take before the hosts file will work properly (though you only need to do it once). Tiger fixed this issue, so it's not a concern if you have that OS.
You are in Soviet Russia. It is dark. Grue is likely to be eaten by YOU!
     
Clinically Insane
Join Date: Oct 2000
Location: Los Angeles
Status: Offline
Reply With Quote
Jul 27, 2005, 11:31 AM
 
Originally Posted by Millennium
By the way, if you're working with a version of OSX earlier than 10.4, please let us know. If you are, then there's one extra step you need to take before the hosts file will work properly (though you only need to do it once). Tiger fixed this issue, so it's not a concern if you have that OS.
His sig indicates he's running Panther.

"The natural progress of things is for liberty to yield and government to gain ground." TJ
     
   
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 07:53 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