[root@localhost ~]# nslookup www.beidu.com Server: 192.168.31.1 Address: 192.168.31.1#53 Non-authoritative answer: Name: www.beidu.com Address: 184.154.126.180 [root@localhost ~]# # 安装 bind - 10.4.7.11 [root@localhost ~]# yum install bind -y # 查看版本 [root@localhost ~]# rpm -qa bind bind-9.11.4-26.P2.el7_9.9.x86_64 # 1-主配置 [root@localhost ~]# vim /etc/named.conf # 修改的地方 listen-on port 53 { 192.168.31.31; }; allow-query { any; }; # 添加了一个网关地址 forwarders { 192.168.31.1 }; # 使用yes 采用递归 recursion yes; # 这两个设置成 no dnssec-enable no; dnssec-validation no; # 检查配置是否有问题 [root@localhost ~]# named-checkconf # 2-配置区域文件 [root@localhost named]# vim /etc/named.rfc1912.zones # 配置两个域,添加如下内容 zone "host.com" IN { type master; file "host.com.zone"; allow-update { none; }; }; zone "od.com" IN { type master; file "od.com.zone"; allow-update { none; }; }; # 3-配置区域数据文件 [root@localhost ~]# cd /var/named/ [root@localhost named]# cp -a named.localhost host.com.zone [root@localhost named]# vim host.com.zone $ORIGIN host.com. $TTL 1D @ IN SOA dns.host.com. root.host.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS dns.host.com. dns A 192.168.31.31 HD-31 A 192.168.31.31 HD-32 A 192.168.31.218 HD-33 A 192.168.31.132 [root@localhost named]# cp -a host.com.zone od.com.zone [root@localhost named]# vim od.com.zone $ORIGIN od.com. $TTL 1D @ IN SOA dns.od.com. root.host.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum NS dns.od.com. dns A 192.168.31.31 # 检查配置文件是否有问题 [root@localhost named]# named-checkconf # 启动 [root@localhost named]# systemctl start named # 查看 53 端口 [root@localhost named]# netstat -luntp|grep 53 tcp 0 0 192.168.31.31:53 0.0.0.0:* LISTEN 2334/named tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1369/dnsmasq tcp 0 0 127.0.0.1:953 0.0.0.0:* LISTEN 2334/named tcp6 0 0 ::1:53 :::* LISTEN 2334/named tcp6 0 0 ::1:953 :::* LISTEN 2334/named udp 0 0 192.168.31.31:53 0.0.0.0:* 2334/named udp 0 0 192.168.122.1:53 0.0.0.0:* 1369/dnsmasq udp 0 0 0.0.0.0:57534 0.0.0.0:* 576/avahi-daemon: r udp 0 0 0.0.0.0:5353 0.0.0.0:* 576/avahi-daemon: r udp6 0 0 ::1:53 :::* 2334/named # 检查主机域 [root@localhost named]# dig -t hostname.host.com @192.168.31.31 +short # 要linxu 和Windows 客户端都可以使用。 修改DNS 为(主域IP) # Windows 的首选DNS 写主域的IP [root@localhost network-scripts]# cd /etc/sysconfig/network-scripts [root@localhost network-scripts]# vim ifcfg-ens33 GATEWAY=192.168.31.1 DNS1=192.168.31.31 DNS2=192.168.31.1 [root@localhost network-scripts]# systemctl restart network [root@localhost network-scripts]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 192.168.31.31 nameserver 192.168.31.1 # ping 通本机 添加如下(主域+其他域都加) vim /etc/resolv.conf search host.com