美文网首页成长励志想法散文
linux下的dns(二)正向解析

linux下的dns(二)正向解析

作者: zhangxiaohao | 来源:发表于2019-06-09 07:15 被阅读0次
解析目标

对test.com解析为:192.168.22.66
对www解析为:192.168.22.88
news解析为www的别名

主配置文件

vim /etc/named.conf

options {
    listen-on port 53 { any; };
    directory     "/var/named";
};
......
zone "test.com" IN {
 type master;
 file "test.com.zone";区域数据库文件
};

hint:根
master:主域
slave:辅助域
forward:转发域

设置区域数据文件
cp named.localhost test.com.zone #把模板文件拷贝过来进行修改
chgrp named test.com.zone

vim test.com.zone

@ IN SOA ns1.test.com. rname.invalid. (
      0;
      1d;
      1h;
      1w;
      3h );
NS  ns1.test.com.  ;dns为ns1.test.com.  
ns1 A 192.168.22.66
www A 192.168.22.88
news CNAME  www

A 域名机械为IP
PTR IP解析为域名
MX 邮件标记
CNAME 别名

测试

named-checkconf /etc/named.conf
named-checkzone /var/named/ test.com.zone
systemctl restart named
vim /etc/resolv.conf

# Generated by NetworkManager
nameserver 192.168.22.66 #加上dns地址
  • host命令
    host news.test.com
  • nslookup 命令---交互式解析
nslookup
> news.test.com
Server:        192.168.22.66
Address:    192.168.22.16#53

news.test.com    canonical name = www.test.com.
Name:    www.test.com
Address: 192.168.22.88
> exit
  • nslookup 命令---非交互式解析
nslookup news.test.com
Server:        192.168.22.66
Address:    192.168.22.66#53

news.test.com    canonical name = www.test.com.
Name:    www.test.com
Address: 192.168.22.88
  • dig命令
    dig news.test.com

相关文章

网友评论

    本文标题:linux下的dns(二)正向解析

    本文链接:https://www.haomeiwen.com/subject/dwjrxctx.html