How to - Edit your Hosts File

Modifying your hosts file enables you to override the domain name system (DNS) for a domain on a specific machine. This is helpful if you wish to bypass some DNS settings such as bypassing Cloudflare to work directly on your webserver or website. Another thing you can do is give static IP's to devices on your network that never change, such as routers, switches, printers and NAS (network attached storage) devices. By adding the devices into your hosts file your computer will always be able to find them.

The hostsfile is generally located in the following areas on your Computer

  • Windows 11 / 10 / 8 - c:\Windows\System32\Drivers\etc\hosts or %Windows%\System32\Drivers\etc\hosts
  • UNIX / Linux OS's - /etc/hosts

The hosts file contains lines of text with two columns. In the first column there is an IP address. And in the second column, there is a computer hostname. The two columns can be separated by a space or tab. So, an example hosts file might look like this:  gatewayrouter swtich01 nas1 nas2 printer01 printer02

Windows 11, 10 and Windows 8

Use the following instructions if you’re running Windows 10 or Windows 8:

  1. Press the Windows key.

  2. Type Notepad in the search field.

  3. In the search results, right-click Notepad and select Run as administrator.

  4. From Notepad, open the following file:

  5. c:\Windows\System32\Drivers\etc\hosts

  6. Make the necessary changes to the file.

  7. Select File > Save to save your changes.

Linux / UNIX

  1. Use the following instructions if you’re running Linux:
  2. Open a Terminal window.
  3. Enter the following command to open the hosts file in a text editor:
  4. sudo nano /etc/hosts
  5. Enter your sudo user password.
  6. Make the necessary changes to the file.
  7. Press Control-X.
  8. When you are asked if you want to save your changes, enter y.


Editing your hosts file can save you time and a lot of grief. Having proper host file settings will solve your DNS issues if your DNS servers go off line.

Ron Billings

Clustered Networks

Located in Edmonton, AB Canada, Clustered Networks was Incorporated in 2001 and has offered Network / Internet and IT Consulting services for over 20 years. We offer personalized service! Call Us Today! - Click Here for our Contact Info

#linux #windows10 #hosts

Posted in Linux Desktop Tips, Linux Network Admin Tips, Network Security Tips, Tech How To on Oct 06, 2021