Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Email

32.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