目标:局域网的人访问某个域名时,拦截下来到指定的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
Dnsmasq 解析域名到内网IP
时间: 2024-10-13 16:58:03