[App] dnsmasq 安装

# 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值