User Tools

Site Tools


hstarwiki:cust:gen:hostfile

Host file

Edit for testing

If you are working on a temporary site that is located at a different location, you may need to change how your computer uses DNS on that page. You do this by editing the Host file. Here are the steps:

  • Figure out what you want to change, for example:
  • mywebsite.com has a development version on a dns server at 11.22.33.44
  • Open the host file, here are the locations:
  • Windows: C:\Windows\System32\drivers\etc\hosts
  • Unix: /etc/hosts
  • Open the file with a simple text editor like windows notepad or notepad++
  • To add an entry, add the line:
  • [ip of server location] [domain]
  • So in the above example, the line will be:
11.22.33.44 mywebsite.com 
  • Save file. You may need to give windows elevated permission to save

Clearing dns

  • Open a browser and clear cache or do private browsing to test.
  • Sometimes it helps to run flush dns:
  • Press the key combo “Windows Key + R” (without quotations and +) to open a command prompt
  • Type this and press return:
  • ipconfig /flushdns
  • Also, you may need to restart your computer after clearing your cache

Testing

A good way to check if you have made the correct changes is to use traceroute. It helps to do this before so you know the current IP and can see the difference:

  • Open Press the key combo “Windows + R” (without quotations) to open a command prompt
  • type in “cmd” and press enter
  • You are now in the windows command prompt and can run the traceroute command
  • Example:
C:\Users\myuser>tracert mywebsite.com 
  • This will give you long readout, but will show you the ip of your website first, you can ignore the trace.
  • example:
C:\Users\myuser>tracert mywebsite.com

Tracing route to mywebsite.com [44.44.44.44]
  • Once you have modified the host file, and following our example, you would see something like:
C:\Users\myuser>tracert mywebsite.com

Tracing route to mywebsite.com [11.22.33.44]

Commenting out and reverting

When you are done with the host file, you should either delete the line in the host file, or comment it out. Commenting it out leaves the line in to be activated later. To comment out just add a hash mark # before the line. SO the host file would look like:

#11.22.33.44 mywebsite.com 

Multiple lines

You can add multiple lines of code and various ones commented out. your host file can look like this:

11.22.33.44 mywebsite.com 
#4.3.2.1 google.com
55.66.77.88 testsitenumber2.com

In this example it would only change the first and third dns entry. The google entry would not affect how your computer reaches google.

hstarwiki/cust/gen/hostfile.txt · Last modified: 2017-08-07 T 23:09 by admin