How to set DNS mapping via the hosts file in Linux

Steps to Edit the hosts File on Linux

  1. Open Terminal:

    • Open your terminal application.
  2. Edit the Hosts File:

    • Type this command and press Enter

      sudo nano /etc/hosts
      
    • Enter your password if prompted.

  3. Add Your Mapping:

    • At the end of the file, add a line like this

      192.168.0.1 example.com
      
  4. Save and Exit:

    • Press Ctrl + X, then Y, and hit Enter.
Updated on