Centos 7 搭建DNS服务器
2023-02-15 18:57 @学无止境 阅读(149) 评论(0) 编辑 收藏 举报参考:https://www.cnblogs.com/whjblog/p/17047263.html
1、安装DNS服务
yum install -y bind bind-utils
2、修改/etc/named.conf配置
options {
listen-on port 53 { any; }; //此处修改为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";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; }; //此处修改为any
3、修改/etc/named.rfc1912.zones配置,在文件末尾加上如下代码
#DNS正向解析
zone "hyqvictory.com" IN {
type master;
file "hyqvictory.com.zone";
allow-update { none; };
};
#DNS反向解析
zone "20.168.192.in-addr.arpa" IN {
type master;
file "hyqvictory.com.local";
allow-update { none; };
};
4、进入/var/named/目录,创建hyqvictory.com.zone和hyqvictory.com.local两个文件,名称对应上面的file
hyqvictory.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.20.100
www IN A 192.168.20.100
node1 IN A 192.168.20.101
node2 IN A 192.168.20.102
hyqvictory.com.local
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 192.168.20.100
101 IN PTR node1.hyqvictory.com.
102 IN PTR node2.hyqvictory.com.
5、重启named服务
systemctl start named
nslookup www.hyqvictory.com
nslookup node1.hyqvictory.com
nslookup node2.hyqvictory.com
nslookup 192.168.20.100
nslookup 192.168.20.101
nslookup 192.168.20.102