DNS正反向解析,区域备份
DNS作业
正反向解析:
关闭防火墙、selinux:
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld.service
编写配置文件:
[root@localhost ~]# vim /etc/named.conf
编写数据配置文件
[root@localhost ~]# cp -a /var/named/named.localhost /var/named/named.192
cp: overwrite '/var/named/named.192'? y
[root@localhost ~]# vim /var/named/named.192
[root@localhost ~]# vim /var/named/named.openlab.com
[root@localhost ~]# systemctl restart named
测试:
[root@localhost ~]# nslookup
> server 192.168.36.131
> Default server: 192.168.36.131
> Address: 192.168.36.131#53
> www.openlab.com
> Server: 192.168.36.131
> Address: 192.168.36.131#53
Name: www.openlab.com
Address: 192.168.36.33
dig解析测试:
[root@localhost ~]# dig www.openlab.com @192.168.36.131
; <<>> DiG 9.16.23-RH <<>> www.openlab.com @192.168.36.131
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62608
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: d69077111ae8183201000000672982db97c2eb04161ee260 (good)
;; QUESTION SECTION:
;www.openlab.com. IN A
;; ANSWER SECTION:
www.openlab.com. 86400 IN A 192.168.36.33
;; Query time: 0 msec
;; SERVER: 192.168.36.131#53(192.168.36.131)
;; WHEN: Tue Nov 05 10:28:43 CST 2024
;; MSG SIZE rcvd: 88
正向解析:
options {
listen-on port 53 { 192.168.36.131; };
directory "/var/named";
allow-query { any; };
};
zone "openlab.com" IN {
type master;
file "named.openlab.com";
};
反向解析:
zone "36.168.192.in-addr.arpa" IN {
type master;
file "named.192";
allow-update { none; };
};
区域备份
主服务器:
关闭防火墙、selinux:
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld.service
设置静态IP:
[root@localhost named]# nmcli c modify ens160 ipv4.method manual ipv4.addresses '192.168.36.131/24' ipv4.gateway '192.168.36.2' ipv4.dns '192.168.36.131'
[root@localhost named]# nmcli c reload
[root@localhost named]# nmcli c up ens160
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
编写配置文件,子配置文件:
[root@localhost ~]# vim /etc/named.conf
[root@localhost ~]# vim /etc/named.rfc1912.zones
[root@localhost ~]# cd /var/named
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
编写模块配置文件:
[root@localhost named]# cp -a named.localhost named.openlab.com
[root@localhost named]# vim named.openlab.com
[root@localhost named]# cp -a named.loopback named.192
[root@localhost named]# vim /var/named/named.192
[root@localhost named]# systemctl restart named
从服务器:
关闭防火墙、selinux:
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0
编写配置文件,子配置文件:
[root@localhost ~]# vim /etc/named.conf
[root@localhost ~]# vim /etc/named.rfc1912.zones
编写模块文件:
[root@localhost ~]# cd /var/named/slaves
[root@localhost slaves]# ls
[root@localhost slaves]# cd
[root@localhost ~]# cd /var/named/slaves
[root@localhost slaves]# systemctl start named
测试:
[root@localhost ~]# nslookup www.openlab.com
Server: 192.168.36.132
Address: 192.168.36.132#53
Name: www.openlab.com
Address: 192.168.36.131
[root@localhost ~]# dig @192.168.36.131 www.openlab.com
; <<>> DiG 9.16.23-RH <<>> @192.168.36.131 www.openlab.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 59195
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 043868bb84985e9201000000672996b5a8fd6370c35dbe17 (good)
;; QUESTION SECTION:
;www.openlab.com. IN A
;; ANSWER SECTION:
www.openlab.com. 86400 IN A 192.168.36.131
;; Query time: 2 msec
;; SERVER: 192.168.36.131#53(192.168.36.131)
;; WHEN: Tue Nov 05 11:53:25 CST 2024
;; MSG SIZE rcvd: 88
主服务器配置文件,子配置文件,数据模块文件:
从服务器配置文件,子配置文件: