配置dns服务
安装dns服务软件包
yum install bind -y
修改全局配置文件
[root@server mnt]# vim /etc/named.conf
options {
listen-on port 53 { any; }; //将127.0.0.0 修改为any
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { any; }; //将localhost修改为any
修改局部配置文件
//在最后写
zone "hmmm.com" IN {
type master;
file "hmmm.com.zone";
};
创建hmmm.com.zone文件
[root@server mnt]# vim /var/named/hmmm.com.zone
$TTL 1D
@ IN SOA hmmm.com rname.invalid. (
//填入局部配置文件中的域名 0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ NS www.hmmm.com. //结尾部分有一个. 注意,别掉了
www A 127.0.0.1 //本地ip
web A 192.168.130.50
检查配置
[root@server mnt]# named-checkconf -z /etc/named.conf
zone localhost.localdomain/IN: loaded serial 0
zone localhost/IN: loaded serial 0
zone 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa/IN: loaded serial 0
zone 1.0.0.127.in-addr.arpa/IN: loaded serial 0
zone 0.in-addr.arpa/IN: loaded serial 0
zone hmmm.com/IN: loaded serial 0
[root@server mnt]#
启动服务和防火墙放行
[root@server mnt]# systemctl start named
[root@server mnt]# firewall-cmd --permanent --add-service=dns
success
[root@server mnt]# firewall-cmd --reload
success
[root@server mnt]#
客户端尝试
[root@client ~]# cat /etc/resolv.conf
# Generated by NetworkManager
# nameserver 114.114.114.114
nameserver 192.168.130.50
[root@client ~]# nslookup www.hmmm.com
Server: 192.168.130.50
Address: 192.168.130.50#53
** server can't find www.hmmm.com: SERVFAIL
[root@client ~]#
标签:named,服务,zone,0.0,server,dns,root,hmmm
From: https://www.cnblogs.com/humlogs/p/18184825