Bind多域名配置

一、承上启下

https://www.cnblogs.com/eagle6688/p/17026162.html

上一篇我们配置了example.com的解析,本文我们尝试添加第二个域名test.com还有它的二级子域名mail.test.com。

二、配置

1. Forward配置

(1) options entry

sudo vi /etc/named.conf

添加以下配置:

#Add: Forward map for example.com
zone "test.com" IN {
         type master;
         file "test.com.fwd.db";
         allow-update { none; };
         notify no;
};

(2) Forward lookup文件

a. 新建文件:

sudo vi /var/named/test.com.fwd.db

b. 初始化内容:

; base zone file for test.com
$TTL 2d    ; default TTL for zone
$ORIGIN test.com. ; base domain-name

@ IN SOA ns1.example.com. root.test.com. (
        2023010801 ;Serial
        12h ;Refresh
        15m ;Retry
        3w ;Expire
        2h ;Minimum TTL
)

; Name Server RR for the domain
        IN NS ns1.example.com.

; A - Record of Name Server
ns1 IN A 10.8.0.1

; A - Record hostname test.com to IP address
@ IN A 10.8.0.5
www IN A 10.8.0.5
admin IN A 10.8.0.6

注意:

example.com和test.com需要共用一个域名解析服务器ns1.example.com;

$ORIGIN test.com指明了需要解析的域名;

我们在这里添加了三条解析:

@ 代表test.com本身;

www 代表www.test.com二级域名;

admin 代表admin.test.com二级域名。

2. reverse配置

因为新的test.com与example.com同属于10.8.0.0/25这个网段,所以需要共用同一个reverse文件:

(1) 编辑10.8.0.rev

sudo vi /var/named/10.8.0.rev

(2) 在末尾追加以下配置:

5     IN      PTR     example.com. ; fully qualified domain name (FQDN)
5     IN      PTR     www.example.com. ; fully qualified domain name (FQDN)
6     IN      PTR     admin.example.com. ; fully qualified domain name (FQDN)

3. 文件权限

sudo chmod 777 /var/named/test.com.fwd.db

4. 重启服务

sudo systemctl restart named

三、测试

1. forward

dig test.com
dig www.test.com
dig admin.test.com

2. reverse

dig -x 10.8.0.5
dig -x 10.8.0.6

四、参考

https://acloudguru.com/hands-on-labs/dns-and-bind-configuring-multiple-domains

https://systemzone.net/how-to-add-new-domains-to-bind-dns-server/

https://systemzone.net/dns-server-configuration-on-centos-7-caching-dns-with-bind/

posted @ 2023-01-15 15:41  白马黑衣  阅读(859)  评论(0)    收藏  举报