http://www.thekelleys.org.uk/dnsmasq/doc.html
# yum install dnsmasq ================================================================================================================== Package Arch Version Repository Size ================================================================================================================== Installing: dnsmasq x86_64 2.48-13.el6 base 149 k Transaction Summary ==================================================================================================================
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.org vi /etc/dnsmasq.conf
diff /etc/dnsmasq.conf /etc/dnsmasq.conf.org 14c14 < domain-needed ←shorthostnameの名前解決要求を上位DNSサーバに転送しない --- > #domain-needed 16c16 < bogus-priv ←プライベートIPアドレスの逆引き要求を上位DNSサーバに転送しない --- > #bogus-priv 114c114 < expand-hosts ←domain=で指定されたドメイン名を補完する --- > #expand-hosts 123c123 < domain=exmple.osk ←補完対象のドメイン --- > #domain=thekelleys.org.uk
# vi /etc/hosts
~省略~ # test 192.168.24.170 test.exmple.osk ~省略~
# /etc/init.d/dnsmasq start
# dig @127.0.0.1 test.exmple.osk ~省略~ ;; ANSWER SECTION: test.exmple.osk. 0 IN A 192.168.24.170 ~省略~
[root@client ~]# dig test.exmple.osk ~省略~ ;; AUTHORITY SECTION: . 3336 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2014111100 1800 900 604800 86400 ~省略~
IPアドレスをDHCPで取得している環境ではnetworkのrestartでresolv.confが上書き更新されるので、NICの設定ファイルにresolv.confを更新しないオプション「PEERDNS=no」を追加する。
[root@client ~]# vi /etc/resolv.conf < nameserver 192.168.24.177 [root@dev-luck ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 < PEERDNS=no
以下のいづれかに記述すれば、networkをrestartしても指定したDNSが使用される。
[root@client ~]# vi /etc/sysconfig/network < DNS1=192.168.24.177
[root@client ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 < DNS1=192.168.24.177
[root@client ~]# dig test.exmple.osk ~省略~ ;; ANSWER SECTION: test.exmple.osk. 0 IN A 192.168.24.170 ~省略~
# vi /etc/hosts < 192.168.24.170 test.exmple.osk < 192.168.24.171 test.exmple.osk
# dig test.exmple.osk ~省略~ ;; ANSWER SECTION: test.exmple.osk. 0 IN A 192.168.24.170 test.exmple.osk. 0 IN A 192.168.24.171 ~省略~ # dig test.exmple.osk ~省略~ ;; ANSWER SECTION: test.exmple.osk. 0 IN A 192.168.24.171 test.exmple.osk. 0 IN A 192.168.24.170 ~省略~