Dnsmasq 简单DNS service搭建抗污染
服务端:
一台香港VPS(国内主机不推荐,有污染)
OS:Debian9
# apt-get install dnsmasq
# nano /etc/dnsmasq.conf
*******************修改:去掉 “#” 启动功能*******************
#port=443 (默认端口53,0为禁用。如果你的运营商启用了dns透明代理,请启用)
strict-order (按顺序解析)
listen-address=127.0.0.1,23.188.88.88(替换你VPS的IP)
cache-size=8000 (缓存条数,根据VPS速度调整大小)
# resolv-file=/etc/resolv.dnsmasq.conf (手动指定上游DNS文件,无需求不用启动)
*******************保存内容*******************
# nano /etc/resolv.conf
**************添加上游DNS**************
nameserver 127.0.0.1 (先本地查,不缓存可以不填这行)
nameserver 8.8.8.8
nameserver 8.8.4.4
**************添加上游DNS**************
# service dnsmasq restart (重启服务)
# service dnsmasq status (检查服务状态,没问题就进客户端测试了)
Iptables放行DNS端口:
$ iptables -A INPUT -p udp -m udp --dport 53 -j ACCEPT
$ iptables -A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
客户端:
openwrt:
1.非53标准端口
# nano /etc/config/dhcp
************注释掉*********
#option resolvfile
****************************
# nano /etc/dnsmasq.conf
**********添加*************
server=208.67.222.222#443
************************
# service dnsmasq restart
2. 53端口
# nano /etc/config/dhcp
************修改*********
option resolvfile '/etc/resolv.dnsmasq.conf'
****************************
# nano /etc/resolv.dnsmasq.conf
**********添加************
nameserver 208.67.222.123
nameserver 208.67.220.123
***************************
# service dnsmasq restart
windows:
# cmd
# nslookup google.com
linux:
dig google.com
# apt-get install -y dnsutils (没装dig,运行这条命令)
非53端口:
1.
# iptables -t nat -A OUTPUT -o 网卡名 -p udp --dport 53 \ -j DNAT --to 208.67.222.222:443
2.使用dnsmasq
# nano /etc/dnsmasq.conf
port=53
no-resolv
# For IPv6
# server=2620:0:ccc::2#443
server=208.67.222.222#443
listen-address=127.0.0.1
增加中国网站cdn速度:
大型网站CDN会根据dns所在地分配ip,为了更快的连接请使用以下列表,也可以按自己需求精简列表,毕竟会消耗一些路由性能
https://github.com/felixonmars/dnsmasq-china-list
香港宽频 Hong Kong BroadBand Network DNS
203.80.96.10
203.80.96.9
HKNet
202.67.240.222
202.67.240.221
和记环球电讯 HGC
202.45.84.58
202.45.84.59
中華電信
168.95.1.1(dns.hinet.net)
168.95.192.1(hntp1.hinet.net)
168.95.192.2(hntp3.hinet.net)
速博 sparq:
61.56.211.185
211.78.130.2
臺灣固網:
211.78.215.137
211.78.215.200

0 评论:
发表评论