内网虚拟机上DNS-over-https服务器
以下均是在局域网虚拟机上的Debian 9里操作,目的是配置一个使用DOH服务的自动分流DNS服务器。
安装Go 1.10:
wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz
tar -zxvf go1.10.1.linux-amd64.tar.gz
sudo mv go /usr/local
ls /usr/local
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
安装dns-over-https:
git clone https://github.com/m13253/dns-over-https.git
cd dns-over-https
sudo make
sudo make install
配置:
sudo nano /etc/dns-over-https/doh-client.conf
doh-client.conf内容修改,这里使用的是CloudFlare的DNS-over-https服务器:
listen= [
"127.0.0.1:5312",
"[::1]:5312",
]
upstream_ietf = [
"https://1.1.1.1/dns-query",
]
启动doh
systemctl start doh-client
systemctl enable doh-client
安装dnsmasq
sudo apt install dnsmasq
配置dnsmasq
sudo nano /etc/dnsmasq.conf
dnsmasq.conf内容:
conf-dir=/etc/dnsmasq.d/,*.conf
listen-address=127.0.0.1
listen-address=本机ip
cache-size=102400
no-dhcp-interface=
bind-interfaces
gfwlist分流:
git clone https://github.com/cokebar/gfwlist2dnsmasq
cd gfwlist2dnsmasq
./gfwlist2dnsmasq.sh -d 127.0.0.1 -p 5312 -o dnsmasq_gfwlist.conf
sudo mkdir /etc/dnsmasq.d
sudo mv dnsmasq_gfwlist.conf /etc/dnsmasq.d
服务重启动:
sudo service dnsmasq restart
sudo service doh-client restart
以下为局域网特殊配置操作备忘:
/etc/resolv.conf:
nameserver "router ip"
&
chattr +i /etc/resolv.conf
route del default gw "assigned gw"
route add default gw "router ip"
Fin