The Local DNS Resolver
In Ubuntu Linux, dnsmasq is a lightweight network service designed to provide DNS (Domain Name System) forwarding and DHCP (Dynamic Host Configuration Protocol) services to a local network. Historically, Ubuntu desktop versions often ran a local instance of dnsmasq bound to the loopback address (127.0.0.1) via NetworkManager to handle local DNS caching and speed up web browsing.
However, in modern Ubuntu releases, DNS resolution is primarily handled by systemd-resolved. If you are running an Ubuntu server and you attempt to install your own full-featured DNS server (like BIND9 or Pi-hole), or if you are configuring complex Docker networks, you may find that an old, lingering instance of dnsmasq (often spawned by libvirt or NetworkManager) is already binding to port 53. This causes port conflicts and prevents your primary DNS software from starting. To regain control over port 53 and simplify your network stack, you must disable dnsmasq.
How to Disable the Dnsmasq Service
You can permanently stop this local DNS forwarder using systemctl.
Warning: If you disable this and do not have an alternative DNS resolver configured (like systemd-resolved), your machine will lose the ability to resolve domain names (like google.com) to IP addresses.
- Open your Ubuntu Terminal or connect via SSH.
- Stop the active service if it is currently running in the background:
sudo systemctl stop dnsmasq.service
- Disable the service to prevent it from starting automatically on the next boot:
sudo systemctl disable dnsmasq.service
- (Optional) If you are absolutely sure no other hypervisor tools (like KVM/QEMU) rely on it for managing virtual networks, you can remove the package entirely:
sudo apt-get purge dnsmasq-base dnsmasq
Your Ubuntu server will immediately stop listening on port 53 with dnsmasq, freeing up the port for your preferred DNS server software.