Previewing a website before DNS is pointed

Posted:  May 14th, 2018

 

To preview the content of a website without modifying the DNS configuration of a domain is to (temporarily) force your computer to make the domain point on a specific IP address. Follow these steps to do so:

 

Microsoft Windows

 

Open up your hosts file with a text editor (such as notepad). Click on "Start" -> " Run" and execute the following shortcut;

 

%windir%\system32\notepad.exe %windir%\system32\drivers\etc\hosts

 

You may also go review the file manually, it is located in the location "C:\windows\system32\drivers\etc\hosts".

 

In the file, you will see something that looks like this:

 

127.0.0.1 localhost

(IP address) (domain)

 

You must add an entry corresponding to your server's IP address, then a space and finally, your domain.

 

Example:

 

255.255.255.255 your-domain-name.com

 

Now, your-domain-name.com will resolve to the IP address 255.255.255.255 and load accordingly.

 

Having an entry like that in your host file will override any DNS configuration currently in place, locally on your computer. Do take note that you must save the file in order for this modification to take effect.

 

That is the easiest way to see content from a specific IP if you have limited access to the remote server.

 

Linux & OS X

 

Under OS X and most Linux distributions, the hosts file is located under /etc/hosts (for Mac OS X: /private/etc/hosts).

 

The file can be edited following this procedure (usually the same under OS X and Linux):

 

1) Open a terminal

 

2) Type: sudo nano /etc/hosts (step 2 and 3 are not necessary if you are logged in as root)

 

3) Enter your root password

 

4) Add a line to the file with the domain name and the desired IP

 

5) Hit Ctrl + X to save

 

6) Confirm that you want to save and exit