1. 安装bind服务
yum -y install bind
2. 修改named配置文件
- /etc/named.conf
13 listen-on port 53 { any; }; //修改为any;
14 listen-on-v6 port 53 { any; }; //修改为any;
15 directory "/var/named";
16 dump-file "/var/named/data/cache_dump.db";
17 statistics-file "/var/named/data/named_stats.txt";
18 memstatistics-file "/var/named/data/named_mem_stats.txt";
19 recursing-file "/var/named/data/named.recursing";
20 secroots-file "/var/named/data/named.secroots";
21 allow-query { any; }; //修改为any;
- /etc/named.rfc1912.zones
在该文件中添加需要解析的域名,这里解析的分别是 www.rj.com,ftp.rj.com
12 zone "rj.com" IN { //正向解析
13 type master;
14 file "rj.com.zone"; //文件名后缀可自定义
15 allow-update { none; };
16 };
17
18 zone "50.16.172.in-addr.arpa" IN { //反向解析
19 type master;
20 file "50.16.172.local"; //文件名后缀可自定义
21 allow-update { none; };
22 };
3. 添加对应的文件
cd /var/named/
cp named.localhost rj.com.zone
cp named.localhost 50.16.172.local
4. 修改正向解析文件
1 $TTL 1D
2 @ IN SOA rj.com. rname.invalid. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS @
9 A 127.0.0.1
10 AAAA ::1
11 www IN A 172.16.50.8
12 ftp IN A 172.16.50.8
5. 修改反向解析文件
1 $TTL 1D
2 @ IN SOA rj.com. rname.invalid. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS @
9 AAAA ::1
10 8 PTR www.rj.com.
11 8 PTR ftp.rj.com.
6. 测试
将测试机器的dns服务器地址填写为centos7地址,使用nslookup
测试是否解析成功