安装 unbound
:
$ sudo pkg install unbound
编辑 /etc/resolvconf.conf
,让 DNS 解析转发到 unbound 监听的本地回环上:
name_servers=127.0.0.1
修改后使配置立即生效:resolvconf -u
开始配置 unbound
服务,重新指定 unbound 的配置文件目录为 /var/unbound
:
sudo service unbound enable
sudo sysrc unbound_config=/var/unbound/unbound.conf
编辑 unbound
配置文件 /var/unbound/unbound.conf
:
server:
username: unbound
directory: /var/unbound
chroot: /var/unbound
pidfile: /var/run/unbound.pid
prefer-ip6: yes
num-threads: 2
cache-min-ttl: 7200
cache-max-ttl: 36000
interface: lo0@53
include: /var/unbound/forward.conf
编辑 /var/unbound/forward.conf
,配置 DNS 转发服务器:
forward-zone:
name: "."
forward-first: no
forward-tls-upstream: yes
forward-addr: 1.1.1.1@853
启动 unbound
服务:
service unbound start