ESXiホスト構築時に名前解決先として、192.168.10.32としていますが、この時点ではサーバーはなくAlternate DNSサーバの192.168.100.1を参照しているので、DNS兼NTPサーバを構築していきます。なお、OSはCentOS7でインストールまでは完了している状態で進めます。
ネットワーク構成
DNSサーバのインストール
DNSサーバは、BINDを導入していきます。
★以下のコマンドでBINDをインストールする [root@dns32 ~]# yum -y install bind 読み込んだプラグイン:fastestmirror ★途中割愛★ インストール: bind.x86_64 32:9.11.4-26.P2.el7_9.7 依存性関連をインストールしました: audit-libs-python.x86_64 0:2.8.5-4.el7 checkpolicy.x86_64 0:2.5-8.el7 libcgroup.x86_64 0:0.41-21.el7 libsemanage-python.x86_64 0:2.5-14.el7 policycoreutils-python.x86_64 0:2.5-34.el7 python-IPy.noarch 0:0.75-6.el7 python-ply.noarch 0:3.4-11.el7 setools-libs.x86_64 0:3.3.8-4.el7 完了しました! [root@dns32 ~]# [root@dns32 ~]# ★BINDがインストールされたことを確認する★ [root@dns32 ~]# yum list installed | grep bind bind.x86_64 32:9.11.4-26.P2.el7_9.9 @updates bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.7 @updates bind-libs.x86_64 32:9.11.4-26.P2.el7_9.9 @updates bind-libs-lite.x86_64 32:9.11.4-26.P2.el7_9.9 @updates bind-license.noarch 32:9.11.4-26.P2.el7_9.9 @updates bind-utils.x86_64 32:9.11.4-26.P2.el7_9.9 @updates [root@dns32 ~]#
named.confを編集します。
[root@dns32 etc]# cat /etc/named.conf // // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // // See the BIND Administrator's Reference Manual (ARM) for details about the // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html options { ★ホームラボ内の問い合わせを受け付けるため以下の2行をコメントアウトします★ //listen-on port 53 { 127.0.0.1; }; //listen-on-v6 port 53 { ::1; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; recursing-file "/var/named/data/named.recursing"; secroots-file "/var/named/data/named.secroots"; ★ホームラボ内のネットワーク192.168.0.0/16を許可します★ allow-query { localhost; 192.168.0.0/16; }; ★自身で解決できない問い合わせを1.1.1.1に転送する設定を追加します★ forwarders { 1.1.1.1; }; /* - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion. - If you are building a RECURSIVE (caching) DNS server, you need to enable recursion. - If your recursive DNS server has a public IP address, you MUST enable access control to limit queries to your legitimate users. Failing to do so will cause your server to become part of large scale DNS amplification attacks. Implementing BCP38 within your network would greatly reduce such attack surface */ recursion yes; dnssec-enable yes; dnssec-validation yes; /* Path to ISC DLV key */ bindkeys-file "/etc/named.root.key"; managed-keys-directory "/var/named/dynamic"; pid-file "/run/named/named.pid"; session-keyfile "/run/named/session.key"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; ★デフォルトのzoneファイルをコメントアウトします★ /zone "." IN { / type hint; / file "named.ca"; ★正引きと逆引きのゾーンファイルの設定を追加します★ ★正引きのファイルをhome.local.zone としています★ zone "home.local" IN { type master; file "home.local.zone"; }; ★逆引きのファイルをhome.local.zone.rev としています★ zone "168.192.in-addr.arpa" IN { type master; file "home.local.zone.rev"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; [root@dns32 etc]#
正引きのゾーンファイルを作成します。
[root@dns32 ~]# vi /var/named/home.local.zone $ORIGIN home.local. $TTL 1800 @ IN SOA home.local. root.home.local. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ; minimum ) IN NS home.local. @ IN A 192.168.10.32 dns32 IN A 192.168.10.32 esx21 IN A 192.168.10.21 esx22 IN A 192.168.10.22 esx23 IN A 192.168.10.23 vcsa31 IN A 192.168.10.31 [root@dns32~]#
逆引きのゾーンファイルを作成します。
[root@cent32 ~]# vi /var/named/home.local.zone.rev $TTL 1800 @ IN SOA home.local root.home.local( 0 ;Serial 10800 ;Refresh 3 hours 3600 ;Retry 1 hour 86400 ;Expire 1 day 3600 ;Minimum 24 hours ) IN A 192.168.10.32 IN NS home.local. 32.10 IN PTR dns32.home.local. 21.10 IN PTR esx21.home.local. 22.10 IN PTR esx22.home.local. 23.10 IN PTR esx23.home.local. 31.10 IN PTR vcsa31.home.local. [root@dns32 ~]#
名前解決動作確認
サービスの再起動を行い、名前解決できることを確認します。なお、確認用のdigコマンドを使用する場合は、あらかじめbind-utilsをインストールしておく必要があります。
[root@dns32 named]# systemctl status named ● named.service - Berkeley Internet Name Domain (DNS) Loaded: loaded (/usr/lib/systemd/system/named.service; disabled; vendor preset: disabled) Active: active (running) since 土 2023-10-28 10:13:09 JST; 6s ago Process: 9605 ExecStart=/usr/sbin/named -u named -c ${NAMEDCONF} $OPTIONS (code=exited, status=0/SUCCESS) Process: 9602 ExecStartPre=/bin/bash -c if [ ! "$DISABLE_ZONE_CHECKING" == "yes" ]; then /usr/sbin/named-checkconf -z "$NAMEDCONF"; else echo "Checking of zone files is disabled"; fi (code=exited, status=0/SUCCESS) Main PID: 9608 (named) CGroup: /system.slice/named.service mq9608 /usr/sbin/named -u named -c /etc/named.conf 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:2::c#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:2f::f#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:9f::42#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:503:ba3e::2:30#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:1::53#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:a8::e#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:500:200::b#53 10月 28 10:13:09 dns32.home.local named[9608]: network unreachable resolving './NS/IN': 2001:503:c27::2:30#53 10月 28 10:13:09 dns32.home.local named[9608]: managed-keys-zone: Key 20326 for zone . acceptance timer complete: key now trusted 10月 28 10:13:09 dns32.home.local named[9608]: resolver priming query complete [root@dns32 named]# 正引きできること確認します★ [root@dns32 named]# dig A dns32.home.local ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.15 <<>> A dns32.home.local ;; global options: +cmd ;; Got answer: ;; WARNING: .local is reserved for Multicast DNS ;; You are currently testing what happens when an mDNS query is leaked to DNS ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4862 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;dns32.home.local. IN A ;; ANSWER SECTION: dns32.home.local. 1800 IN A 192.168.10.32 ;; AUTHORITY SECTION: home.local. 1800 IN NS home.local. ;; ADDITIONAL SECTION: home.local. 1800 IN A 192.168.10.32 ;; Query time: 0 msec ;; SERVER: 192.168.10.32#53(192.168.10.32) ;; WHEN: 土 10月 28 10:19:29 JST 2023 ;; MSG SIZE rcvd: 91 [root@dns32 named]# ★逆引きできること確認します★ [root@dns32 named]# dig -x 192.168.10.32 ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.15 <<>> -x 192.168.10.32 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11193 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;32.10.168.192.in-addr.arpa. IN PTR ;; ANSWER SECTION: 32.10.168.192.in-addr.arpa. 1800 IN PTR dns32.home.local. ;; AUTHORITY SECTION: 168.192.in-addr.arpa. 1800 IN NS home.local. ;; ADDITIONAL SECTION: home.local. 1800 IN A 192.168.10.32 ;; Query time: 0 msec ;; SERVER: 192.168.10.32#53(192.168.10.32) ;; WHEN: 土 10月 28 10:19:40 JST 2023 ;; MSG SIZE rcvd: 115 [root@dns32 named]#
以上でDNSサーバの設定は完了です。
NTPサーバの設定、動作確認
続いて、NTPサーバを構築します。
CentOS7は、デフォルトでchronyがインストールされているので、設定ファイルを編集します。
[root@dns32 ~]# cat /etc/chrony.cnonf # Use public servers from the pool.ntp.org project. # Please consider joining the pool (http://www.pool.ntp.org/join.html). ★以下の4行をコメントアウトします★ # server 0.centos.pool.ntp.org iburst # server 1.centos.pool.ntp.org iburst # server 2.centos.pool.ntp.org iburst # server 3.centos.pool.ntp.org iburst ★NICTを参照するように設定を追加します★ server ntp.nict.jp iburst # Allow NTP client access from local network. ★ホームラボ内からntp問い合わせを許可するため、#(コメントアウト)を削除します★ allow 192.168.0.0/16
サービスの再起動を行い、NICTと時刻同期できることを確認します。
[root@dns32 ~]# systemctl restart chronyd [root@dns32 ~]# [root@dns32 ~]# chronyc sources 210 Number of sources = 1 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* ntp-b2.nict.go.jp 1 6 17 0 -67us[ -302us] +/- 3822us [root@dns32 ~]#
以上でNTPサーバの導入は完了です。