搭建可翻墙的dns服务器

因为有个国外的服务器搭了ss的服务,在电脑上使用比较方便.我自己本身有个可用的翻墙host,所以更青睐使用host直接上谷歌,并且github也可以加速.手机并不能使用ss,pad越狱之后才安装了ss的软件.也用过Privoxy将socks转成http,手机经常的切换代理也是很繁琐.

然后有现在解决办法,搭建了dns服务器.

dns服务器搭建在raspberry pi上,系统烧录的是debian系统.使用的dnsmasq软件,修改dns配置,配置翻墙host,修改dns服务器.

安装dnsmasq

1
sudo apt-get install dnsmasq

修改配置文件

1
sudo vi /etc/dnsmasq.conf

修改为

1
2
3
4
5
6
domain=raspberry.local
resolv-file=/etc/resolv.dnsmasq
min-port=4096
server=8.8.8.8
server=8.8.4.4
cache-size=10000

配置host

在/etc/dnsmasq.d/目录下创建gfw.conf,分析hosts文件结构

1
2
3
4
64.233.162.83    0.docs.google.com
64.233.162.83 0.drive.google.com
64.233.162.83 1.docs.google.com
64.233.162.83 1.drive.google.com

dnsmasq配置文件格式

1
2
3
4
address=/0.docs.google.com/64.233.162.83
address=/0.drive.google.com/64.233.162.83
address=/1.docs.google.com/64.233.162.83
address=/1.drive.google.com/64.233.162.83

批量处理hosts文件

1
awk -F ' ' '{print "address=/"$2"/"$1}' /etc/hosts

重启服务,修改dns到树莓派的ip

1
service dnsmasq restart