在OpenWrt上安装DNSCrypt

一、OpenWrt介绍

OpenWrt官网: https://openwrt.org
这里写图片描述
OpenWrt是一种适用于嵌入式设备的Linux发行版,是一个高度模块化、高度自动化的嵌入式Linux系统,拥有强大的网络组件和扩展性,常常被用于工控设备、电话、小型机器人、智能家居、路由器以及VoIP设备中。同时,OpenWrt还提供了100多个已编译好的软件,且数量还在不断增加,OpenWrt SDK简化了开发相关软件的过程。

二、DNSCrypt介绍

本文主要讲述怎样在OpenWrt路由器上安装和配置DNSCrypt。

步骤1:安装DNSCrypt

DNSCrypt源码不在opkg的默认列表中,因此需要先把源添加到opkg列表的最后 ‘/etc/opkg.conf’。

echo 'src/gz exopenwrt http://exopenwrt.roland.black/barrier_breaker/14.07/ar71xx/packages/exopenwrt' >> /etc/opkg.conf

然后接着进行安装:

opkg update
opkg install dnscrypt-proxy

验证安装:

### opkg status | grep -n "dnscrypt-proxy"
### Result ###
230:Package: dnscrypt-proxy
236: /etc/config/dnscrypt-proxy ff316755d745da9b15b7166b667ed108

步骤2:配置DNSCrypt

DNSCrypt的配置文件在/etc/config/dnscrypt-proxy,它比较简单,易于调整:

### nano /etc/config/dnscrypt-proxy
config dnscrypt-proxy
    option address '127.0.0.1'
    option port    '5353'
  # option resolver        'cisco'
  # option resolvers_list  '/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv'
  # option ephemeral_keys '1'

现在可以启动DNSCrypt,并设置自启动:

/etc/init.d/dnscrypt-proxy enable
/etc/init.d/dnscrypt-proxy start

如果路由器重启后dnscrypt-proxy没有启动,那么或许该尝试在网络接口完全启动前启动它。在/etc/rc.local文件的“exit 0”行上面添加:

sleep 10
/etc/init.d/dnscrypt-proxy start

接下来,编辑‘/etc/config/dhcp’配置:

config dnsmasq
    option domainneeded         1
    option boguspriv            1
    option filterwin2k          0
    option localise_queries     1
    option rebind_protection    1
    option rebind_localhost     1
    option local                '/lan/'
    option domain               'lan'
    option expandhosts          1
    option nonegcache           0
    option authoritative        1
    option readethers           1
    option leasefile            '/tmp/dhcp.leases'
#   option resolvfile           '/tmp/resolv.conf.auto'
    option noresolv             1
    list server                 '127.0.0.1#5353'
    list server                 '/pool.ntp.org/208.67.222.222'
#   list server                 '208.67.222.222'
#   list server                 '208.67.220.220'

重启dnsmasq,使之生效:

/etc/init.d/dnsmasq restart

至此,就成功完成了DNSCrypt的安装。

扫描二维码关注公众号,回复: 2021620 查看本文章

猜你喜欢

转载自www.linuxidc.com/Linux/2016-10/136406.htm