To add a static entry to the etc\hosts file, follow these steps:
For Windows:
- Open your text editor in Administrator mode.
- In the text editor, open C:\Windows\System32\drivers\etc\hosts.
- Add the IP Address and hostname.
Example:
171.25.31.45 yourdomain.com - Save the changes.
For Linux:
- Open terminal.
- Use the nano command line text editor or a different one you have available to open the hosts file. The command with nano is as follows (the command will require your Linux user password)
sudo nano /etc/hosts - Add the appropriate changes in the hosts file.
Example:
171.25.31.45 yourdomain.com - Use the Control and 'X' key combination to save the changes.
For macOS:
- Launch the macOS Terminal application.
- Go to the Finder, then Click Go.
- Click Utilities.
- Double-click Terminal to launch the Terminal window
- Now, enter the following command: sudo nano /etc/hosts
- Then, enter the sudo password for your user to allow edit access to the file.
- Next, use the arrow keys to move the cursor to the bottom of the file. On a new line, enter the testing server's IP address and the domain name you want to use for that IP address. (In the example below, we used the IP address 171.25.31.45 and the domain name mydomain.com)
Example:171.25.31.45 yourdomain.com
- Next, press Control+O to overwrite the existing file, then press Enter to confirm the overwriting. This saves the changes to the file.
- Now, press Control+X to exit the nano editor.
- Finally, to update our browsers DNS records and make these changes go live in your browser, enter the following command: sudo killall -HUP mDNSResponder