Свой DNS сервер мне необходим для почтового сервера, что бы фильтровать спам через DBL и RBL листинги. Выбор сделан в пользу Unbound по причине его максимально быстрой и простой настройке.
Для установки Unbound в Arch Linux выполните команды:
pacman -S unbound curl mkdir -p /var/lib/unbound curl -fsSL -o /etc/unbound/root.hints https://www.internic.net/domain/named.cache install -o unbound -g unbound -m 0755 -d /etc/unbound/var/lib/unbound unbound-anchor -a /etc/unbound/var/lib/unbound/root.key chown unbound:unbound /etc/unbound/var/lib/unbound/root.key chmod 644 /etc/unbound/var/lib/unbound/root.key ls -l /etc/unbound/var/lib/unbound/root.key
Далее создаем конфигурационный файл:
cp /etc/unbound/unbound.conf /etc/unbound/unbound.conf.old > /etc/unbound/unbound.conf nano /etc/unbound/unbound.conf
Добавить в содержимое файла:
server: interface: 127.0.0.1 interface: ::1 port: 53 access-control: 127.0.0.0/8 allow access-control: ::1 allow do-ip4: yes do-ip6: yes prefetch: yes prefetch-key: yes msg-cache-size: 64m rrset-cache-size: 128m cache-min-ttl: 60 cache-max-ttl: 86400 qname-minimisation: yes harden-glue: yes harden-dnssec-stripped: yes hide-identity: yes hide-version: yes auto-trust-anchor-file: "/var/lib/unbound/root.key" root-hints: "/etc/unbound/root.hints" #verbosity: 1
Проверяем что unbound слушает 127.0.0.1:53:
ss -lntup | grep ':53 '
Если все в порядке, меняем DNS в настройка сети:
nano /etc/systemd/network/20-ens18.network
Меняем DNS на:
DNS=127.0.0.1 DNS=::1
Применяем настройки:
systemctl restart systemd-networkd systemctl restart systemd-resolved resolvectl flush-caches
Настроим автозапуск Ubound при падении:
mkdir -p /etc/systemd/system/unbound.service.d cat > /etc/systemd/system/unbound.service.d/restart.conf <<'EOF' [Unit] StartLimitIntervalSec=300 StartLimitBurst=5 [Service] Restart=on-failure RestartSec=3s EOF
Применяем настройки:
systemctl daemon-reload systemctl restart unbound systemctl status unbound --no-pager