cluster ONTAP/ONTAP9のNFS exports設定にNISホスト名が使えないのでdnsmasqでごまかすことにした

NetAppのcluster ONTAP8.x/ONTAP9はNISを使える、と書いてあるものの、詳細を確認すると、NISホスト名は使用できず、NISユーザとパスワード、NISグループ、NIS netgroup(ホスト名用のグループ)しか使えないとのこと。

NIS netgroup対応といっても、netgroupに含まれるホスト名にNIS ホスト名が許されるわけではなく、DNS起因のホスト名の使用が許される、というものでした。(ONTAPシミュレータで確認)

既存のDNSサーバにエントリを追加してもらえれば解決ではありますが、できるかどうかわからないので、お手軽にできる回避策として、RHEL6/RHEL7などの標準パッケージ群に含まれているdnsmasqを使用した簡易DNSサーバを立ててみることにした。

dnsmasqは/etc/hostsもしくはhostsフォーマットに準じたファイルを指定して、そこのエントリを元にDNS応答を返すことができる。

NISホスト名を「ypcat hosts」で一括出力するとhostsフォーマットでエントリが取得できるので、crontabで定期的に「ypcat hosts」を実行して情報更新を行い、dnsmasqでDNSで応答を返せるようにした。

まずは、DNSサーバのインストール。

1[root@nisclient ~]# yum install dnsmasq
2読み込んだプラグイン:fastestmirror
3インストール処理の設定をしています
4Loading mirror speeds from cached hostfile
5 * base: ftp.nara.wide.ad.jp
6 * extras: ftp.nara.wide.ad.jp
7 * updates: ftp.nara.wide.ad.jp
8依存性の解決をしています
9--> トランザクションの確認を実行しています。
10---> Package dnsmasq.x86_64 0:2.48-18.el6_9 will be インストール
11--> 依存性解決を終了しました。
12 
13依存性を解決しました
14 
15================================================================================
16 パッケージ       アーキテクチャ  バージョン                リポジトリー   容量
17================================================================================
18インストールしています:
19 dnsmasq          x86_64          2.48-18.el6_9             base          150 k
20 
21トランザクションの要約
22================================================================================
23インストール         1 パッケージ
24 
25総ダウンロード容量: 150 k
26インストール済み容量: 294 k
27これでいいですか? [y/N]y
28パッケージをダウンロードしています:
29dnsmasq-2.48-18.el6_9.x86_64.rpm                         | 150 kB     00:00
30rpm_check_debug を実行しています
31トランザクションのテストを実行しています
32トランザクションのテストを成功しました
33トランザクションを実行しています
34  インストールしています  : dnsmasq-2.48-18.el6_9.x86_64                    1/1
35  Verifying               : dnsmasq-2.48-18.el6_9.x86_64                    1/1
36 
37インストール:
38  dnsmasq.x86_64 0:2.48-18.el6_9
39 
40完了しました!
41[root@nisclient ~]#

/etc に配置された設定ファイルを確認。

1[root@nisclient ~]# ls -l /etc/dnsmasq.*
2-rw-r--r--. 1 root root 21214 10月  3 08:18 2017 /etc/dnsmasq.conf
3 
4/etc/dnsmasq.d:
5合計 0
6[root@nisclient ~]#

NISで配布されたhostsを/etc/hosts-from-nisに保存するということにして、/etc/hosts は使用しない、ということにして、/etc/dnsmasq.conf の以下を変更

1変更前
2# If you don't want dnsmasq to read /etc/hosts, uncomment the
3# following line.
4#no-hosts
5# or if you want it to read another file, as well as /etc/hosts, use
6# this.
7#addn-hosts=/etc/banner_add_hosts
1変更後
2# If you don't want dnsmasq to read /etc/hosts, uncomment the
3# following line.
4no-hosts
5# or if you want it to read another file, as well as /etc/hosts, use
6# this.
7addn-hosts=/etc/hosts-from-nis

上記以外のエントリは標準設定のままです。NISから配布されたhostsを/etc/hosts-from-nisに保存

1[root@nisclient ~]# ypcat hosts > /etc/hosts-from-nis
2[root@nisclient ~]# cat /etc/hosts-from-nis
3127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
4127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
5127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
6127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
7172.17.44.100   nfstest
8172.17.44.49    server49      server49.vm2.example.com
9172.17.44.49    server49      server49.vm2.example.com
10172.17.44.87    server87
11172.17.44.88    server88
12172.17.44.89    server89
13[root@nisclient ~]#

続いてfirewalld/iptablesの設定変更して、ポート53のtcp/udpを許可。

1[root@nisclient ~]# cat /etc/sysconfig/iptables
2# Firewall configuration written by system-config-firewall
3# Manual customization of this file is not recommended.
4*filter
5:INPUT ACCEPT [0:0]
6:FORWARD ACCEPT [0:0]
7:OUTPUT ACCEPT [0:0]
8-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
9-A INPUT -p icmp -j ACCEPT
10-A INPUT -i lo -j ACCEPT
11-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
12-A INPUT -m state --state NEW -m tcp -p tcp --dport 53 -j ACCEPT
13-A INPUT -m state --state NEW -m udp -p udp --dport 53 -j ACCEPT
14-A INPUT -j REJECT --reject-with icmp-host-prohibited
15-A FORWARD -j REJECT --reject-with icmp-host-prohibited
16COMMIT
17[root@nisclient ~]# service iptables restart
18iptables: チェインをポリシー ACCEPT へ設定中filter         [  OK  ]
19iptables: ファイアウォールルールを消去中:                  [  OK  ]
20iptables: モジュールを取り外し中:                          [  OK  ]
21iptables: ファイアウォールルールを適用中:                  [  OK  ]
22[root@nisclient ~]#

firewalldの場合は以下

1-bash-4.2# firewall-cmd --list-all
2public (active)
3  target: default
4  icmp-block-inversion: no
5  interfaces: ens192
6  sources:
7  services: dhcpv6-client ssh
8  ports:
9  protocols:
10  masquerade: no
11  forward-ports:
12  source-ports:
13  icmp-blocks:
14  rich rules:
15 
16-bash-4.2# firewall-cmd --permanent --zone=public --add-service=dns
17success
18-bash-4.2# firewall-cmd --reload
19success
20-bash-4.2# firewall-cmd --list-all
21public (active)
22  target: default
23  icmp-block-inversion: no
24  interfaces: ens192
25  sources:
26  services: dhcpv6-client dns ssh
27  ports:
28  protocols:
29  masquerade: no
30  forward-ports:
31  source-ports:
32  icmp-blocks:
33  rich rules:
34 
35-bash-4.2#

で、dnsmasqを起動して、DNSにより名前解決ができるか確認してみます。

1[root@nisclient ~]# service dnsmasq status
2dnsmasq は停止しています
3[root@nisclient ~]# service dnsmasq start
4Starting dnsmasq:                                          [  OK  ]
5[root@nisclient ~]# service dnsmasq status
6dnsmasq (pid  1556) を実行中...
7[root@nisclient ~]#
8 
9[root@nisclient ~]# nslookup nfstest 127.0.0.1
10Server:         127.0.0.1
11Address:        127.0.0.1#53
12 
13Name:   nfstest
14Address: 172.17.44.100
15 
16[root@nisclient ~]#

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StatCounter - Free Web Tracker and Counter