One popular procedure for manually mapping hostnames to IP addresses on a local workstation is editing the hosts file. The hosts file may be edited using the following method on various operating systems:
For Windows:
Open Notepad as an administrator:
Right-click on the Notepad application.
Choose "Run as administrator."
Open the hosts file:
In Notepad, go to File -> Open.
Navigate to C:\Windows\System32\drivers\etc.
In the file type dropdown, select "All Files" instead of "Text Documents" to see the hosts file.
Open the hosts file.
Edit the hosts file:
Add entries in the format: IP_Address Hostname.
For example: 127.0.0.1 example.com.
Save the hosts file:
After editing, save the file. You may need to overwrite the existing hosts file.
Flush DNS cache (optional):
Open Command Prompt as an administrator.
Run the command: ipconfig /flushdns.
For macOS and Linux:
Open Terminal:
You can find it in the Applications > Utilities folder on macOS. On Linux, use the terminal application.
Open the hosts file:
Type: sudo nano /etc/hosts and press Enter.
You'll be prompted to enter your password.
Edit the hosts file:
Add entries in the format: IP_Address Hostname.
For example: 127.0.0.1 example.com.
Save the hosts file:
In Nano, press Ctrl + X, then press Y to confirm changes, and press Enter.
Flush DNS cache (optional):
On macOS, you can use the command: sudo dscacheutil -flushcache.
On Linux, use: sudo service nscd restart or sudo /etc/init.d/nscd restart.
BONUS: On Zeronoon, an annual hosting plan comes with a free domain.
Click this link www.zeronoon.com/webhosting now to secure yours today at 57.1% off.