Difference between revisions of "Hosts file"

From TheAlmightyGuru
Jump to: navigation, search
(Examples)
(Locations)
Line 31: Line 31:
 
! Path
 
! Path
 
|-
 
|-
| '''Android'''
+
| '''[[Android]]'''
 
| /system/etc/hosts
 
| /system/etc/hosts
 
|-
 
|-
| '''iOS'''
+
| '''[[iOS]]'''
 
| /private/etc/hosts
 
| /private/etc/hosts
 
|-
 
|-
| '''Linux'''
+
| '''[[Linux]]'''
 
| /etc/hosts
 
| /etc/hosts
 
|-
 
|-
| '''OS X'''
+
| '''[[OS X]]'''
 
| /private/etc/hosts
 
| /private/etc/hosts
 
|-
 
|-
| '''Windows XP / Vista / 7 / 8 / 10'''  
+
| '''[[Windows]] XP / Vista / 7 / 8 / 10'''  
 
| \windows\system32\drivers\etc\hosts
 
| \windows\system32\drivers\etc\hosts
 
|-
 
|-
| '''Windows NT / 2000'''  
+
| '''[[Windows NT]] / 2000'''  
 
| \winnt\system32\drivers\etc\hosts
 
| \winnt\system32\drivers\etc\hosts
 
|}
 
|}

Revision as of 12:39, 29 December 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 it is not in the DNS lookup, or you don't have DNS access.
  • 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 torrentfreak.com to the site's IP address, so even if their country's DNS blocks it, you can still get there through the URL.

104.25.103.105    torrentfreak.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 hosts file is located in different locations for different operating systems.

Operating System Path
Android /system/etc/hosts
iOS /private/etc/hosts
Linux /etc/hosts
OS X /private/etc/hosts
Windows XP / Vista / 7 / 8 / 10 \windows\system32\drivers\etc\hosts
Windows NT / 2000 \winnt\system32\drivers\etc\hosts

Links