Dnsmasq - can we use it as a LAN DNS Server? Or how to install a 2nd dnsmasq for LAN use?

Hey. I was just installing dnsmasq on my home server, where I use LXD. So I got the “port in use” error as expected.

So I’m now wondering how can I proceed with my plan to have a dns server for my lan servers that are inside this machine. This will prevent requests going out through my router and back in, cutting my bandwidth in half.

I thought maybe I can use LXD’s dnsmasq for this, but can’t find any instructions and this is a bit over my head. Can anyone help?

Another option would be to have 2 dnsmasq running - but on the same port? I don’t see how… can we change LXD dns port? I would say no but asking here anyway.

Thanks in advance.

EDIT: adding details - ubuntu 22.04, LXD 5.0.2.

Well I can now nslookup using the local IP instead of just 127.0.0.1. But it does not answer requests from other computers…

I added to dnsmasq.raw:

raw.dnsmasq: |
server=1.1.1.1
server=8.8.8.8
domain-needed
bogus-priv
no-hosts
no-negcache
no-poll
cache-size=1000
listen-address=192.168.1.93

Port 53 is open…

Any help appreciated.

well, part 2. It’s working. Just closed and reopened my terminal on a windows pc, and it resolved… go figure.

nslookup microsoft.com 192.168.1.93
Server: UnKnown
Address: 192.168.1.93

Non-authoritative answer:
Name: microsoft.com
Addresses: 20.81.111.85
20.84.181.62
20.103.85.33
20.53.203.50
20.112.52.29

Sooo… guess it’s working. Still have to test a reboot and see if it persists.

FInal configuration:

raw.dnsmasq: |
server=127.0.0.53
server=1.1.1.1
server=8.8.8.8
domain-needed
bogus-priv
no-hosts
no-negcache
no-poll
cache-size=1000
listen-address=192.168.1.93
addn-hosts=/etc/hosts

Last line was added because it was not solving local hosts file entries. First line server=127.0.0.53 because it was not serving external requests.