通过unbound软件配置简单的DNS

发布时间:2020-06-02 09:37:32 作者:tomshen
来源:网络 阅读:3154

实现DNS的软件:unbound(貌似bind更强大)


unbound是红帽公司推荐的DNS软件


unbound的程序包:

unbound:实现DNS的主程序包

unbound-libs:进行域名解析必备的库文件


unbound服务的启动:


systemctl start unbound


unbound的配置文件:

/etc/unbound/unbound.conf    #主配置文件

/etc/unbound/local.d/        #

/etc/nsswitch.conf           #/etc/nsswitch.conf文件的第39行"hosts:files dns"规定了一台主机解析的顺序,

  首先找的本地文件/etc/hosts,然后再是DNS



/etc/hosts                   #本地IP地址与主机名的映射关系

/etc/resolv.conf             #为linux客户端指定DNS服务器




配置防火墙,放行DNS服务;

firewall-cmd --add-service=dns --permanent


启动unbound服务,并设置开机启动:

systemctl start unbound

systemctl enable unbound


配置防火墙;

firewall-cmd --permanent --add-service=dns

firewall-cmd --reload




unbound主配置文件:

/etc/unbound/unbound.conf 


server:

interface:xxxx   #监听的IP地址,默认监听localhost


访问控制列表;(默认拒绝所有主机,除了localhost)


access-control: IP地址/掩码 allow   #允许访问的主机

access-control: IP地址/掩码 refuse  #禁止访问的主机


username:""                         #任何用户都能访问


include: /etc/unbound/local.d/*.conf


local-zone:

资源记录:RR


remote-control:


stub-zone:


forward-zone:





1. unbound中正反向解析文件,合并为一个:

在/etc/unbound/local.d/下新建一个文件testyuming.com.conf,内容如下:

local-zone: "testyuming.com." static

local-data: "testyuming.com. 86400 IN SOA 768047936.qq.com. root 1 1D 1H 1W 1H"    

local-data: "testyuming.com. NS www.testyuming.com."

local-data: "testyuming.com. MX 5 www.testyuming.com."

local-data: "www.testyuming.com. A 192.168.1.118"

local-data: "bbs.testyuming.com. A 192.168.1.118"



# local-data-ptr: "192.168.1.118 www.testyuming.com."     反向解析范例 



2.使用unbound-checkconf检查语法


3.重启unbound服务:

systemctl restart unbound

4.修改/etc/resolv.conf文件,内容如下:

nameserver 192.168.1.118


5.

[root@localhost etc]# host www.testyuming.com

www.testyuming.com has address 192.168.1.118






    配置仅转发DNS:


    1.

    unbound主配置文件的基本设置:


    interface: 192.168.1.118

    access-control: 0.0.0.0/0 allow

    username:""


    在配置文件里找到module-config

    把注释取消,然后改成module-config:"iterator"



    2.

    重启unbound


    systemctl restart unbound



    3.

在/etc/unbound/local.d/下新建一个文件bb.conf,内容如下:


    forward-zone:


    name:"."

    forward-addr:可以进行DNS解析的服务器IP




    unbound-control flush 域名    #清除缓存


   


推荐阅读:
  1. DNS查询过程及DNS服务器简单搭建
  2. unbound搭建递归dns

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

unbound un bo

上一篇:电商运营需要知道哪些知识

下一篇:Eclipse_安装Spring Tool Suite

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》