free up port 53 on ubuntu 20.04

It’s worth noting that you can free up port 53 by simply uncommenting DNSStubListener and setting it to no in /etc/systemd/resolved.conf. The other steps are for enabling a DNS server – without it, your system will not be able to resolve any domain names, so you won’t be able to visit websites in web browser, etc.

1. Edit /etc/systemd/resolved.conf with a text editor (as root), e.g. open it with Nano console text editor:

sudo nano /etc/systemd/resolved.conf

https://2944662652a498294082227cb31af4a2.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html
And uncomment (remove # from the front of the line) the DNS= line and the DNSStubListener= line. Next, change the DNS= value in this file to the DNS server you want to use (e.g. 127.0.0.1 to use a local proxy, 1.1.1.1 to use the Cloudflare DNS, etc.), and also change the DNSStubListener= value from yes to no.

This is how the file should look after you’ve made these changes (I’m using 1.1.1.1 as the DNS server here, which is the Cloudflare DNS):

[Resolve]
DNS=1.1.1.1
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no
DNSStubListener=no
#ReadEtcHosts=yes

To save the file using Nano text editor, press Ctrl + x, then type y and press Enter.

2. Create a symbolic link for /run/systemd/resolve/resolv.conf with /etc/resolv.conf as the destination:

sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

Here, -s is for creating a symbolic and not hard link, and -f is for removing any existing destination files (so it removes /etc/resolv.conf if it exists).

3. Reboot your system.

Port 53 should now be free on your Ubuntu system, and you shouldn’t be getting errors like “listen tcp 127.0.0.1:53: bind: address already in use” anymore.

You can check to see if port 53 is in use or not by running sudo lsof -i :53 – if port 53 is not in use, this command shouldn’t show any output.

You might like:

https://2944662652a498294082227cb31af4a2.safeframe.googlesyndication.com/safeframe/1-0-38/html/container.html

How to undo the changes

Do you want to undo the changes made by following the instructions in this article? This is what you must do.

1. Start by editing /etc/systemd/resolved.conf with a text editor (as root), e.g. open it with Nano console text editor:

sudo nano /etc/systemd/resolved.conf

And comment out (add # in front of the line) DNS= and DNSStubListener=no, then save the file. To save the file using Nano text editor, press Ctrl + x, then type y and press Enter.

2. Remove the /etc/resolv.conf symbolic link:

sudo rm /etc/resolv.conf

3. Reboot your system.

refer: https://www.linuxuprising.com/2020/07/ubuntu-how-to-free-up-port-53-used-by.html