一键部署脚本
bash <(curl -sSLk https://blog.koniaoer.top/upload/dns.sh)
#关闭防火墙
systemctl stop firewalld
#检查
#systemctl status firewalld #运行后显示 Active: #inactive (dead)
或者允许防火墙开放53端口
firewall-cmd --permanent --add-port=53/udp
firewall-cmd --permanent --add-port=53/tcp
firewall-cmd --reload
#关闭安全策略
setenforce 0
#检查
#getenforce #运行后显示Permissive
bind是DNS服务器的软件包,而bind-utils提供了一些用于查询和操作DNS的实用工具
这里我们先安装bing和bing-utils
dnf install bind bind-utils
配置主配置文件 /etc/named.conf
配置主配置文件 /etc/named.conf
options {
listen-on port 53 { 127.0.0.1;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";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query { localhost;any; }; #允许那些人查询,any代表所有人
现在配置子配置文件/etc/named.rfc1912.zones
zone "koniaoer.net" IN{ #正向配置
type master;
file "koniaoer.zx";
allow-update { none; };
};
zone "130.168.192.in-addr.arpa" IN{ #反向配置
type master;
file "koniaoer.fx";
allow-update { none; };
};
查错
named-checkconf koniaoer.net /etc/named.conf
named-checkconf koniaoer.net /etc/named.rfc1912.zones
现在配置解析文件
正向解析:
内容格式要与named.localhost相同
[root@DNS /]# cat /var/named/named.localhost >> /var/named/koniaoer.zx
[root@DNS /]# cat /var/named/named.localhost
$TTL 1D #1D ,生存周期为一天
@ IN SOA @ rname.invalid. ( #IN 因特网 soa 开始授权
0 ; serial #更新序列号
1D ; refresh #更新间隔 1D 一天
1H ; retry #失败重新尝试时间 1H 一个小时
1W ; expire #过期时间 1W 指一周
3H ) ; minimum #缓存最小生命周期 3H 3小时
NS @
A 127.0.0.1 #A正向解析
AAAA ::1
配置后
$TTL 1D
@ IN SOA dns.edu.cn. admin.edu.cn. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
@ IN NS dns.edu.cn.
dns IN A 192.168.64.122
dhcp IN A 192.168.64.121
反向解析:
[root@DNS /]# cat /var/named/named.loopback >> /var/named/koniaoer.fx
[root@DNS /]# cat /var/named/named.loopback
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
PTR localhost.
配置后:
$TTL 3600
@ IN SOA dns.edu.cn. admin.edu.cn. (
0
1H
10M
3D
1D
)
@ IN NS dns.edu.cn.
121 IN PTR dhcp.edu.cn.
检查文件有没有语法错误
named-checkzone koniaoer.net koniaoer.fx
named-checkzone koniaoer.net koniaoer.zx
重启该服务
systemctl restart named
在网卡中修改dns服务ip
使用nslookup检查错误
[root@DNS /]# nslookup samba.koniaoer.net
Server: 192.168.130.128
Address: 192.168.130.128#53
Name: samba.koniaoer.net
Address: 192.168.130.129
[root@DNS /]# nslookup 192.168.130.129
129.130.168.192.in-addr.arpa name = samba.koniaoer.net.
评论区