By modifying your hosts file on your local PC you can override the DNS for a domain. This is useful if you need to view how a website will look on a particular ip before you update the DNS for it such as when you change web hosting providers without using the test link/url.
To modify the host files you will need locate it on your PC whether it's Windows, Linux, or Mac. You need to add two entries to the file with the domain and ip address you want the website to resolve to. For example you will add this to the file:
104.31.87.149 www.domain.com
104.31.87.149 domain.com
The following section provide instructions on locating and editing the hosts file on the following operating systems.
- Windows
- Linux
- Mac OS
Windows NT, 2000, XP, 7, Vista, 8, and 10
- Navigate to notepad, right click and run it as administrator
- Open and go to C:\Windows\System32\drivers\etc\hosts
- Open the hosts file and make the changes and save
Linux
- Open a terminal window
- Open the hosts file in a text editor by typing the following line:
sudo nano /etc/hosts - Enter your domain user password
- Make the changes to the file and press Control-x
- When asked if you want to save your changes, answer y.
Mac OS
- Open Applications > Utilities > Terminal
- Open the hosts file by typing the following line in the window
sudo nano /private/etc/hosts - Type your domain user password
- Edit the hosts file
- Save the hosts file by pressing control+x and answerying y.
When you are done flush your DNS by opening your command prompt and typing: ipconfig /flushdns