
Rocky Linux 9を使用して、UnboundでDNSサーバを構築します。宅内の小規模な環境の名前解決用の設定を行います。
記事の目次
サーバを構築する環境を確認する!
サーバを構築するOS環境を確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 | # hostnamectl Static hostname: vmsnms01.loc.lab4ict.com Icon name: computer-vm Chassis: vm Machine ID: 39f2f77b642b4abe96b05142172223f9 Boot ID: 23d6cfd6e0b04ac2a454055aaa3c937e Virtualization: oracle Operating System: Rocky Linux 9.1 (Blue Onyx) CPE OS Name: cpe:/o:rocky:rocky:9::baseos Kernel: Linux 5.14.0-162.6.1.el9_1.x86_64 Architecture: x86-64 Hardware Vendor: innotek GmbH Hardware Model: VirtualBox |
Firewalldの通信許可設定を行う!
DNSの問い合わせに対する通信許可設定を行います。
1 2 3 4 | # firewall-cmd --add-service=dns --zone=public --permanent # firewall-cmd --reload # firewall-cmd --list-services cockpit dhcpv6-client dns ssh |
Unboundをインストールする!
Unboundをインストールします。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # dnf -y install unbound ... ======================================================================================================================== Package Architecture Version Repository Size ======================================================================================================================== Installing: unbound x86_64 1.16.2-3.el9 appstream 963 k Installing dependencies: unbound-libs x86_64 1.16.2-3.el9 appstream 547 k Transaction Summary ======================================================================================================================== Install 2 Packages ... Complete! |
Unboundによる名前解決の設定を行う!
Unboundの設定ファイルは、「/etc/unbound/unbound.conf」です。名前解決のレコードも設定ファイルに記述します。
1 | # vi /etc/unbound/unbound.conf |
リッスンするインターフェースの設定を行います。ループバックと、DNSサーバ自身のアドレスを設定します。
1 2 | interface: 127.0.0.1 interface: 10.1.20.1 |
名前解決のリクエストを受け付けるアドレスを設定します。ループバックと、自身のネットワークアドレスを設定します。
1 2 | access-control: 127.0.0.1 allow access-control: 10.1.0.0/16 allow |
名前解決を行うためのAレコードを記述します。
1 | local-data: "router01.loc.lab4ict.com. IN A 10.1.0.1" |
Unboundの起動設定を行う!
Unboundの起動設定を行います。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # systemctl enable --now unbound.service Created symlink /etc/systemd/system/multi-user.target.wants/unbound.service → /usr/lib/systemd/system/unbound.service. # systemctl status unbound.service ● unbound.service - Unbound recursive Domain Name Server Loaded: loaded (/usr/lib/systemd/system/unbound.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2023-06-24 12:13:16 JST; 36s ago Process: 1888 ExecStartPre=/usr/sbin/unbound-checkconf (code=exited, status=0/SUCCESS) Process: 1889 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_UNBOUND_ANCHOR" == "yes" ]; then /usr/sbin/unbound-anchor > Main PID: 1892 (unbound) Tasks: 4 (limit: 11062) Memory: 33.8M CPU: 89ms CGroup: /system.slice/unbound.service └─1892 /usr/sbin/unbound -d ... |
名前解決の確認を行う!
名前解決ができることを確認します。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # nslookup > server 127.0.0.1 Default server: 127.0.0.1 Address: 127.0.0.1#53 > router01.loc.lab4ict.com Server: 127.0.0.1 Address: 127.0.0.1#53 Name: router01.loc.lab4ict.com Address: 10.1.0.1 > server 10.1.20.1 Default server: 10.1.20.1 Address: 10.1.20.1#53 > router01.loc.lab4ict.com Server: 10.1.20.1 Address: 10.1.20.1#53 Name: router01.loc.lab4ict.com Address: 10.1.0.1 > www.google.com Server: 10.1.20.1 Address: 10.1.20.1#53 Non-authoritative answer: Name: www.google.com Address: 142.250.207.4 Name: www.google.com Address: 2404:6800:4004:820::2004 |
おわりに
Unboundを使用すると、bindのようにゾーンファイルを作成しなくても、設定ファイルに直接名前解決のレコードを記述する方法で、名前解決を行うことができます。
関連記事
参考書籍(Amazon)