准备工作
1.安装相应包
提供DNS服务的软件叫bind,服务名是named。
root@localhost \~\]# yum install bind -y
关闭防火墙:[root@localhost ~]# systemctl stop firewalld.service
关闭selinux:[root@localhost ~]# setenforce 0
3.vim /etc/named.conf主配置文件
1 options {
2 listen-on port 53 { 127.0.0.1; };
3 listen-on-v6 port 53 { ::1; };
4 directory "/var/named";
5 allow-query { localhost; };
6 zone "." IN {
7 type hint;
8 file "named.ca";
9 };
~
1.DNS正向解析
1.主配置文件
options {
listen-on port 53 { 192.168.44.135; };
directory "/var/named";
};
zone "baidu.com" IN {
type master;
file "baidu.com";
};
2.正向解析文件配置
root@localhost \~\]# vim /var/named/named.baidu.com $TTL 1D @ IN SOA @ admin.baidu.com. ( 0 1D 1H 1W 3H ) IN NS ns.baidu.com. IN MX 10 mail.baidu.com. ns IN A 192.168.44.135 mail IN A 192.168.44.135 www IN A 192.168.44.135 ftp IN CNAME www
4.重启服务:
root@localhost \~\]# systemctl restart named
5.测试
root@localhost \~\]# nslookup www.baidu.com 192.168.44.135 \[root@localhost \~\]# host www.baidu.com 192.168.44.135 \[root@localhost \~\]# dig -t A www.baidu.com @192.168.44.135
2.DNS反向解析
1.主配置文件
root@localhost \~\]# vim /etc/named.conf zone "44.168.192.in-addr.arpa" IN { type master; file "named.192.168.44"; };
2.反向解析文件配置
root@localhost \~\]#vim /var/named/named.192.168.44 $TTL 1D @ IN SOA ns.baidu.com. admin.baidu.com. ( 0 1D 1H 1W 3H ) IN NS ns.baidu.com. 135 IN PTR ns.baidu.com. 135 IN PTR www.baidu.com. 135 IN PTR mail.baidu.com. 135 IN PTR ftp.baidu.com. \~
3.重启服务:
root@localhost \~\]# systemctl restart named
4、测试
root@localhost \~\]# nslookup 192.168.44.135 192.168.44.135 \[root@localhost \~\]# host 192.168.44.135 192.168.44.135 \[root@localhost \~\]# dig -x 192.168.44.135 @192.168.44.135