DNS server configuration

1. Mount the CD

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
vim /etc/fstab
/dev/cdrom      /mnt/cdrom iso9660      defaults        0 0

2. Create yum source

[root@centos7-1 xwk]# yum-config-manager --add-repo=file:///mnt/cdrom
 Plug in loaded: fastestmirror, langpacks
adding repo from: file:///mnt/cdrom
Cannot add repo from file:///mnt/cdrom as is a duplicate of an existing repo
[root@centos7-1 xwk]# 

[root@centos7-1 xwk]# cd /etc/yum.repos.d/
[root@centos7-1 yum.repos.d]# ls
CentOS-Base.repo.bak   CentOS-fasttrack.repo  CentOS-Vault.repo
CentOS-CR.repo         CentOS-Media.repo      mnt_cdrom.repo
CentOS-Debuginfo.repo  CentOS-Sources.repo
[root@centos7-1 yum.repos.d]# 

vim mnt_cdrom.repo 

[mnt_cdrom]
name=added from: file:///mnt/cdrom
baseurl=file:///mnt/cdrom
enabled=1
gpgcheck=0

[root@centos7-1 yum.repos.d]# yum clean all
 Plug in loaded: fastestmirror, langpacks
 Cleaning up software source: mnt_cdrom
Cleaning up everything
Cleaning up list of fastest mirrors
[root@centos7-1 yum.repos.d]# 

[root@centos7-1 yum.repos.d]# yum list
 Plug in loaded: fastestmirror, langpacks
mnt_cdrom                                                | 3.6 kB     00:00     
(1/2): mnt_cdrom/group_gz                                  | 155 kB   00:00     
(2/2): mnt_cdrom/primary_db                                | 3.0 MB   00:00     
Determining fastest mirrors

3. Install DNS Service

Everyone's installation package name may be different, according to their own modifications.

[root@centos7-1 Packages]# cd /mnt/cdrom/Packages/
[root@centos7-1 Packages]# rpm -ivh bind-9.9.4-37.el7.x86_64.rpm 
Warning: bind-9.9.4-37.el7.x86_64.rpm: head V3 RSA/SHA256 Signature, secret key ID f4a80eb5: NOKEY
 In preparation...                          ################################# [100%]
	software package bind-32:9.9.4-37.el7.x86_64 Already installed
[root@centos7-1 Packages]# rpm -ivh bind-chroot-9.9.4-37.el7.x86_64.rpm 
Warning: bind-chroot-9.9.4-37.el7.x86_64.rpm: head V3 RSA/SHA256 Signature, secret key ID f4a80eb5: NOKEY
 In preparation...                          ################################# [100%]
	software package bind-chroot-32:9.9.4-37.el7.x86_64 Already installed
[root@centos7-1 Packages]# 

Configure / etc / named Conf file

ip is configured according to your actual needs

Check configuration file syntax

[root@centos7-1 /]# named-checkconf /etc/named.conf 
[root@centos7-1 /]# 

No result is returned, indicating that there is no problem with the file configuration. Otherwise, modify the configuration file according to the error information.

Add service startup and operation

[root@centos7-1 /]# systemctl enable named
[root@centos7-1 /]# 

4. Configure forward area

Modify / etc / named rfc1912. Zones file

Add to it

Check configuration file syntax

[root@centos7-1 /]# named-checkconf /etc/named.rfc1912.zones 
[root@centos7-1 /]# 

No result is returned, indicating that there is no problem with the file configuration. Otherwise, modify the configuration file according to the error information.

Create forward resolution file

Edit the domain name and file name according to your needs

cd /var/named
cp -p named.localhost xwk.com.zone

Edit XWK com. zone

vim /var/named/xwk.com.zone

Check file syntax

[root@centos7-1 /]# named-checkzone "xwk.com" /var/named/xwk.com.zone 
zone xwk.com/IN: loaded serial 0
OK
[root@centos7-1 /]# 

There are no errors in the display file

Modify file permissions or user groups

[root@centos7-1 /]# chgrp named /var/named/xwk.com.zone 
[root@centos7-1 /]#

Restart service

[root@centos7-1 /]# systemctl restart named
[root@centos7-1 /]# 

5. Configure reverse area

Modify / etc / named rfc1912. Zones file

Add to it

Check configuration file syntax

[root@centos7-1 /]# named-checkconf /etc/named.rfc1912.zones 
[root@centos7-1 /]# 

No result is returned, indicating that there is no problem with the file configuration. Otherwise, modify the configuration file according to the error information.

Create reverse parse file

cd /var/named
cp -p named.loopback local.txt

Edit local Txt file

vim /var/named/local.txt 

Check file syntax

[root@centos7-1 /]# named-checkzone "10.168.192.in-addr.arpa" /var/named/local.txt 
zone 10.168.192.in-addr.arpa/IN: loaded serial 0
OK
[root@centos7-1 /]# 

No result is returned, indicating that there is no problem with the file configuration. Otherwise, modify the configuration file according to the error information.

Modify file permissions or user groups

[root@centos7-1 /]# chgrp named /var/named/local.txt 
[root@centos7-1 /]# 

Restart service

[root@centos7-1 /]# systemctl restart named[root@centos7-1 /]# 

6. Turn off the firewall

[root@centos7-1 /]# systemctl stop firewalld.service
[root@centos7-1 /]# systemctl status firewalld.service
‚óŹ firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
[root@centos7-1 /]# systemctl disable firewalld.service
[root@centos7-1 /]# 

7. Modify / etc / resolv Conf file

8. Test DNS Service

Forward parsing test

[root@centos7-1 /]# nslookup
> www.xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

Name:	www.xwk.com
Address: 192.168.1.9
> 

Reverse parsing test

> 192.168.10.1
Server:		192.168.10.1
Address:	192.168.10.1#53

1.10.168.192.in-addr.arpa	name = dns.xwk.com.
> 

Test CNAME (alias) resource record

> set type=cname
> bbs.xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

bbs.xwk.com	canonical name = www.xwk.com.xwk.com.
> 

Test MX (mail exchange) resource record

> set type=mx
> xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

xwk.com	mail exchanger = 10 mail.xwk.com.
> 

Test SOA (initial authority) resource record

> set type=soa
> xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

xwk.com
	origin = dns.xwk.com
	mail addr = rname.invalid
	serial = 0
	refresh = 86400
	retry = 3600
	expire = 604800
	minimum = 10800
> 

Test NS (name server) resource record

> set type=ns
> xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

xwk.com	nameserver = dns.xwk.com.
> 

Test load balancing

> set type=a
> www.xwk.com
Server:		192.168.10.1
Address:	192.168.10.1#53

Name:	www.xwk.com
Address: 192.168.1.9
> 

9. Create a secondary domain name server

Another virtual machine, with ip 192.168.10.2, can communicate with each other.

Configure / etc / named Conf and / etc / named rfc1912. Zones file
Same as primary server

Close the firewall and modify / etc / resolv Conf file

Start named

[root@centos7-2 xwk]# service named start
Redirecting to /bin/systemctl start  named.service
[root@centos7-2 xwk]# 

Test secondary server

[root@centos7-2 xwk]# cd /var/named/slaves/
[root@centos7-2 slaves]# ll
 Total consumption 8
-rw-r--r--. 1 named named 573 4 August 12:27 local.txt
-rw-r--r--. 1 named named 587 4 August 12:27 xwk.com.zone
[root@centos7-2 slaves]# 

Keywords: Linux Operation & Maintenance CentOS yum

Added by hcdarkmage on Tue, 08 Mar 2022 19:49:26 +0200