Dnsmasq 解析域名到内网IP

风流意气都作罢 提交于 2019-12-09 10:53:10

目标:局域网的人访问某个域名时,拦截下来到指定的ip,做缓存节省带宽

配置:

1;>yum install dnsmasq -y

2 ; >vi /etc/dnsmasq.conf

resolve-file=/etc/dnsmasq.resolv.conf

addn-hosts=/etc/dnsmasq.hosts

resolve-file指定dnsmasq从哪里获取上行DNS Server, 默认是从/etc/resolv.conf获取。

addn-hosts指定dnsmasq从哪个文件中读取“地址 域名”记录, 默认是系统文件/etc/hosts;

listen-address默认是监控在所有网卡上的

3;cp /etc/resolv.conf /etc/dnsmasq.resolv.conf

  cp /etc/hosts /etc/dnsmasq.hosts

4;vi /etc/dnsmasq.hosts   

 10.6.0.210 www.baidu.com

5; 测试

echo  my ip  is 210 >/var/www/html/index.html

service httpd restart

客户端指定dns为 10.6.0.210

访问  www.baidu.com  












标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!