Dnsmasq
dnsmasq는 1000 클라이언트 이하의 로컬 네트워크에서 활용하 수 있는 간단한 DHCP/DNS 서버입니다. 핵심 특징으로는 쉬운 설정과 소규모 시스템을 꼽을 수 있습니다. 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
참고로 기존 /etc/resolv.conf
, 즉 /run/systemd/resolve/stub-resolv.conf
파일의 내용은:
# 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
/etc/hosts 파일로 도메인 서버 운영
/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
클라이언트에 네임서버 등록:
systemd-resolved vs dnsmasq
Systemd-resolved#systemd-resolved vs dnsmasq 항목 참조.
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
- 우분투 20.04 사용중인 53번 포트 끄기
/etc/systemd/resolved.conf
파일의 [Resolve]
섹션에 DNSStubListener=no
설정을 적용하면 된다.
아래와 같다:
See also
- Domain Name Server (DNS)
- DHCP
- dnsmasq
- bind
- Unbound
- hostapd - 무선 렌카드를 액세스 포인트로 만든다.
- Access Point (ap)
- wifi
- SoftAP
- resolv.conf (/etc/resolv.conf)