How to Use the Hosts File
You can use the Hosts file as another name resolution method. You might do this if you know that your DNS server is unavailable or the database is out of date, you need to access a server, and you know the server's IP address. It's also useful when you've recently installed a new server and you want to contact it using a host name before the DNS database is updated.
Although you can typically contact servers using their IP addresses, Web sites often need to be reached using the correct host name, and IP addresses might not work.
Your Hosts file is located at %WinDir%\System32\Drivers\Etc\Hosts. It is a text file, and you can edit it using Notepad. To open the Hosts file, run Notepad using administrative permissions. Then, open the Notepad %WinDir%\System32\Drivers\Etc\Hosts file (it does not have a file extension). To add an entry to the Hosts file to enable name resolution without using DNS, add lines to the bottom of the Hosts file, as demonstrated here for IPv4 and IPv6 addresses.
After updating the Hosts file, you can contact servers by using the host name. When an entry is in the Hosts file, Windows will use the associated IP address without contacting a DNS server. In fact, the only application that bypasses the Hosts file is Nslookup, which always contacts DNS servers directly. Remember to remove entries from the Hosts file after you finish using them; otherwise, you might have name resolution problems later if the server's IP address changes.
In this tutorial:
- Troubleshooting Network Issues
- Tools for Troubleshooting
- Table-1 Network Troubleshooting Tools
- Arp
- How to Identify a Problem with the ARP Cacher
- How to Clear the ARP Cache
- Event Viewer
- IPConfig
- Nblookup
- Nbtstat
- Net
- How to View Shared Folders on the Local Computer
- How to View Shared Folders on Another Computer
- Netstat
- Network Monitor
- Nslookup
- Verifying that the Default DNS Server Resolves Correctly
- Verifying that a Specific DNS Server Resolves Correctly
- Verifying Specific Types of Addresses
- Using TCP for DNS Lookups
- PathPing
- PathPing Output
- Routing Loops
- Performance Problems
- Possible Connectivity Issues
- No Connectivity Issues
- Performance Monitor
- Data Collector Sets
- Windows Resource Monitor
- Ping
- PortQry
- Identifying the TCP Port for a Service
- Windows 7 Testing Service Connectivity
- Determining Available Remote Management Protocols
- Why PortQry Is Great
- Route
- Task Manager
- TCPView
- Telnet Client
- Testing Service Connectivity
- Test TCP
- Windows Network Diagnostics
- The Process of Troubleshooting Network Problems
- How to Troubleshoot Network Connectivity Problems
- How to Troubleshoot Application Connectivity Problems
- Default Port Assignments for Common Services and Tasks
- How to Troubleshoot Name Resolution Problems
- How to Verify Connectivity to a DNS Server
- How to Use the Hosts File
- How to Troubleshoot Performance Problems and Intermittent Connectivity Issues
- How to Troubleshoot Joining or Logging on to a Domain
- How to Verify Requirements for Joining a Domain
- How to Troubleshoot Network Discovery
- How to Troubleshoot File and Printer Sharing
- How to Troubleshoot File and Printer Sharing from the Client
- How to Troubleshoot File and Printer Sharing from the Server
- How to Troubleshoot Wireless Networks
- Network Diagnostics
- How to Troubleshoot Firewall Problems