ESXiができたので、これから仮想サーバを構築してきますが、NSX-V、NSX-Tを導入するにはvCenterが必須となるため、事前にホームラボ内で名前解決が行えるようにしておく必要があります。ゲートウェイとなるL3SWではDNS機能を提供していないので、いっそのこと、DNS兼NTPサーバを構築しようと思います。
OSは、CentOS7でインストールまでは完了している状態で進めてきます。
DNSサーバのインストール
1.DNSサーバは、BINDを導入していきます。
★以下のコマンドでBINDをインストールする [root@cent32 ~]# 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@cent32 ~]# [root@cent32 ~]# ★BINDがインストールされたことを確認する★ [root@cent32 ~]# 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@cent32 ~]#
2.named.confを編集します。
[root@cent32 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; }; ★自身で解決できない問い合わせを8.8.8.8に転送する設定を追加します★ forwarders { 8.8.8.8; }; /* - 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@cent32 etc]#
3.正引きのゾーンファイルを作成します。
[root@cent32 ~]# 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.1.32 ns IN A 192.168.1.32 cent32 IN A 192.168.1.32 esxi21 IN A 192.168.1.21 esxi22 IN A 192.168.1.22 esxi23 IN A 192.168.1.23 esxi24 IN A 192.168.1.24 esxi25 IN A 192.168.1.25 esxi26 IN A 192.168.1.26 vcenter31 IN A 192.168.1.31 nsxvmgr41 IN A 192.168.1.41 nsxtmgr51 IN A 192.168.1.51 edge56 IN A 192.168.1.56 edge57 IN A 192.168.1.57 [root@cent32 ~]#
4.逆引きのゾーンファイルを作成します。
[root@cent32 ~]# vi /var/named/home.local.zone.rev $TTL 1800 @ IN SOA home.local root.home.local ( 2021040100 ;Serial 10800 ;Refresh 3 hours 3600 ;Retry 1 hour 86400 ;Expire 1 day 3600 ;Minimum 24 hours ) IN A 192.168.1.32 IN NS home.local. 32.1 IN PTR cent32.home.local. 21.1 IN PTR esxi21.home.local. 22.1 IN PTR esxi22.home.local. 23.1 IN PTR esxi23.home.local. 24.1 IN PTR esxi24.home.local. 25.1 IN PTR esxi25.home.local. 26.1 IN PTR esxi26.home.local. 31.1 IN PTR vcenter31.home.local. 41.1 IN PTR nsxvmgr41.home.local. 51.1 IN PTR nsxtmgr51.home.local. 56.1 IN PTR edge56.home.local. 57.1 IN PTR edge57.home.local. [root@cent32 ~]#
5.サービスの再起動を行い、名前解決できることを確認します。なお、確認用のdigコマンドを使用する場合は、あらかじめbind-utilsをインストールしておく必要があります。
[root@cent32 ~]# systemctl restart named [root@cent32 ~]# [root@cent32 ~]# [root@cent32 ~]# systemctl status named ● named.service - Berkeley Internet Name Domain (DNS) Loaded: loaded (/usr/lib/systemd/system/named.service; enabled; vendor preset: disabled) Active: active (running) since 土 2022-03-12 14:56:26 JST; 19min ago Process: 4048 ExecStop=/bin/sh -c /usr/sbin/rndc stop > /dev/null 2>&1 || /bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS) Process: 4060 ExecStart=/usr/sbin/named -u named -c ${NAMEDCONF} $OPTIONS (code=exited, status=0/SUCCESS) Process: 4058 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: 4062 (named) CGroup: /system.slice/named.service mq4062 /usr/sbin/named -u named -c /etc/named.conf 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:500:200::b#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:500:1::53#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:dc3::35#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:7fd::1#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:500:a8::e#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:500:9f::42#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:7fe::53#53 3月 12 14:56:26 cent32.home.local named[4062]: network unreachable resolving './NS/IN': 2001:500:12::d0d#53 3月 12 14:56:26 cent32.home.local named[4062]: managed-keys-zone: Key 20326 for zone . acceptance timer complete: key now trusted 3月 12 14:56:26 cent32.home.local named[4062]: resolver priming query complete [root@cent32 ~]# [root@cent32 ~]# ★正引きできること確認します★ [root@cent32 ~]# dig A vcenter31.home.local @127.0.0.1 ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> A vcenter31.home.local @127.0.0.1 ;; 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: 28816 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;vcenter31.home.local. IN A ;; ANSWER SECTION: vcenter31.home.local. 1800 IN A 192.168.1.31 ;; AUTHORITY SECTION: home.local. 1800 IN NS home.local. ;; ADDITIONAL SECTION: home.local. 1800 IN A 192.168.1.32 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: 土 3月 12 15:18:04 JST 2022 ;; MSG SIZE rcvd: 95 [root@cent32 ~]# [root@cent32 ~]# ★逆引きできること確認します★ [root@cent32 ~]# dig -x 192.168.1.31 @127.0.0.1 ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> -x 192.168.1.31 @127.0.0.1 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7913 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;31.1.168.192.in-addr.arpa. IN PTR ;; ANSWER SECTION: 31.1.168.192.in-addr.arpa. 1800 IN PTR vcenter31.home.local. ;; AUTHORITY SECTION: 168.192.in-addr.arpa. 1800 IN NS home.local. ;; ADDITIONAL SECTION: home.local. 1800 IN A 192.168.1.32 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: 土 3月 12 15:18:35 JST 2022 ;; MSG SIZE rcvd: 118 [root@cent32 ~]#
以上でDNSサーバの設定は完了です。
NTPサーバの設定
1.CentOS7は、デフォルトでchronyがインストールされているので、設定ファイルを編集します。
[root@cent32 ~]# 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
2.サービスの再起動を行い、NICTと時刻同期できることを確認します。
[root@cent32 ~]# systemctl restart chronyd [root@cent32 ~]# [root@cent32 ~]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since 木 2021-09-23 21:39:28 JST; 8s ago Docs: man:chronyd(8) man:chrony.conf(5) Process: 1174 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS) Process: 1170 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 1172 (chronyd) CGroup: /system.slice/chronyd.service mq1172 /usr/sbin/chronyd 9月 23 21:39:28 cent32.home.local systemd[1]: Stopped NTP client/server. 9月 23 21:39:28 cent32.home.local systemd[1]: Starting NTP client/server... 9月 23 21:39:28 cent32.home.local chronyd[1172]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCF...DEBUG) 9月 23 21:39:28 cent32.home.local chronyd[1172]: Frequency 3.023 +/- 17.756 ppm read from /var/lib/chrony/drift 9月 23 21:39:28 cent32.home.local systemd[1]: Started NTP client/server. 9月 23 21:39:33 cent32.home.local chronyd[1172]: Selected source 133.243.238.244 Hint: Some lines were ellipsized, use -l to show in full. [root@cent32 ~]# [root@cent32 ~]# [root@cent32 ~]# chronyc sources 210 Number of sources = 1 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* ntp-a3.nict.go.jp 1 6 17 6 +5675us[+6404us] +/- 36ms [root@cent32 ~]#
以上でNTPサーバの導入は完了です。
導入後、ESXiホスト、各種VMのDNSおよびNTPを192.168.1.32に設定することで、名前解決や時刻同期が可能となります。
次回は、いよいよvCenterを導入していきます。