Dnsmasq 解析域名到内网IP

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

配置:缓存

1;>yum install dnsmasq -y测试

2 ; >vi /etc/dnsmasq.confspa

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

addn-hosts=/etc/dnsmasq.hostshtm

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

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

listen-address默认是监控在全部网卡上的get

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  

相关文章
相关标签/搜索