Apologies if this turns out to be trivial, but getting dnsmasq to work has completely frustrated and defeated me, after days of faffing around.
I have a bunch of vhosts on a server, and need to access them from other devices. To date, I’ve done this via /etc/hosts on each device. However, an iPad, iPhone and Samsung tablet now also need access, hence looking at dnsmasq.
Fedora 35, installed Nov.2021
Linux 5.15.5-200.fc35.x86_64
dnsmasq v 2.86
/etc/hosts:
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
192.168.178.9 server.lan
192.168.178.10 laptop.lan
127.0.0.1 vhost1.lan
127.0.0.1 vhost2.lan
… … …
Router: Fritzbox 7490
Local DNS Server: 192.168.178.9
(server)
/etc/NetworkManager/NetworkManager.conf
[main]
dns=none
NM config for wlp5s0 (wifi conn on server)
Method: Manual
Address: 192.168.178.9/24
Gateway: 192.168.178.1 (router)
DNS Servers: 127.0.0.1 (server)
Search domains: localhost
/etc/dnsmasq.conf:
domain-needed
bogus-priv
no-resolv
no-poll
local=/lan/
interface=wlp5s0
(wifi)
listen-address=127.0.0.1
(server)
no-dhcp-interface=wlp5s0
bind-interfaces
address=/lan/127.0.0.1
address=/lan/192.168.178.9
Most of the help on the web uses dnsmasq as both a DNS server and DHCP lessor. I /only/ want to run the DNS server, leaving the router to assign leases as it sees fit.
I couldn’t figure out how to stop NM from running the dnsmasq plugin which was blocking port 53, and ended up killing the process. In case the plugin starts up on next reboot, it would be good to know if there is a better way.
/etc/resolv.conf:
resolv.conf -> /run/systemd/resolve/stub-resolv.conf
nameserver 127.0.0.53
options edns0 trust-ad
search localhost
$ netstat -tulpn | grep ":53 "
tcp/udp 0 0 192.168.178.9:53 0.0.0.0:* LISTEN 2250435/dnsmasq
tcp/udp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 2250435/dnsmasq
tcp/udp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 2213842/systemd-resolve
/run/systemd/resolve/resolv.conf
nameserver 192.168.178.1
nameserver 127.0.0.1
search localhost
Output from dig on the server:
; <<>> DiG 9.16.28-RH <<>> vhost1.lan
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57328
;; flags: qr aa rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;vhost1.lan. IN A
;; ANSWER SECTION:
vhost1.lan. 0 IN A 127.0.0.1
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sun May 22 07:10:27 CEST 2022
;; MSG SIZE rcvd: 55