24

I was setting up a server as in the below link https://help.ubuntu.com/community/Dnsmasq

root@user-desktop:/etc/init.d# sudo apt-get install dnsmasq
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  dnsmasq
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/15.4 kB of archives.
After this operation, 120 kB of additional disk space will be used.
Selecting previously unselected package dnsmasq.
(Reading database ... 146283 files and directories currently installed.)
Unpacking dnsmasq (from .../dnsmasq_2.59-4_all.deb) ...
Processing triggers for ureadahead ...
Setting up dnsmasq (2.59-4) ...
 * Starting DNS forwarder and DHCP server dnsmasq                                                                                                                                                            
dnsmasq: failed to create listening socket for port 53: Address already in use [fail]
invoke-rc.d: initscript dnsmasq, action "start" failed.
14

Check what's listening on port 53 (domain) with:

sudo ss -lp "sport = :domain"

Disable any service that is running on this port. It's usually systemd-resolved.

I'm going to also mask it so it doesn't auto start on reboot.

sudo systemctl disable systemd-resolved
sudo systemctl mask systemd-resolved

Also, make sure that you have stopped the systemd-resolved service. Run:

sudo systemctl stop systemd-resolved

To undo what you did:

sudo systemctl unmask systemd-resolved
sudo systemctl enable systemd-resolved

Also sudo update-rc.d systemd-resolved disable might also stop it from auto starting on boot but I haven't tested it. Use defaults instead of disable to undo the command.


Or you can change what port dnsmasq listens on, by editing the config file:

sudo nano /etc/dnsmasq.conf

Hit Ctrl+W and type listen-address= and hit enter.

Uncomment the line and add 127.0.0.1 with a different port than 53 like:

listen-address=127.0.0.1#5300
| improve this answer | |
  • sudo ss -lp "sport = :domain" Doesn't say 53 – Philip Rego Jul 9 at 0:18
7

I get the same issue as you do. I think that it's true since 12.10, but this thread was closed before the release of 12.10.

Making some googling around (mostly inspired from here), I found this solution:

  • edit /etc/NetworkManager/NetworkManager.conf file with you lovest editor
  • comment the line dns=dnsmasq
  • restart the network manager : sudo service network-manager restart

But in your dnsmasq configuration (/etc/dnsmasq.conf), you have to be sure to listen the localhost DNS queries with the line listen-address=127.0.0.1.

If you change the configuration of dnsmasq, don't forget to run sudo /etc/init.d/dnsmasq restart

I hope this will help.

| improve this answer | |
  • 2
    By commenting out dns=dnsmasq doesn't that defeat the purpose of installing DNSmasq. I made the listen-address=127.0.0.1 change and it seems to work fine now. – user232921 Jan 7 '14 at 22:32
  • 1
    No. You're keeping NetworkManager from starting dnsmasq and instead starting it independently. – MrMas Aug 27 '19 at 15:07
  • i found dns= in /usr/lib/NetworkManager/conf.d/10-dns-resolved.conf however commenting out did not fix the dnsmasq: failed to create listening socket for – northern-bradley Apr 9 at 23:58
  • I didn't have the line dns=dnsmasq in /etc/NetworkManager/NetworkManager.conf. I set listen-address=127.0.0.1 in /etc/dnsmasq.conf and restarted dnsmasq, but I still get the same port 53: address already in use error. – Philip Rego Jul 9 at 0:26
5

I had the same problem.

dnsmasq-base was installed and listened on port 53 preventing dnsmasq to start.

It is possible to use dnsmasq-base insead of dnsmasq for the same purpose: just use another config directory: the one placed in Network Manager folder:

/etc/NetworkManager/dnsmasq.d/
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.