这次改进主要是因为Cloudflared的DNS Over HTTPS不是很稳定,一直超时,所以仍旧改回传统的53端口转发SSR,另外把NAT表的节点过滤规则和端口挂钩,这样就不用手动去配置节点的忽略规则了。
环境
- Raspbian Stretch
- SSR配置完成
- hostapd配置完成
- Raspberry Pi 3 Model B+ 配置AP全局代理 配置完成
改进
- 把Cloudflared的DNS Over HTTPS改为Google DNS
- 把NAT的节点规则改为端口过滤
优化DNS
编辑
| 1 | nano /etc/dnsmasq.conf | 
增加
| 1 | resolv-file=/etc/resolv.dnsmasq.conf | 
并将之前添加的内容添加注释标记
| 1 2 | #no-resolv #server=127.0.0.1#15353 | 
编辑
| 1 | nano /etc/resolv.dnsmasq.conf | 
写入
| 1 2 | nameserver 8.8.8.8 nameserver 8.8.4.4 | 
编辑
| 1 | nano /etc/resolv.conf | 
写入
| 1 | nameserver 127.0.0.1 | 
重启
| 1 | service dnsmasq restart | 
修改DNS规则
查询NAT的DNS规则
| 1 | iptables -t nat -L --line-number | 
找到之前添加的CloudFlare规则
| 1 2 3 4 5 | Chain PREROUTING (policy ACCEPT) target     prot opt source               destination          SHADOWSOCKS  tcp  --  anywhere             anywhere             REDIRECT   udp  --  anywhere             anywhere             udp dpt:domain redir ports 15353 REDIRECT   tcp  --  anywhere             anywhere             tcp dpt:domain redir ports 15353 | 
删除旧的规则
| 1 | iptables -t nat -D PREROUTING 2 | 
执行2次
添加新的规则
| 1 2 | iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53 | 
测试
| 1 | dig +short @127.0.0.1 -p 53 youtube.com | 
优化NAT表规则
将之前的规则删除
查询规则
| 1 | iptables -t nat -L --line-number | 
找到之前的规则
| 1 2 3 | Chain SHADOWSOCKS (2 references) num  target     prot opt source               destination          1    RETURN     all  --  anywhere             lts.minirplus.com | 
删除规则
| 1 | iptables -t nat -D SHADOWSOCKS 1 | 
添加按端口的节点转发规则
| 1 | iptables -t nat -A SHADOWSOCKS -p tcp --dport 989 -j RETURN | 
这样就不用添加每个节点地址到列表了
测试
| 1 | curl https://ipapi.co/json/ | 
Know More
https://www.hi-linux.com/posts/30947.html
https://xixitalk.github.io/blog/2018/08/31/transparent-proxy/
There are no comments yet