Dnsmasq
lastmod 2024-06-05created 2021-01-2213 edits
dnsmasq is a simple DHCP/DNS server that can be used on local networks with fewer than 1000 clients. Its key features are easy configuration and a small footprint. It also supports IPv6.
Install
Ubuntu 20.04
- Install and Configure Dnsmasq on Ubuntu 22.04|20.04|18.04 | ComputingForGeeks
- Configure Local DNS Server using Dnsmasq on Ubuntu 20.04 - kifarunix.com
sudo -s
systemctl disable systemd-resolved
systemctl stop systemd-resolved
systemctl daemon-reload
ls -lh /etc/resolv.conf ## lrwxrwxrwx 1 root root 39 Oct 16 2023 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
unlink /etc/resolv.conf
echo "nameserver 8.8.8.8" > /etc/resolv.conf
apt update
apt install dnsmasq
netstat -n -u -p -a
vi /etc/hosts
vi /etc/dnsmasq.conf
systemctl restart dnsmasq
systemctl status dnsmasq
For reference, the contents of the original /etc/resolv.conf, i.e. the /run/systemd/resolve/stub-resolv.conf file:
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0 trust-ad
search vcn03281442.oraclevcn.com
Running a domain server with the /etc/hosts file
/etc/dnsmasq.conf file:
DNS Server - Docker build
/etc/dnsmasq.conf file:
# dnsmasq configuration file
no-resolv
server=8.8.8.8 # Upstream DNS server
addn-hosts=/etc/hosts.dnsmasq
/etc/hosts.dnsmasq file:
Dockerfile ilfe:
FROM alpine:latest
RUN apk --no-cache add dnsmasq
COPY dnsmasq.conf /etc/dnsmasq.conf
COPY hosts.dnsmasq /etc/hosts.dnsmasq
EXPOSE 53/tcp 53/udp
CMD ["dnsmasq", "--no-daemon"]
Build:
Run command:
docker run -d \
--name dnsmasq \
-p 53:53/tcp -p 53:53/udp \
-v /path/to/dnsmasq.conf:/etc/dnsmasq.conf \
-v /path/to/hosts.dnsmasq:/etc/hosts.dnsmasq \
andyshinn/dnsmasq
Register the nameserver on the client:
systemd-resolved vs dnsmasq
See Systemd-resolved#systemd-resolved vs dnsmasq.
Resolving conflicts with systemd-resolved
- How to avoid conflicts between dnsmasq and systemd-resolved? - Unix & Linux Stack Exchange
- 16.10 - How to disable systemd-resolved and resolve DNS with dnsmasq? - Ask Ubuntu
- Turning off port 53 in use on Ubuntu 20.04
Apply the DNSStubListener=no setting in the [Resolve] section of the /etc/systemd/resolved.conf file.
As follows:
See also
- Domain Name Server (DNS)
- DHCP
- dnsmasq
- bind
- Unbound
- hostapd - turns a wireless LAN card into an access point.
- Access Point (ap)
- wifi
- SoftAP
- resolv.conf (/etc/resolv.conf)
Favorits site
- Dnsmasq - network services for small networks.
- Wikipedia (en) Dnsmasq
- Dnsmasq - Gentoo Wiki
- Joinc - Building a local network DNS server with dnsmasq
- Using a wireless LAN card as an AP on Ubuntu (SoftAP) (dnsmasq, hostapd)
- SAP operator ST03 :: (Micro Service recommendation) dnsmasq - Building DNS with a hosts file
Pages that link here