DNS


------------------DNS主服务器正解搭建 tcp/udp53---------------------------
服务器操作:
1.#yum install bind [安装服务]
2.通过模板生成dhcp配置文件
#vim /etc/named.conf [配置文件]
options {
listen-on 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; };

};

logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};

zone "." IN {
type hint;
file "named.ca";
};


zone "yht.edu" IN {
type master;
file "yht.db";
};
3.#vim /var/named/yht.db[建正解区域数据库]
$TTL 3H
@ IN SOA ns.yht.edu. root.yht.edu. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
IN NS ns.yht.edu.
ns IN A 192.168.10.5
www IN A 192.168.1.1
ftp IN CNAME www.yht.edu.
mail IN A 192.168.2.1
@ IN MX 1 mail.yht.edu.
4.#chown named.named yht.db[修改数据库属主、属组为named]
5.#systemctl restart named[重启数据库]

客户端操作:
1.#nslookup www.yht.edu 192.168.10.5 [查看解析情况]
2.#vim /etc/resolv.conf [配置文件]
search yht.edu
nameserver 192.168.10.5
#nslookup www [查看]
#dig
#host


-------------------DNS反解搭建-------------------------------
服务器操作:
1.#vim /etc/named.conf[修改配置文件添加反解ZONE]

zone "10.168.192.in-addr.arpa." IN {
type master;
file "db.yht";
};
2.#vim /var/named/db.yht
$TTL 3H
@ IN SOA ns.yht.edu. root.yht.edu. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS yht.edu.
5 IN PTR ns.yht.edu.
101 IN PTR www.yht.edu.
102 IN PTR mail.yht.edu.
101 IN PTR ftp.yht.edu.
3.#chown named. db.yht[修改属组、属主] #systemctl restart named[重启]

客户端配置:
1.#vim /etc/resolv.conf
search yht.edu→域名
nameserver 192.168.10.5→DNS服务器IP
#dig -x 192.168.10.5
#nslooup -t 192.168.10.5


----------------------------DNS辅服务器搭建----------------------------------
辅服务器操作:
1.#yum install bind [安装服务]
2.#vim /etc/named.conf[修改配置文件添加辅服务器ZONE]
options {
listen-on 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; };

zone "yht.edu" IN {
type slave;→指定服务器类型
file "slaves/yht.edu.zone";→和服务器数据库同一数据库,不用手动写,自动生成
masters { 192.168.10.5; };→指向服务器IP
3.#named-checkconf →检查配置文件
4.#systemctl restart named[启动服务]
5.#cd /var/named/slaves [查看确认文件yht.edu.zone是否生成]

主服务器配置:
1.#vim /etc/named.conf [添加指定辅服务器IP语句]
allow-transfer { 192.168.10.10; };→IP是辅服务器IP
2.#systemctl restart named [重启]



-------------------------------------DNS转服服务器搭建--------------------------------------
转发服务器操作:
1.#yum install bind -y[安装服务]
2.#vim /etc/named.conf [指定查询请求转发到的远程域名服务器的IP地址]
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
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; };
forward only; →仅转发
forwarders { →指定转发DNS服务器IP地址
192.168.10.5; →主
192.168.10.10; →辅
};
};

或指定zone "." IN {
type hint;
file "named.ca";
};

zone "yht.edu" IN {
type forward;
forwarders {
192.168.10.5;
192.168.10.10; };
forward only;

};

3.#重启namd服务
4.客户端测试


----------------------------------------DNS委派-----------------------------------------
主服务器操作:
1.#vim /etc/named.conf →指定新的zone
options {
directory "/var/named";
};
zone "edu." {
type master;
file "named.edu”;
};
2.#cd /var/named #vim named.edu
$TTL 3H
@ IN SOA ns.edu. root.edu. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS ns.edu.
ns.edu. IN A 192.168.10.5→edu.由本服务器解析
www.edu IN A 192.168.10.34
dongbei.edu IN A 192.168.10.35
yht.edu. IN NS www.yht.edu.→将yht.edu委派给10.15
www.yht.edu. IN A 192.168.10.15
3.#systemctl restart named [重启服务]

委派服务器配置:
1.#vim /etc/named.conf →指定新的zone
options {
directory "/var/named";
};
zone "yht.edu." {
type master;
file "yht.db”;
};
2.#cd /var/named #yht.db
3.$TTL 3H
@ IN SOA www.yht.edu. root.yht.edu. (
                                         0 ; serial
                                        1D ; refresh
                                        1H ; retry
                                        1W ; expire
                                        3H ) ; minimum
@                         NS                www.yht.edu.
www.yht.edu.         A                 192.168.10.15→本机IP
haha.yht.edu.        A                  192.168.10.101
mail.yht.edu.          A                  192.168.10.102


4.#chown named.named yht.db[修改属组、属主]

#systemctl restart named[重启]

posted @ 2019-09-16 15:51  yanghaitao  阅读(200)  评论(0编辑  收藏  举报