DNS Server - dcasota/photonos-scripts GitHub Wiki

Here a code snippet to install a DNS server on Photon OS.

First, assign a static ip address, see Setting a Static IP Address.

Install Unbound, an open-source DNS server. See https://github.com/NLnetLabs/unbound.

tdnf install -y unbound

Edit the configuration (see bunch of information in unbound.conf). vi /etc/unbound/unbound.conf

Sample configuration.

server:

        do-ip4: yes
        do-udp: yes
        do-tcp: yes
        do-ip6: yes
        interface: 192.168.1.0
        port: 53
        access-control: 192.168.1.0/24 allow
local-zone: "photonos.local." static
local-data: "ph3.photonos.local A 192.168.1.4"
local-data-ptr: "192.168.1.4 ph3.photonos.local"

forward-zone:
        name: "."
        forward-addr: 8.8.4.4
        forward-addr: 8.8.8.8

Configure iptables and start unbound.

iptables -A INPUT -i eth0 -p udp --dport 53 -j ACCEPT
iptables-save >/etc/systemd/scripts/ip4save
ip6tables-save >/etc/systemd/scripts/ip6save
systemctl stop unbound
systemctl start unbound
systemctl status unbound.service

Unbound status output.

systemctl status unbound.service
● unbound.service - Unbound recursive Domain Name Server
     Loaded: loaded (/usr/lib/systemd/system/unbound.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2021-04-12 09:57:33 UTC; 14min ago
    Process: 1801 ExecStartPre=/usr/sbin/unbound-checkconf (code=exited, status=0/SUCCESS)
   Main PID: 1802 (unbound)
      Tasks: 1 (limit: 2286)
     Memory: 5.6M
     CGroup: /system.slice/unbound.service
             └─1802 /usr/sbin/unbound -d

Apr 12 09:57:33 ph3 systemd[1]: Starting Unbound recursive Domain Name Server...
Apr 12 09:57:33 ph3 systemd[1]: Started Unbound recursive Domain Name Server.
Apr 12 09:57:33 ph3 unbound-checkconf[1801]: unbound-checkconf: no errors in /etc/unbound/unbound.conf
Apr 12 09:57:33 ph3 unbound[1802]: [1802:0] notice: init module 0: validator
Apr 12 09:57:33 ph3 unbound[1802]: [1802:0] notice: init module 1: iterator
Apr 12 09:57:33 ph3 unbound[1802]: [1802:0] info: start of service (unbound 1.11.0).