Ubuntu 26.04

Dnsmasq : Install2026/04/24

 

Install Dnsmasq which is the lightweight DNS forwarder and DHCP Server Software.

[1] Install Dnsmasq.
root@dlp:~#
apt -y install dnsmasq
[2] Configure Dnsmasq.
root@dlp:~#
vi /etc/dnsmasq.conf
# line 19 : uncomment
# never forward plain names
domain-needed

# line 21 : uncomment
# never forward addresses in the non-routed address spaces
bogus-priv

# line 53 : uncomment
# query with each server strictly in the order in resolv.conf
strict-order

# line 67 : add if you need
# query the specific domain name to the specific DNS server
# the example follows means query [server.education] domain to the [10.0.0.10] server
server=/server.education/10.0.0.10

# line 116 : uncomment and specify network interfaces to bind
interface=enp1s0

# line 134 : uncomment
bind-interfaces

# line 145 : uncomment to add domain name on hostname automatically
expand-hosts

# line 155 : add to set domain name
domain=srv.world

# change the link according to man page of systemd-resolved in order to avoid conflicting on 53

root@dlp:~#
ln -fs /run/systemd/resolve/resolv.conf /etc/resolv.conf

root@dlp:~#
systemctl restart dnsmasq systemd-resolved

[3] For DNS records, add them in [/etc/hosts]. Then, Dnsmasq will answer to queries from clients.
root@dlp:~#
vi /etc/hosts
# add DNS entries
10.0.0.30       dlp.srv.world dlp
10.0.0.31       www.srv.world www 

root@dlp:~#
systemctl reload dnsmasq

[4] If UFW is enabled, allow DNS service. DNS uses [53/TCP,UDP].
root@dlp:~#
ufw allow domain

Rule added
Rule added (v6)
[5] Verify Name or Address Resolution from a client host in your network.
root@desktop:~#
vi /etc/netplan/01-netcfg.yaml
# change DNS setting to refer to Dnsmasq Server

nameservers:
  addresses: [10.0.0.30]

root@desktop:~#
netplan apply

root@desktop:~#
grep nameserver /run/systemd/resolve/resolv.conf

nameserver 10.0.0.30
root@desktop:~#
dig dlp.srv.world.


; <<>> DiG 9.20.18-1ubuntu2-Ubuntu <<>> dlp.srv.world.
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39087
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;dlp.srv.world.                 IN      A

;; ANSWER SECTION:
dlp.srv.world.          0       IN      A       10.0.0.30

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Apr 24 09:41:38 UTC 2026
;; MSG SIZE  rcvd: 58

root@desktop:~#
dig -x 10.0.0.30


; <<>> DiG 9.20.18-1ubuntu2-Ubuntu <<>> -x 10.0.0.30
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 14591
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;30.0.0.10.in-addr.arpa.                IN      PTR

;; ANSWER SECTION:
30.0.0.10.in-addr.arpa. 0       IN      PTR     dlp.srv.world.

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Apr 24 09:42:18 UTC 2026
;; MSG SIZE  rcvd: 78
Matched Content