linux系统Centos7搭建DNS服务器
时间:2023-06-01 09:42:02 | 来源:网站运营
时间:2023-06-01 09:42:02 来源:网站运营
linux系统Centos7搭建DNS服务器:1、配置IP地址
服务器
IPADDR= 192.168.1.1
NETMASK=255.255.255.0
客户机
IPADDR=192.168.1.254
NETMASK=255.255.255.0
DNS1=192.168.1.1
2、关闭防火墙和Selinux
systemctl stop firewalld
setenforce 0 或 vim /etc/sysconfig /selinux
3、yum安装bind
[root@localhost ~]# vim /etc/yum.repos.d/yum.repo
添加:
[yum]
name=yum
baseurl=file:///media/
enabled=1
gpgcheck=0
[root@localhost ~]# yum list
[root@localhost ~]# yum install bind -y
[root@localhost ~]# rpm -qa bind
4、修改配置文件
(1)修改name.conf
[root@localhost ~]# vim /etc/named.conf
修改:
options {
directory "/var/named";
};
zone "
http://huizhong.com" IN {
type master;
file "huizhong.com.zone";
};
(2)区域配置文件
[root@localhost ~]# vim /var/named/huizhong.com.zone
添加:
$TTL 1D
@ IN SOA root huizhong.com. (
2020092901
1D
1H
1W
3H )
NS www.huizhong.com.
www A 1.1.1.1
mail A 2.2.2.2
ftp A 3.3.3.3
5、验证配置文件
(1)验证主配置文件
[root@localhost ~]# named-checkconf /etc/named.conf
(2)验证区域文件
[root@localhost ~]# named-checkzone
http://huizhong.com /var/named/huizhong.com.zone
6、启动服务
[root@localhost ~]# systemctl start named
[root@localhost ~]# systemctl enable named
[root@localhost ~]# systemctl status named
7、验证DNS
[root@localhost ~]# vim /etc/resolv.conf
添加:
nameserver 192.168.1.1
或者
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
DNS1=192.168.1.1
[root@localhost ~] # nslookup ww
http://w.huizhong.com