一.正向:
服务端:
root@localhost wzw\]# vim /etc/named.conf options { listen-on port 53 { 192.168.41.128; }; directory "/var/named"; allow-query { any; }; }; zone "openlab.com" IN { type master; file "openlab.zone"; }; \[root@localhost wzw\]# cd /var/named/ \[root@localhost named\]# ll 总用量 44 -rw-r-----. 1 root named 598 10月 31 19:54 192.168.41.arpa drwxrwx---. 2 named named 23 10月 29 20:15 data drwxrwx---. 2 named named 60 10月 29 21:15 dynamic -rw-r--r--. 1 named named 821 10月 31 20:35 managed-keys.bind -rw-r--r--. 1 named named 1717 10月 31 20:35 managed-keys.bind.jnl -rw-r--r--. 1 root root 192 10月 31 20:28 named.192 -rw-r-----. 1 root named 2253 9月 20 2023 named.ca -rw-r-----. 1 root named 152 9月 20 2023 named.empty -rw-r-----. 1 root named 152 9月 20 2023 named.localhost -rw-r-----. 1 root named 168 9月 20 2023 named.loopback -rw-r-----. 1 root named 152 9月 20 2023 named.openlab -rw-r--r--. 1 root root 184 10月 31 20:22 named.openlab.com drwxrwx---. 2 named named 6 9月 20 2023 slaves \[root@localhost named\]# cp -a named.localhost openlab.zone \[root@localhost named\]# vim /var/named/openlab.zone $TTL 1D @ IN SOA dns.openlab.com. test.163.com ( 0 1D 1H 1W 3H ) IN NS dns.openlab.com. IN MX 10 mail.openlab.com. dns.openlab.com. IN A 192.168.41.160 mail.openlab.com. IN A 192.168.41.161 www.openlab.com. IN A 192.168.41.160 \[root@localhost named\]# named-checkconf /etc/named.conf \[root@localhost named\]# named-checkzone openlab.com /var/named/openlab.zonezone openlab.com/IN: loaded serial 0 OK \[root@localhost named\]# systemctl restart named 客户端 nslookup www.openlab.com Server: 192.168.41.128 Address: 192.168.41.128#53 Name: www.openlab.com Address: 192.168.41.160 \[root@localhost wzw\]# nslookup mail.openlab.com Server: 192.168.41.128 Address: 192.168.41.128#53 Name: mail.openlab.com Address: 192.168.41.161 二.反向: 服务端: \[root@localhost wzw\]# vim /etc/named.conf zone "41.168.192.in-addr.arpa" IN { type master; file "41.168.192.zone"; }; \[root@localhost wzw\]# vim /var/named/41.168.192.zone $TTL 1D @ IN SOA dns.openlab.com. test.163.com ( 0 1D 1H 1W 3H ) IN NS dns.openlab.com. 160 IN PTR dns.openlab.com 161 IN PTR mail.openlab.com 160 IN PTR www.openlab.com \[root@localhost wzw\]# named-checkconf /etc/named.conf \[root@localhost wzw\]# named-checkzone 41.168.192 /var/named/41.168.192.zone zone 2.168.192/IN: loaded serial 0 OK \[root@localhost wzw\]# systemctl restart named \[root@localhost wzw\]# nslookup 192.168.41.160 160.41.168.192.in-addr.arpa name = dns.openlab.com.41.168.192.in-addr.arpa.