1.基础了解
DNS服务:
FQDN:完全符合规格的域名
正向解析:FQDN---->IP
反向解析:IP----->FQDN
DNS查询类型:
递归查询
迭代查询
DNS服务类型:
主从
转发
缓存
指定DNS服务器:
/etc/resolv.conf
本地DNS解析:
/etc/hosts
2.提供基本DNS服务解析
2.1正向解析 (环境为cenos6.8)
2.1.1.服务前安装软件:bind.x86_64 bind-libs-9.8.2-0.47.rc1.el6_8.1.x86_64 bind-utils-9.8.2-0.47.rc1.el6_8.1.x86_64
2.1.2.配置正向解析文件
2.1.2.1主配置文件: 在/etc/named.conf里面
listen-on port 53 { any; };DNS服务监听端口
directory "/var/named";定义配置文件目录
allow-query { any; };允许DNS查询的ip地址或者ip地址范围
recursion yes;允许递归查询
include "/etc/named.rfc1912.zones";包含zone的配置文件
2.1.2.2.主区域配置文件:在/etc/named.rfc1912.zones下
zone "uplooking.com" IN { 定义区域名
type master;制定区域类型{master,slave,hint,forward}
file "uplooking.com";制定区域文件名
};
2.1.2.3.区域文件配置:在/var/named/新建一个up14.com
修改权限:chown root.nomed up14.com
编辑up14.com 内容为以下:
$TTL 1D
@ IN SOA ns.uplooking.com. admin.uplooking.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
uplooking.com. IN NS ns.uplooking.com.
ns.uplooking.com. IN A 172.16.10.1
www IN A 172.16.10.1
bbs IN A 172.16.10.1
IN MX 10 mail
mail IN A 172.16.10.1
bbs2 IN CNAME bbs
2.1.2.4。重启服务:
/etc/init.d/named restart 重启named服务
named-chekconf 检查named.conf
named-chekzone "up14.com" /var/named/up14.com 检查/var/named/up14.com文件
2.1.2.5.编辑/etc/resolv.conf指定服务器IP地址 (本次试验机为192.168.119.128)
例:; generated by /sbin/dhclient-script
#search localdomain (#表示将原来得注释掉)
#nameserver 192.168.119.2 (#表示将原来得注释掉)
nameserver 192.168.119.128 (新增加)
2.1.2.6.解析检查:dig -t A www.up14.com或者nslookup www.uplooking.com
例:[root@localhost etc]# dig -t A www.up14.com
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6_8.1 <<>> -t A www.up14.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64037
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;www.up14.com. IN A
;; ANSWER SECTION:
www.up14.com. 86400 IN A 192.168.119.128
;; AUTHORITY SECTION:
up14.com. 86400 IN NS ns.up14.com.
;; ADDITIONAL SECTION:
ns.up14.com. 86400 IN A 192.168.119.128
;; Query time: 1 msec
;; SERVER: 192.168.119.128#53(192.168.119.128)
;; WHEN: Sat Oct 8 21:36:36 2016
;; MSG SIZE rcvd: 79
解析成功!
2.2.反向解析
2.2.1主区域文件配置在/etc/named.rfc1912.zones里面
格式:
zone "100.168.192.in-addr.arpa" IN {
type master;
file "192.168.100.zone";
};
2.2.2区域配置文件在/var/named/里面新建一个192.168.100.zone文件
输入格式
$TTL 600
@ IN SOA ns1.up14.com. admin.up14.com. (
20140904
1H
5M
2D
6H
)
IN NS ns1.up14.com.
200 IN PTR ns1.up14.com.
221 IN PTR www.up14.com.
222 IN PTR www.up14.com.
2.2.3.重启服务:
/etc/init.d/named restart 重启named服务
named-chekconf 检查named.conf
named-chekzone "100.168.192.in-addr.arpa" /var/named/192.168.100.zone 检查/var/named/up14.com文件
2.2.4.编辑/etc/resolv.conf指定服务器IP地址 (本次试验机为192.168.100.128)
例:; generated by /sbin/dhclient-script
#search localdomain (#表示将原来得注释掉)
#nameserver 192.168.119.2 (#表示将原来得注释掉)
nameserver 192.168.119.128 (新增加正向解析IP---> 此步为上面正向解析保留得IP地址可以不要)
nameserver 192.168.100.128 (新增加反向解析IP)
2.2.5.验证反向解析:dig -x 192.168.100.221
例:[root@localhost named]# dig -x 192.168.100.221
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.47.rc1.el6_8.1 <<>> -x 192.168.100.221
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51833
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;221.100.168.192.in-addr.arpa. IN PTR
;; ANSWER SECTION:
221.100.168.192.in-addr.arpa. 600 IN PTR www.up14.com.
;; AUTHORITY SECTION:
100.168.192.in-addr.arpa. 600 IN NS ns1.up14.com.
;; Query time: 0 msec
;; SERVER: 192.168.119.128#53(192.168.119.128)
;; WHEN: Sat Oct 8 21:58:43 2016
;; MSG SIZE rcvd: 90
解析成功!
3.增加DNS别名
在zone文件中添加以下内容实现别名
bbs2 IN CNAME bbs
4.泛域名解析:
* IN A 192.168.119.128 或者 *.uplooking.com. IN A 192.168.119.128
5.递归和迭代解析流程
5.1 迭代
dig +norecurse -t A www.sohu.com @192.168.119.128
dig +norecurse -t A www.sohu.com @f.gtld-servers.net
dig +norecurse -t A www.sohu.com @dns.sohu.com
dig +norecurse -t A www.sohu.com @gs.a.sohu.com
5.2递归
dig +trace -t A www.sohu.com @192.168.119.128
6.增量传送,完全传输
axfr:完全传输
ixfr:增量传送
dig -t axfr uplooking.com
dig -t IXFR=2016100816 uplooking.com
注意:
完成配置后要记住修改DNS服务器地址(/etc/resolv.conf)
注意区域配置文件的权限root.named
主区域配置文件中文件名zone最好和zone名字一样
解析类型:A记录
PTR记录
MX记录
NS记录
NS服务器记录和NS的A记录要成对出现
uplooking.com. IN NS ns.uplooking.com.
ns.uplooking.com. IN A 192.168.119.128
邮件域名解析
IN MX 10 mail
mail IN A 192。168.119.128
记住加上根域(.)