由于最近用了cloudflare访问困难研究发现可以使用MosDNS来解决Cloudflare访问慢 无法访问问题
说下环境 群晖docker搭建了优选IP服务 镜像 lee1080/cfstddns 自动更新到优选域名
由于写了文章不久就会被偷走已经没心情再仔细一步一步写教程,只写了重要的部分,其他的不是问题或者可以谷歌解决。
路由器为openwrt
安装MosDns 4.X
https://github.com/sbwml/luci-app-mosdns
可根据此仓库安装
level: info # 日志级别,可选 debug 、 info 、 warn 、 error 。默认 info
file: "/tmp/mosdns.log" # 留空代表不输出日志
# 服务器
servers:
- exec: main_sequence
listeners:
- protocol: udp
addr: ":5335"
- protocol: tcp
addr: ":5335"
plugins:
- tag: lazy_cache
type: cache
args:
size: 1024 # 缓存条数
lazy_cache_ttl: 86400 # 缓存时间
lazy_cache_reply_ttl: 30 # 返回过期应答的 TTL
# 转发到上游 DNS
- tag: forward_local
type: fast_forward
args:
upstream:
- addr: "udp://114.114.114.114" # 114 公共明文 UDP DNS
- addr: "udp://223.5.5.5" # 阿里云的明文 UDP DNS
- addr: "https://dns.alidns.com/dns-query" # 阿里的 DoH 加密 DNS
idle_timeout: 30 # 连接复用空连接保持时间,单位: 秒
trusted: true # 是否是可信服务器
- addr: "https://doh.pub/dns-query" # 腾讯的 DoH 加密 DNS
idle_timeout: 30
trusted: true
# 匹配 Cloudflare CDN IP 地址
- tag: response_IP_Cloudflare
type: response_matcher
args:
- "173.245.48.0/20"
- "103.21.244.0/22"
- "103.22.200.0/22"
- "103.31.4.0/22"
- "141.101.64.0/18"
- "108.162.192.0/18"
- "190.93.240.0/20"
- "188.114.96.0/20"
- "197.234.240.0/22"
- "198.41.128.0/17"
- "162.158.0.0/15"
- "104.16.0.0/12"
- "172.64.0.0/17"
- "172.64.128.0/18"
- "172.64.192.0/19"
- "172.64.224.0/22"
- "172.64.229.0/24"
- "172.64.230.0/23"
- "172.64.232.0/21"
- "172.64.240.0/21"
- "172.64.248.0/21"
- "172.65.0.0/16"
- "172.66.0.0/16"
- "172.67.0.0/16"
- "131.0.72.0/22"
# - "2606:4700::/32" # 如果要匹配 IPv6 地址,则请移除行首第一个井号
# 修改 IP 为自选 IP
- tag: blackhole_Cloudflare
type: blackhole
args:
ipv4: "1.1.1.1" # 如果请求类型是 A,则生成 IP 为该地址的应答。请修改为自选 IPv4
# ipv6: "xxxx:xxxx:xxxx:xxxx" # 如果请求类型是 AAAA,则生成 IP 为该地址的应答。请修改为自选 IPv6,如果要返回 IPv6 则请移除行首第一个井号
# 将多个插件组合成流水线
- tag: main_sequence
type: sequence
args:
exec:
- lazy_cache # 匹配缓存
- forward_local # 请求转发至上游 DNS
- if: response_IP_Cloudflare # 如果域名解析结果为 Cloudflare CDN IP 地址
exec:
- blackhole_Cloudflare # 则返回指定的 自选 IP
#2023-06-26 14:47:15
1.1.1.1 为优选IP 根据实际需要自己替换
自动化优选IP
由于cfip经常变化 想了个办法自动更新
查看本段内容需要支付 10 金币
您尚未登录,请 点击登录 或者 立即注册
喜欢 (2)