// If there is a firewall between you and nameservers you want // to talk to, you may need to fix the firewall to allow multiple // ports to talk. See http://www.korg/vuls/id/800113
// If your ISP provided one or more IP addresses for stable // nameservers, you probably want to use them as forwarders. // Uncomment the following block, and insert the addresses replacing // the all-0's placeholder.
// DNS 转发器,用于设定该 DNS 解析服务器无法进行当前域名解析的情况下,进行转发解析的 DNS 地址 forwarders { 114.114.114.114; 8.8.8.8; };
//======================================================================== // If BIND logs error messages about the root key being expired, // you will need to update your keys. See https://www.isc.org/bind-keys //======================================================================== dnssec-validation auto; auth-nxdomain no;
; ; BIND data file for local loopback interface ; $TTL 604800 @ IN SOA customer.com. root.customer.com. ( 2 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS localhost. @ IN A 127.0.0.1 ;@ IN AAAA ::1 dhcp IN A 102.168.1.201 ntp IN A 192.168.1.203 ftp IN A 192.168.1.204 dns IN A 192.168.1.202
3.2.反向解析文件:db.168.192 配置内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
; ; BIND reverse data file for local loopback interface ; $TTL 604800 @ IN SOA customer.com. root.customer.com. ( 1 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS localhost. 1.0.0 IN PTR localhost. 201.1 IN PTR dhcp 203.1 IN PTR ntp 204.1 IN PTR ftp 202.1 IN PTR dns
检查配置及启动服务
1.执行命令,检查正向解析和反向解析 配置文件是否正确:
1 2 3 4 5 6 7 8 9 10 11 12
# 主配置文件检查 leazhi@ubuntu2204-001:~$ sudo named-checkconf /etc/bind/named.conf # 正向解析文件配置检查 leazhi@ubuntu2204-001:~$ sudo named-checkzone customer.com /etc/bind/zones/db.customer.com zone customer.com/IN: loaded serial 2 OK # 反向解析文件配置检查 leazhi@ubuntu2204-001:~$ sudo named-checkzone 168.192.in-addr.arpa /etc/bind/zones/db.customer.com zone 168.192.in-addr.arpa/IN: loaded serial 2 OK
2.启动bind服务:
1
sudo systemctl enable --now named.service
3.检查bind服务是否启动:
1 2 3 4 5 6 7 8 9 10 11 12
leazhi@ubuntu2204-001:~$ sudo systemctl status named.service ● named.service - BIND Domain Name Server Loaded: loaded (/lib/systemd/system/named.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2023-09-03 02:12:12 UTC; 37min ago Docs: man:named(8) Process: 15851 ExecStart=/usr/sbin/named $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 15852 (named) Tasks: 4 (limit: 935) Memory: 4.3M CPU: 188ms CGroup: /system.slice/named.service └─15852 /usr/sbin/named -u bind -4