Installing dnsmasq on Windows 10 using WSL

dnsmasq is a lightweight DNS forwarder and DHCP server. Since it doesn't natively run on Windows, you can install it through the Windows Subsystem for Linux (WSL). Here's how:

Step 1: Install WSL on Windows 10

If you haven't installed WSL yet, follow these steps:

  1. Open PowerShell as Administrator.

  2. Run the following command to enable WSL:

    wsl --install
    

    This will install WSL along with Ubuntu (the default Linux distribution). You can choose other distributions later if desired.

  3. Restart your machine when prompted.

  4. After restarting, open Ubuntu from the Start menu (or any other WSL Linux distribution you prefer).

Step 2: Update Ubuntu (or your WSL distribution)

  1. Once you're in your Linux environment, update the package list and upgrade existing packages:
    sudo apt update
    sudo apt upgrade -y
    

Step 3: Install dnsmasq

  1. Install dnsmasq by running the following command:

    sudo apt install dnsmasq -y
    
  2. Confirm that dnsmasq is installed by checking its version:

    dnsmasq -v
    

Step 4: Configure dnsmasq

  1. Open the configuration file for dnsmasq in a text editor:

    sudo nano /etc/dnsmasq.conf
    
  2. Add or modify configurations according to your needs. For example, to set a custom DNS server, you can add:

    server=8.8.8.8
    
  3. Save and close the file (in nano, press CTRL+X, then Y, and Enter).

Step 5: Start dnsmasq

  1. Start the dnsmasq service:

    sudo service dnsmasq start
    
  2. To ensure dnsmasq starts automatically on boot, run:

    sudo systemctl enable dnsmasq
    

Step 6: Test dnsmasq

  1. You can test dnsmasq by using dig or nslookup:

    dig @localhost example.com
    

    This command queries dnsmasq running locally for the example.com domain.

Step 7: Optional - Configure Windows to Use dnsmasq

To route DNS requests through dnsmasq, you can configure Windows to use localhost (127.0.0.1) as the DNS server:

  1. Open Control Panel > Network and Sharing Center > Change adapter settings.
  2. Right-click on your active network adapter and choose Properties.
  3. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
  4. Choose Use the following DNS server addresses and set the Preferred DNS server to 127.0.0.1.

Step 8: Troubleshooting

And that's it! dnsmasq is now installed and running on Windows 10 via WSL.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!