mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
vim /etc/fstab
/dev/cdrom /mnt/cdrom iso9660 defaults 0 0
[root@centos7-1 xwk]# yum-config-manager --add-repo=file:///mnt/cdrom
已加载插件: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
已加载插件:fastestmirror, langpacks
正在清理软件源: 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
已加载插件: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
每个人的安装包名称可能不一样,根据自己的修改。
[root@centos7-1 Packages]# cd /mnt/cdrom/Packages/
[root@centos7-1 Packages]# rpm -ivh bind-9.9.4-37.el7.x86_64.rpm
警告:bind-9.9.4-37.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
软件包 bind-32:9.9.4-37.el7.x86_64 已经安装
[root@centos7-1 Packages]# rpm -ivh bind-chroot-9.9.4-37.el7.x86_64.rpm
警告:bind-chroot-9.9.4-37.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
软件包 bind-chroot-32:9.9.4-37.el7.x86_64 已经安装
[root@centos7-1 Packages]#
[root@centos7-1 /]# named-checkconf /etc/named.conf
[root@centos7-1 /]#
没有返回结果说明文件配置没有问题,否则根据报错信息修改配置文件。
[root@centos7-1 /]# systemctl enable named
[root@centos7-1 /]#
[root@centos7-1 /]# named-checkconf /etc/named.rfc1912.zones
[root@centos7-1 /]#
没有返回结果说明文件配置没有问题,否则根据报错信息修改配置文件。
根据自己需求编辑域名和文件名
cd /var/named
cp -p named.localhost xwk.com.zone
vim /var/named/xwk.com.zone
[root@centos7-1 /]# named-checkzone "xwk.com" /var/named/xwk.com.zone
zone xwk.com/IN: loaded serial 0
OK
[root@centos7-1 /]#
显示文件没有错误
[root@centos7-1 /]# chgrp named /var/named/xwk.com.zone
[root@centos7-1 /]#
[root@centos7-1 /]# systemctl restart named
[root@centos7-1 /]#
[root@centos7-1 /]# named-checkconf /etc/named.rfc1912.zones
[root@centos7-1 /]#
没有返回结果说明文件配置没有问题,否则根据报错信息修改配置文件。
cd /var/named
cp -p named.loopback local.txt
vim /var/named/local.txt
[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 /]#
没有返回结果说明文件配置没有问题,否则根据报错信息修改配置文件。
[root@centos7-1 /]# chgrp named /var/named/local.txt
[root@centos7-1 /]#
[root@centos7-1 /]# systemctl restart named[root@centos7-1 /]#
[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 /]#
[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
>
> 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.
>
> 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.
>
> set type=mx
> xwk.com
Server: 192.168.10.1
Address: 192.168.10.1#53
xwk.com mail exchanger = 10 mail.xwk.com.
>
> 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
>
> set type=ns
> xwk.com
Server: 192.168.10.1
Address: 192.168.10.1#53
xwk.com nameserver = dns.xwk.com.
>
> 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
>
另一台虚拟机,ip 为 192.168.10.2,两台虚拟机之间可以互相通信。
配置 /etc/named.conf 和 /etc/named.rfc1912.zones 文件
与主服务器相同
执行关闭防火墙操作和修改/etc/resolv.conf 文件
[root@centos7-2 xwk]# service named start
Redirecting to /bin/systemctl start named.service
[root@centos7-2 xwk]#
[root@centos7-2 xwk]# cd /var/named/slaves/
[root@centos7-2 slaves]# ll
总用量 8
-rw-r--r--. 1 named named 573 4月 8 12:27 local.txt
-rw-r--r--. 1 named named 587 4月 8 12:27 xwk.com.zone
[root@centos7-2 slaves]#