您的位置:首页 > 移动开发

[App] dnsmasq 安装

2017-10-12 16:34 246 查看
# yum -y install dnsmasq bind-utils
# vi
/etc/dnsmasq.conf

resolv-file=/etc/resolv.dnsmasq.conf     
#在resolv.dnsmasq.conf读取上级dns服务器地址
strict-order                                                   
#按照recolv-file文件中的地址顺序获取ip
address=/www.mazhihua.com/192.168.1.127       
#自定义域名解析为 192.168.1.127
listen-address=127.0.0.1,192.168.1.127        
#定义dnsmasq监听的地址,局域网中使用需添加局域网地址
addn-hosts=/etc/dnsmasq.hosts                 
#定义host文件
 
# vi
/etc/resolv.conf

nameserver 127.0.0.1        # 
使用本地dns
 
# vi
/etc/resolv.dnsmasq.conf

nameserver 192.168.1.1       #
真实DNS地址
 
#
cp -a /etc/hosts /etc/dnsmasq.hosts
# chkconfig dnsmasq on
# service dnsmasq restart
# netstat-tunlp | grep 53

tcp        0      0 0.0.0.0:53                  0.0.0.0:*                   LISTEN      1467/dnsmasq       

tcp        0      0 :::53                       :::*                        LISTEN      1467/dnsmasq       

udp        0      0 0.0.0.0:53                  0.0.0.0:*                               1467/dnsmasq       

udp        0      0 :::53                       :::*                                    1467/dnsmasq

 
#
nslookup www.baidu.com       #
测试

Server:         127.0.0.1
Address:        127.0.0.1#53
 
Non-authoritative answer:
www.baidu.com   canonical name =
www.a.shifen.com.
Name:  
www.a.shifen.com
Address: 111.13.100.91
Name:  
www.a.shifen.com
Address: 111.13.100.92
 
#
echo "192.168.1.128 hahahah" >> /etc/dnsmasq.hosts

# service dnsmasq restart
# nslookup 192.168.1.128

Server:         127.0.0.1
Address:        127.0.0.1#53
 
128.1.168.192.in-addr.arpa      name = hahahah.
# nslookup hahahah

Server:         127.0.0.1
Address:        127.0.0.1#53
 
Name:   hahahah
Address: 192.168.1.128
 
#
ping hahahah
PING hahahah(192.168.1.128) 56(84) bytes of data.
64 bytes fromhahahah (192.168.1.128): icmp_seq=1 ttl=64 time=0.234 ms
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dnsmasq安装配置