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:
Open PowerShell as Administrator.
Run the following command to enable WSL:
wsl --installThis will install WSL along with Ubuntu (the default Linux distribution). You can choose other distributions later if desired.
Restart your machine when prompted.
After restarting, open Ubuntu from the Start menu (or any other WSL Linux distribution you prefer).
Step 2: Update Ubuntu (or your WSL distribution)
- 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
Install
dnsmasqby running the following command:sudo apt install dnsmasq -yConfirm that
dnsmasqis installed by checking its version:dnsmasq -v
Step 4: Configure dnsmasq
Open the configuration file for
dnsmasqin a text editor:sudo nano /etc/dnsmasq.confAdd or modify configurations according to your needs. For example, to set a custom DNS server, you can add:
server=8.8.8.8Save and close the file (in
nano, pressCTRL+X, thenY, andEnter).
Step 5: Start dnsmasq
Start the
dnsmasqservice:sudo service dnsmasq startTo ensure
dnsmasqstarts automatically on boot, run:sudo systemctl enable dnsmasq
Step 6: Test dnsmasq
You can test
dnsmasqby usingdigornslookup:dig @localhost example.comThis command queries
dnsmasqrunning locally for theexample.comdomain.
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:
- Open Control Panel > Network and Sharing Center > Change adapter settings.
- Right-click on your active network adapter and choose Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
- Choose Use the following DNS server addresses and set the Preferred DNS server to
127.0.0.1.
Step 8: Troubleshooting
To check the
dnsmasqlogs, use:sudo journalctl -u dnsmasqIf
dnsmasqdoesn't start, verify your configuration for any syntax errors.
And that's it! dnsmasq is now installed and running on Windows 10 via WSL.