Debian: Edit the Hosts File: Difference between revisions
Created page with "All major operating systems have a hosts file to translate hostnames to IP addresses. The hosts file has priority over DNS lookups. Whenever you open a website by typing its domain name, your system will read through the hosts file to check for the corresponding IP and then open it. The hosts file is a simple text file located in the /etc folder of your Debian system, the full path is '''''/etc/hosts'''''. From what we mentioned, you might expect this file to have a v..." |
No edit summary |
||
| Line 1: | Line 1: | ||
All major operating systems have a hosts file to translate hostnames to IP addresses. The hosts file has priority over DNS lookups. Whenever you open a website by typing its domain name, your system will read through the hosts file to check for the corresponding IP and then open it. The hosts file is a simple text file located in the /etc folder of your Debian system, the full path is '''''/etc/hosts'''''. | All major operating systems have a hosts file to translate hostnames to IP addresses. The hosts file has priority over DNS lookups. Whenever you open a website by typing its domain name, your system will read through the hosts file to check for the corresponding IP and then open it. The hosts file is a simple text file located in the /etc folder of your Debian system, the full path is '''''/etc/hosts'''''. | ||
[[File:Edit hosts 1.png|center|thumb|381x381px]] | |||
From what we mentioned, you might expect this file to have a very long list of IPs and corresponding hostnames; but that is not true. The hosts file only contains several lines; | From what we mentioned, you might expect this file to have a very long list of IPs and corresponding hostnames; but that is not true. The hosts file only contains several lines; | ||
| Line 21: | Line 19: | ||
Or | Or | ||
$ sudo gedit /etc/hosts | $ sudo gedit /etc/hosts | ||
[[File:Edit hosts 2.png|center|thumb|359x359px]] | |||
| Line 41: | Line 39: | ||
This is how the edited file will look like. Please save the changes by hitting ctrl+X and entering y on the filename prompt. | This is how the edited file will look like. Please save the changes by hitting ctrl+X and entering y on the filename prompt. | ||
[[File:Edit hosts 3.png|center|thumb|357x357px]] | |||
Please note that we have defined the complete address www.google.com instead of just the hostname google.com in the hosts file because modern browsers sometimes circumvent the block if we only define the latter. | Please note that we have defined the complete address www.google.com instead of just the hostname google.com in the hosts file because modern browsers sometimes circumvent the block if we only define the latter. | ||