Difference between revisions of "Hosts file"

From TheAlmightyGuru
Jump to: navigation, search
m (moved Host File to Hosts File)
Line 1: Line 1:
A '''''hosts file''''' is a simple text file used by the network to cross-reference an IP address with a URL ''before'' attempting to connect to a DNS server.
+
A '''''hosts file''''' is a simple text file used by a computer to cross-reference an IP address with a URL ''before'' attempting to connect to a DNS server.
  
They exist on most operating systems with the same format IP whitespace URL:
+
They exist on most operating systems with the same two fields separated by whitespace, first the IP address, then the replacement URL. For example:
  
 
  74.125.225.66    google.com
 
  74.125.225.66    google.com
Line 9: Line 9:
  
 
* Direct a URL to an IP address when you don't have access to a DNS server
 
* Direct a URL to an IP address when you don't have access to a DNS server
* Reroute a URLs to an IP address different from your DNS server.
+
* Reroute URLs to an IP address different from your DNS server.
 
* Block access to a particular URL.
 
* Block access to a particular URL.
  
Line 15: Line 15:
 
Here are examples of each of the following uses:
 
Here are examples of each of the following uses:
  
The following entry will direct thisurldoesnotexist.com (which doesn't exist) to 1.1.1.1.
+
The following entry will direct someone trying to get to thisurldoesnotexist.com (which doesn't exist) to Google's IP address, 172.217.6.110.
  1.1.1.1     thisurldoesnotexist.com
+
  172.217.6.110     thisurldoesnotexist.com
  
The following entry will redirect all traffic intended to go to facebook.com to google.com.
+
The following entry will redirect all traffic intended to go to facebook.com to the IP address 104.16.77.187, which is the FBI's web site.
  74.125.225.66     facebook.com
+
  104.16.77.187     facebook.com
  
 
The following entry will block all traffic to facebook.com by rerouting it to the local computer.
 
The following entry will block all traffic to facebook.com by rerouting it to the local computer.
Line 27: Line 27:
 
The file is located in different locations for different operating systems.
 
The file is located in different locations for different operating systems.
  
{|
+
{| class="wikitable" |
 +
! Operating System
 +
! Path
 +
|-
 
| '''Windows XP/Vista/7'''  
 
| '''Windows XP/Vista/7'''  
 
| \windows\system32\drivers\etc\hosts
 
| \windows\system32\drivers\etc\hosts
Line 37: Line 40:
 
| /etc/hosts
 
| /etc/hosts
 
|}
 
|}
 +
 +
==Links==
 +
* [https://en.wikipedia.org/wiki/Hosts_(file) en.wikipedia.org/wiki/Hosts_(file)] - Wikipedia.
 +
 +
 +
[[Category: Tech Guides]]

Revision as of 16:21, 1 August 2017

A hosts file is a simple text file used by a computer to cross-reference an IP address with a URL before attempting to connect to a DNS server.

They exist on most operating systems with the same two fields separated by whitespace, first the IP address, then the replacement URL. For example:

74.125.225.66     google.com

Uses

The hosts file has many uses including:

  • Direct a URL to an IP address when you don't have access to a DNS server
  • Reroute URLs to an IP address different from your DNS server.
  • Block access to a particular URL.

Examples

Here are examples of each of the following uses:

The following entry will direct someone trying to get to thisurldoesnotexist.com (which doesn't exist) to Google's IP address, 172.217.6.110.

172.217.6.110     thisurldoesnotexist.com

The following entry will redirect all traffic intended to go to facebook.com to the IP address 104.16.77.187, which is the FBI's web site.

104.16.77.187     facebook.com

The following entry will block all traffic to facebook.com by rerouting it to the local computer.

127.0.0.1     facebook.com

Locations

The file is located in different locations for different operating systems.

Operating System Path
Windows XP/Vista/7 \windows\system32\drivers\etc\hosts
Linux /etc/hosts
OS X /etc/hosts

Links