unbound搭建递归dns

自红帽7.0更新之后除了原有的bind之外增加了unbound,其实综合使用下来我个人觉得unbound作为递归dns要比bind好用的多,平时工作中喜欢用unbound去测试解析,包括过滤IPv6域名等应用。
因为国家大力推广IPv6,而目前IPv6的互联环境还是非常糟糕,所以我们可以通过过滤IPv6来实现:
使用yum 进行安装:
unbound搭建递归dns

[root@langqun ~]# vim /etc/unbound/unbound.conf
可以看出有很多废话,我喜欢直接将原有的unbound.conf备份一下,然后只保留以下几行:
server:
port: 53
do-ip4: yes
do-ip6: yes
private-address: ::/0 (过滤IPv6查询结果)
interface: 0.0.0.0 (服务器IP地址,如果只有一个接口则不用修改)
access-control: 0.0.0.0/0 allow (限制哪些用户来查询)
msg-cache-size: 4m
rrset-cache-size: 4m
cache-max-ttl: 3600
cache-min-ttl: 300
hide-identity: yes
hide-version: yes
prefetch: yes
num-threads: 4
do-not-query-localhost: no
#logfile: "/var/log/unbound.log"

forward-zone:
name: "qpic.cn"
forward-addr: 114.114.114.114
以下是我的地址信息
unbound搭建递归dns
如果有virbr0接口的话,可能通过virbr0接口监听53号端口,导致unbound服务无法提供服务,这时需要删除虚拟接口:
unbound搭建递归dns

删除虚拟接口的命令:
brctl show
ifconfig virbr0 down;
brctl delbr virbr0;
systemctl stop libvirtd.service;
systemctl disable libvirtd.service;
yum remove libvirt-daemon
reboot

启用服务即可:
[root@langqun unbound]# systemctl start unbound.service
解析qq测试:
unbound搭建递归dns

因为配置了IPv6过滤,则无法反馈客户端IPv6结果:
unbound搭建递归dns

而通过114.114.114.114 是可以解析qq的IPv6结果的:
unbound搭建递归dns

本dns为递归dns,所以下发给用户的dns则可以再搭建dns,如果需要过滤某个域名,则可以直接将该域名转发给这个dns即可。