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  

相關文章
相關標籤/搜索