部署bind解析域名
Posted chenxiaoweiworkinghard
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了部署bind解析域名相关的知识,希望对你有一定的参考价值。
部署主DNS服务器
安装bind
yum install bind-chroot bind-utils -y
迭代查询 返回dns服务器地址
递归查询 返回查询结果
修改主配置文件
vim /etc/named.conf
1 //
2 // named.conf
3 //
4 // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
5 // server as a caching only nameserver (as a localhost DNS resolver only).
6 //
7 // See /usr/share/doc/bind*/sample/ for example named configuration files.
8 //
9 // See the BIND Administrator‘s Reference Manual (ARM) for details about the
10 // configuration located in /usr/share/doc/bind-{version}/Bv9ARM.html
11 options {
12 listen-on port 53 { any; };#对所有IP提供解析服务
13 directory "/var/named";
14 dump-file "/var/named/data/cache_dump.db";
15 statistics-file "/var/named/data/named_stats.txt";
16 memstatistics-file "/var/named/data/named_mem_stats.txt";
17 allow-query { any; };#允许所有IP发起查询请求
18 forwarders {8.8.8.8;};#允许转发查询
19 /*
20 - If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
21 - If you are building a RECURSIVE (caching) DNS server, you need to enable
22 recursion.
23 - If your recursive DNS server has a public IP address, you MUST enable access
24 control to limit queries to your legitimate users. Failing to do so will
25 cause your server to become part of large scale DNS amplification
26 attacks. Implementing BCP38 within your network would greatly
27 reduce such attack surface
28 */
29 recursion yes;
30
31 dnssec-enable yes;
32 dnssec-validation yes;
33
34 /* Path to ISC DLV key */
35 bindkeys-file "/etc/named.iscdlv.key";
36
37 managed-keys-directory "/var/named/dynamic";
38
39 pid-file "/run/named/named.pid";
40 session-keyfile "/run/named/session.key";
41 };
42
43 logging {
44 channel default_debug {
45 file "data/named.run";
46 severity dynamic;
47 };
48 };
49
50 zone "." IN {
51 type hint;
52 file "named.ca";
53 };
54
55 include "/etc/named.rfc1912.zones";
56 include "/etc/named.root.key";
添加个人域名
正向解析
vim /etc/named.rfc1912.zones
1 // named.rfc1912.zones:
2 //
3 // Provided by Red Hat caching-nameserver package
4 //
5 // ISC BIND named zone configuration for zones recommended by
6 // RFC 1912 section 4.1 : localhost TLDs and address zones
7 // and http://www.ietf.org/internet-drafts/draft-ietf-dnsop-default-local-zones-02.txt
8 // (c)2007 R W Franks
9 //
10 // See /usr/share/doc/bind*/sample/ for example named configuration files.
11 //
12 zone "8kb24.cn" IN {
13 type master;
14 file "8kb24.cn.zone";
15 allow-update {none;};
16 };
17 zone "121.168.192.in-addr.arpa" IN{
18 type master;
19 file "192.168.121.arpa";
20 allow-update {none;};
21 };
编辑正向解析zone文件
vim /var/named/8kb24.cn.zone
1 $TTL 1D
2 @ IN SOA 8kb24.cn. test.163.com. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS ns.8kb24.cn.
9 A 192.168.121.11
10 ns IN A 192.168.121.11
11 www IN A 192.168.121.11
12 IN MX 10 mail.8kb24.cn.
13 mail IN A 192.168.121.11
14 host IN CNAME www
编辑反向解析zone文件
vim /var/named/192.168.121.arpa
1 $TTL 1D
2 @ IN SOA 8kb24.cn. test.163.com. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS ns.8kb24.cn.
9 A 192.168.121.11
10 11 PTR ns.8kb24.cn.
11 11 PTR www.8kb24.cn.
12 11 PTR mail.8kb24.cn.
13 11 PTR host.8kb24.cn.
修改zone文件属主属组
chown root.named /var/named/192.68.121.arpa
chown root.named /var/named/8kb24.cn.zone
启动named
systemctl enable named
systemclt start named
开放防火墙端口
firewall-cmd --zone=public --permanent --add-port=53/tcp
firewall-cmd --zone=public --permanent --add-port=53/udp
firewall-cmd --reload
部署从DNS服务器
安装bind
yum install -y bind-chroot bind-utils -y
修改主DNS服务器配置文件
vim /etc/named.rfc1912.zones
1 zone "8kb24.cn" IN {
2 type master;
3 file "8kb24.cn.zone";
4 allow-update { 192.168.121.12; };
5 };
6
7
8 zone "121.168.192.in-addr.arpa" IN {
9 type master;
10 file "192.168.121.arpa";
11 allow-update {192.168.121.12; };
12 };
修改从DNS服务器配置文件
vim /etc/named.rfc1912.zones
1 zone "8kb24.cn" IN {
2 type slave;
3 masters { 192.168.121.11; };
4 file "slaves/8kb24.cn.zone";
5 };
6
7 zone "121.168.192.in-addr.arpa" IN {
8 type slave;
9 masters { 192.168.121.11;};
10 file "slaves/192.168.121.arpa";
11 };
启动从DNS服务器
systemctl enable named
systemctl start named
重启主DNS服务器
systemctl restart named
[[email protected] slaves]# ll /var/named/slaves
total 8
-rw-r--r-- 1 named named 385 Sep 22 15:12 192.168.121.arpa
-rw-r--r-- 1 named named 268 Sep 22 15:12 8kb24.cn.zone
主从服务器加密传输
主DNS服务器生成密钥
[email protected] ~]# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST chenxiaowei
Kchenxiaowei.+157+53919
[[email protected] ~]# cat Kchenxiaowei.+157+53919.key
chenxiaowei. IN KEY 512 3 157 xRVknXER5gnr4QL1r8atlg==
创建密钥文件(主从服务器都一样)
vim /var/named/chroot/etc/chenxiaowei.key
1 key "chenxiaowei" {
2 algorithm hmac-md5;
3 secret "xRVknXER5gnr4QL1r8atlg==";
4 };
chown root.named /var/named/chroot/etc/chenxiaowei.key
ln /var/named/chroot/etc/chenxiaowei.key /etc/
修改主DNS服务器的配置文件
vim /etc/named.conf
include "/etc/chenxiaowei.key";
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; };
allow-transfer {key chenxiaowei; };
forwarders{8.8.8.8;};
修改从DNS服务器的配置文件
vim /etc/named.conf
1 include "/etc/chenxiaowei.key";
2 server 192.168.121.11
3 { keys { chenxiaowei ;} ;};
重启主从服务器named服务
systemctl restart named
分散解析
vim /etc/named.rfc1912.zones
1 acl "gz" {192.168.221.0/24}
2 acl "sz" {192.168.222.0/24}
3 view "gz" {
4 match-clients{"gz";};
5 zone "8kb24.cn"{
6 type master;
7 file "8kb24.cn..gz.zone";
8 };
9 };
10
11 view "sz" {
12 match-clients{"sz";};
13 zone "8kb24.cn"{
14 type master;
15 file "8kb24.cn.sz.zone";
16 };
17 };
vim /var/named/8kb24.cn.gz.zone
1 $TTL 1D
2 @ IN SOA 8kb24.cn. test.163.com. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS ns.8kb24.cn.
9 A 192.168.121.11
10 ns IN A 192.168.121.11
11 www IN A 192.168.121.11
12 IN MX 10 mail.8kb24.cn.
13 mail IN A 192.168.121.11
14 host IN CNAME www
vim /var/named/8kb24.cn.sz.zone
1 $TTL 1D
2 @ IN SOA 8kb24.cn. test.163.com. (
3 0 ; serial
4 1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS ns.8kb24.cn.
9 A 192.168.121.11
10 ns IN A 192.168.121.11
11 www IN A 192.168.121.11
12 IN MX 10 mail.8kb24.cn.
13 mail IN A 192.168.121.11
14 host IN CNAME www
以上是关于部署bind解析域名的主要内容,如果未能解决你的问题,请参考以下文章