If you are a Web Developer you know that Cloudflare's Cache can be very annoying. Did you know your can modify your hosts file so that you can bypass networks such as Cloudflare, Fastly or Akamai? 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. Modifying your hosts file enables you to override the domain name system (DNS) for a domain on a specific machine.
The "hosts" file 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
- MacOS - /etc/hosts or /private/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:
Hosts file example
192.168.0.1 gatewayrouter 192.168.0.10 swtich01 192.168.0.11 nas1 192.168.0.12 nas2 192.168.0.20 printer01 192.168.0.21 printer02 184.108.40.206 webserver.mycompany.com
Edit your Hosts file on Windows 11, 10 and Windows 8
Use the following instructions if you’re running Windows 10 or Windows 8:
Press the Windows key.
Type Notepad in the search field.
In the search results, right-click Notepad and select Run as administrator.
From Notepad, open the following file:
Make the necessary changes to the file.
Select File > Save to save your changes.
Edit your Hosts File on Linux / UNIX
- Open a Terminal window.
- Enter the following command to open the hosts file in a text editor:
sudo nano /etc/hosts
- Enter your sudo user password.
- Make the necessary changes to the file.
- Press Control-X.
- When you are asked if you want to save your changes, enter y.
Edit Hosts file on MacOS
- Open the Terminal application.
- Open the hosts file for editing. In the terminal window you just opened copy/paste the command string below, and press return.
sudo nano /private/etc/hosts
or on the newer MacOS
sudo nano /etc/hosts
- Enter your password when it prompts you to enter your Mac user’s password.
- Edit the hosts file as described above.
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. As well it can help you to bypass CDN (Content Delivery Networks) Networks such as Cloudflare, Fastly or Akamai.
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