树莓派/香橙派.Space树莓派

树莓派/香橙派自建本地DNS加速解析

2017-06-24  本文已影响654人  不着调的小男生

Dnsmasq介绍

Dnsmasq我们用来干什么?

Dnsmasq本地DNS搭建

### 安装Dnsmasq (update)
sudo apt install -y dnsmasq

### 修改配置文件,配置文件一般位于路径/etc/dnsmasq.conf
#备份默认配置文件
cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak

#备份dns配置文件
cp /etc/resolv.conf /etc/resolv.conf.bak

#修改本地dns为127.0.0.1
echo 'nameserver 127.0.0.1' > /etc/resolv.conf

#添加上游dns服务器
cp /etc/resolv.conf /etc/resolv.dnsmasq.conf

#自定义上游DNS
echo 'nameserver 114.114.115.115' >> /etc/resolv.dnsmasq.conf
echo 'nameserver 114.114.114.114' >> /etc/resolv.dnsmasq.conf
echo 'nameserver 223.5.5.5' >> /etc/resolv.dnsmasq.conf

#将本机hosts导入本地自定义dns
cp /etc/hosts /etc/dnsmasq.hosts

#将文件路径写入配置文件
echo 'resolv-file=/etc/resolv.dnsmasq.conf' >> /etc/dnsmasq.conf
echo 'addn-hosts=/etc/dnsmasq.hosts' >> /etc/dnsmasq.conf
echo 'domain=raspberry.local' >> /etc/dnsmasq.conf
echo 'min-port=4096' >> /etc/dnsmasq.conf
echo 'cache-size=10000' >> /etc/dnsmasq.conf

# 重新启动
service dnsmasq restart

# 查看53端口开启
netstat -ntulp|grep 53



53.png
cd dnsmasq-china-list/
cp *.conf  /etc/dnsmasq.d/
service dnsmasq restart

参考:
在/etc/dnsmasq.d/(如果不存在则创建文件夹)中放置accelerated-domains.china.conf,bogus-nxdomain.china.conf(以及可选的google.china.conf,apple.china.conf)。
在/etc/dnsmasq.conf中取消注释“conf-dir = / etc / dnsmasq.d”
(可选)将dnsmasq-update-china-list放入/ usr / bin /


## 验证DNS服务正常工作

sudo apt-get install dnsutils

dig www.baidu.com


Google.png

本地DNS翻墙

参考:https://www.sfantree.com/set_self_dns/

上一篇 下一篇

猜你喜欢

热点阅读