HOSTS File
Overview
The “Hosts” file in Windows and other operating systems is used to associate host names with IP addresses.
This method is one of several methods used by an operating system to locate network nodes on a computer network. On many operating systems, the host file content is used preferentially over other methods, such as the Domain Name System (DNS). Unlike DNS, the hosts file is under the control of the local computer’s administrator.
Locations
Windows XP, Vista and Windows 7
/windows/system32/drivers/etc/
Linux
/etc/
Mac OS (Mac OS X 10.2 or later)
/private/etc/
Mac OS (Mac OS X 10.0 through 10.1.5)
01. Open /Applications/Utilities/NetInfo Manager.
02. To allow editing the NetInfo database, click the padlock in the lower left corner of the window.
03. Enter your Admin password and click OK.
04. In the second column of the browser view, select the node named “machines.” You will see entries for -DHCP-, broadcasthost, and localhost in the third column.
05. The quickest way to create a new entry is to duplicate an existing one. So select the “localhost” item in the third column.
06. Choose Duplicate from the Edit menu. A confirmation alert appears.
07. Click Duplicate. A new entry called “localhost copy” appears, and its properties are shown below the browser view.
08. Double-click the value of the ip_address property and enter the IP address of the other computer.
09. Double-click the value of the name property and enter the hostname you want for the other computer.
10. Click the serves property and choose Delete from the Edit menu.
11. Choose Save from the File menu. A confirmation alert appears.
12. Click Update this copy.
13. Repeat steps 6 through 12 for each additional host entry you wish to add.
14. Choose Quit from the NetInfo Manager menu. You do not need to restart the computer
Example Hosts file (Windows)
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
Editing the HOSTS file
Linux
Now make sure this file is used for host name lookups. This is done in two files. First is:
/etc/host.conf
This file should have at least the line shown below:
order hosts,bind
That has host lookups use the hosts file before doing a DNS query with bind.
The next file is:
/etc/nsswitch.conf
Recent tests indicate that this file is required in order for the pserver to use the entry in /etc/hosts. The nsswitch.conf file should have this line for the hosts configuration:
hosts: files nisplus nis dns
There will probably already be a similar line in your version of this file. Just make sure “files” comes before whatever other methods are listed.
Vista
Non-frequent Edit
1. Open Notepad with Administrative privileges by clicking Start, All Programs, Accessories, and then right-click Notepad and select to open as Administrator.
2. Now that Notepad is open with Administrative privileges browse to (C:\Windows\System32\drivers\etc) in Notepad and open the hosts file. Now you can edit and save the hosts file.
Related Posts
| Print article | This entry was posted by PB on December 21, 2009 at 05:35, and is filed under DNS. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |