Home | Mirror | Search

4. dnsmasq.hosts

dnsmasq 預設會讀取 /etc/hosts 如果你不想讓它解析/etc/hosts檔案,可以自己定義一個檔案。

# vim /etc/dnsmasq.conf
no-hosts
addn-hosts=/etc/dnsmasq.hosts
		
echo "172.16.0.1 test.example.com" > /etc/dnsmasq.hosts
		

重新起動

/etc/init.d/dnsmasq restart
		

查看日誌

cat /var/log/message

Sep 15 18:17:24 J10-51-MemCache dnsmasq[13799]: read /etc/hosts - 2 addresses
Sep 15 18:17:24 J10-51-MemCache dnsmasq[13799]: read /etc/dnsmasq.hosts - 40 addresses
		

使用nslookup測試

nslookup test.example.com 172.16.3.51
		

提示

註釋no-hosts選項,可以實現 /etc/hosts 與 /etc/dnsmasq.hosts 共用

comments powered by Disqus