1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
我的博客已迁移到xdoujiang.com请去那边和我交流
一、基础环境
1、角色、ip、版本、内核
serverA 192.168.1.6 3.2.0-4-amd64 7.8
clientB 192.168.1.7 3.2.0-4-amd64 7.8
clientC 192.168.1.4 win7
二、安装dnsmasq(serverA)
1、安装包
apt-get
install
dnsmasq -y
2. 修改hosts文件
echo
"192.168.1.6 aaa.bbb.com"
>>
/etc/hosts
3. 修改
/etc/resolv
.conf文件(我这里是配置内网DNS)
1)先备份下
cp
/etc/resolv
.conf
/etc/resolv
.conf.bak
2)添加
echo
"nameserver 192.168.1.6"
>
/etc/resolv
.conf
4、修改
/etc/dnsmasq
.conf配置文件
sed
-i
's!#listen-address=.*!listen-address=192.168.1.6!g'
/etc/dnsmasq
.conf
echo
"address=/aaa.bbb.com/192.168.1.6"
>>
/etc/dnsmasq
.conf
5. 重启DNS服务
/etc/init
.d
/dnsmasq
restart
6、查看端口和进程
1)
netstat
-tupnl|
grep
dnsmasq
tcp 0 0 0.0.0.0:53 0.0.0.0:* LISTEN 2510
/dnsmasq
tcp6 0 0 :::53 :::* LISTEN 2510
/dnsmasq
udp 0 0 0.0.0.0:53 0.0.0.0:* 2510
/dnsmasq
udp6 0 0 :::53 :::* 2510
/dnsmasq
2)
ps
-ef|
grep
dnsmasq
dnsmasq 2510 1 0 14:51 ? 00:00:00
/usr/sbin/dnsmasq
-x
/var/run/dnsmasq/dnsmasq
.pid -u dnsmasq -7
/etc/dnsmasq
.d,.dpkg-dist,.dpkg-old,.dpkg-new
三、客户端测试(clientB clientC)
1、先备份下
cp
/etc/resolv
.conf
/etc/resolv
.conf.bak
2、添加
echo
"nameserver 192.168.1.6"
>
/etc/resolv
.conf
3、使用
ping
命令看下是否生效
ping
-c 5 aaa.bbb.com
PING aaa.bbb.com (192.168.1.6) 56(84) bytes of data.
64 bytes from aaa.bbb.com (192.168.1.6): icmp_req=1 ttl=64
time
=2.47 ms
64 bytes from aaa.bbb.com (192.168.1.6): icmp_req=2 ttl=64
time
=0.689 ms
64 bytes from aaa.bbb.com (192.168.1.6): icmp_req=3 ttl=64
time
=0.577 ms
64 bytes from aaa.bbb.com (192.168.1.6): icmp_req=4 ttl=64
time
=0.645 ms
64 bytes from aaa.bbb.com (192.168.1.6): icmp_req=5 ttl=64
time
=0.559 ms
--- aaa.bbb.com
ping
statistics ---
5 packets transmitted, 5 received, 0% packet loss,
time
4010ms
rtt min
/avg/max/mdev
= 0.559
/0
.988
/2
.473
/0
.744 ms
4、使用win7客户端测试(clientC)
|
本文转自 xdoujiang 51CTO博客,原文链接:http://blog.51cto.com/7938217/1642219,如需转载请自行联系原作者