How to set DNS mapping via the hosts file in Windows

Steps to Edit the Hosts File on Windows

  1. Open Notepad as Administrator:

    • Press the Windows key and type Notepad.

    • Right-click on Notepad and select Run as administrator.

  2. Open the Hosts File:

    • In Notepad, go to File > Open.

    • Navigate to C:\Windows\System32\drivers\etc and select the hosts file.

  3. Edit the Hosts File:

    • Add your DNS mappings at the end of the file. Each entry should be on a new line, with the IP address followed by the domain name.

    • Example:

      192.168.0.1 example.com
      127.0.0.1 localhost
      

    Save the File:

    • Click on File > Save to save your changes.
Updated on