目标:创建区域huhaiqing.com
1、安装bind
1
2
3
|
yum install -y bind\*
chkconfig named on service named start |
2、修改主配置/etc/named.conf文件如下
#需要修改的选项:listen-on、listen-on、allow-query
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
|
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { listen-on port 53 { any; }; listen-on-v6 port 53 { any; }; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug {
file "data/named.run";
severity dynamic;
};
}; zone "." IN { type hint; file "named.ca"; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key"; |
3、修改配置文件/etc/named.rfc1912.zones,添加正向和反向区域
1
2
3
4
5
6
7
8
|
zone "huhaiqing.com." IN { type master; file "huhaiqing.com.zone"; }; zone "106.13.10.in-addr.arpa" IN { type master;
file "10.13.106.zone";
}; |
4、添加正向区域文件/var/named/huhaiqing.com.zone
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
$TTL 86400 @ IN SOA zabbix.huhaiqing.com. admin.huhaiqing.com. ( 2016060901
1H
10M
7D
1D
)
@ IN NS zabbix zabbix IN A 10.13.106.11 software IN A 10.13.106.11 nfs IN A 10.13.106.11 test1 IN A 10.13.106.30 test2 IN A 10.13.106.31 |
5、添加反向区域文件 /var/named/10.13.106.zone
1
2
3
4
5
6
7
8
9
10
11
|
$TTL 86400 @ IN SOA zabbix.huhaiqing.com. admin.zabbix.huhaiqing.com. ( 2016060901
1H
10M
7D
1D
)
@ IN NS zabbix.huhaiqing.com. 31 IN PTR test2.huhaiqing.com. 30 IN PTR test1.huhaiqing.com. |
6、重启服务
1
|
service named restart |
7、测试
1
2
3
4
5
6
7
8
9
10
|
[root@test2 ~] # ping test1
PING test1.huhaiqing.com (10.13.106.30) 56(84) bytes of data. 64 bytes from test1.huhaiqing.com (10.13.106.30): icmp_seq=1 ttl=64 time =0.165 ms
64 bytes from test1.huhaiqing.com (10.13.106.30): icmp_seq=2 ttl=64 time =0.557 ms
64 bytes from test1.huhaiqing.com (10.13.106.30): icmp_seq=3 ttl=64 time =0.543 ms
64 bytes from test1.huhaiqing.com (10.13.106.30): icmp_seq=4 ttl=64 time =0.353 ms
[root@test2 ~] # nslookup 10.13.106.30
Server:10.13.106.30 Address:10.13.106.30 #53
30.106.13.10. in -addr.arpaname = test1.huhaiqing.com.
|
注意:
ping目标主机时,如果目标主机的格式为:xxx.huhaiqing.com,则ping xxx可以通,否则只能通过ping xxx.huhaiqing.com测试主机是否在线。
本文转自1321385590 51CTO博客,原文链接:http://blog.51cto.com/linux10000/1787751,如需转载请自行联系原作者