========================================================================================
搭建DNS服务器步骤
1.准备工作
=====关闭SELinux和防火墙
=====setenforce 0
=====getenforce
=====vim /etc/sysconfig/selinux
=====systemctl stop firewalld.service
=====systemctl disable firewalld.service
========================================================================================
2.配置本地yum源
=====mkdir /etc/yum.repos.d/default
=====mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/default
=====vim /etc/yum.repos.d/local.repo
=====vim---[local]
=====vim---name=localsrc
=====vim---baseurl=file:///mnt
=====vim---enabled=1
=====vim---gpgcheck=0
=====mount /dev/cdrom /mnt/
=====yum clean all
=====yum makecache
========================================================================================
3.安装DNS工作软件
=====yum install -y bind bind-chroot
========================================================================================
4.编辑DNS配置文件
=====vim /var/named/chroot/etc/named.conf
=====vim---options {
=====vim---directory "/var/named";
=====vim---};
=====vim---zone "uplooking.com" {
=====vim---type master;
=====vim---file "uplooking.com.zone";
=====vim---};
========================================================================================
=====cp /usr/share/doc/bind-9.8.2/sample/var/named/named.localhost /var/named/chroot/var/named/uplooking.com.zone
=====vim /var/named/chroot/var/named/uplooking.com.zone
=====vim---$TTL 1D
=====vim---@ IN SOA uplooking.com. 454452000.qq.com. (
=====vim--- 0 ; serial
=====vim--- 1D ; refresh
=====vim--- 1H ; retry
=====vim--- 1W ; expire
=====vim--- 3H ) ; minimum
=====vim--- NS dns1.uplooking.com.
=====vim---dns1 A 装有DNS服务的主机IP地址(例:192.168.88.101)
=====vim---web A 192.168.1.1
=====vim---ftp A 192.168.1.2
=====vim--- MX 5 mail.uplooking.com.
=====vim---mail A 192.168.1.3
========================================================================================
5.启动named服务
=====systemctl start named
=====systemctl start named-chroot
=====systemctl enable named
=====systemctl enable named-chroot
=====ss -antp | grep named
=====ss -anup | grep named
========================================================================================
6.测试DNS服务器
(需要使用另一台电脑,先配置一下)
=====vim /etc/sysconfig/network-scripts/ifcfg-eth0
=====vim---NAME="eth0"
=====vim---ONBOOT=yes
=====vim---BOOTPROTO=none
=====vim---TYPE=Ethernet
=====vim---IPADDR=192.168.122.121
=====vim---NETMASK=255.255.255.0
=====vim---GATEWAY=192.168.122.1
=====vim---DNS1=192.168.122.105
=====systemctl restart network
=====systemctl restart NetworkManager
(配置完成,可以测试DNS服务器了)
=====nslookup
=====> server
=====> web.uplooking.com
=====> ftp.uplooking.com
=====> mail.uplooking.com
=====> exit
========================================================================================