XNetwork

Finding my way into noting down any issues (and fixes) I’ve come across and anything else that comes to mind.

WSL2 Ubuntu DNS Issues

The other day, I attempted to create a new Laravel application using Sail but encountered timeouts during the process:

curl https://laravel.build/example-app | bash

After some investigation, I identified the issue was with the Sail Docker container trying to download packages and timing out. Subsequent testing with other containers yielded the same results.

Internet searches pointed to Windows DHCP as the culprit. Through trial and error, I started by instructing WSL not to auto-generate the /etc/resolv.conf file as the IP it was generating wasn’t resolving DNS queries. To fix this, I performed the following:

Add the following line to /etc/wsl.conf:

generateResolvConf = false

Temporarily set the IP in /etc/resolv.conf to 8.8.8.8 to allow the DNS to work so you can install dnsmasq:

sudo apt install dnsmasq -y

If it complains about being unable to start because systemd-resolved is currently listening on port 53, check with:

sudo lsof -i :53

Disable the default resolver service with:

sudo systemctl disable systemd-resolved.service

Stop it with

sudo systemctl stop systemd-resolved.service

Change /etc/resolv.conf from 8.8.8.8 to 127.0.0.1. Then, modify /etc/dnsmasq.conf by adding the following lines at the end:

server=/{your-local-domain}/{your-local-dns}
server=8.8.8.8
no-dhcp-interface=

Finally, restart dnsmasq with:

sudo systemctl restart dnsmasq

This should resolve the DNS issues, allowing you to proceed with your development.