利用mosdns的response_matcher和blackhole两个内置插件实现
以下配置文件适用于mosdns v4版本
下载地址: https://github.com/IrineSistiana/mosdns/releases
运行:./mosdns start -c config.yaml
- log:
- level: debug
- file: ""
-
- plugins:
-
- – tag: forward_remote
- type: fast_forward
- args:
- upstream:
- – addr: https://dns.alidns.com/dns-query
- dial_addr: "223.5.5.5:443"
-
- – tag: response_has_cloudflare_ip
- type: response_matcher
- args:
- ip:
- – "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/13"
- – "104.24.0.0/14"
- – "172.64.0.0/13"
- – "131.0.72.0/22"
- – "2400:cb00::/32"
- – "2606:4700::/32"
- – "2803:f800::/32"
- – "2405:b500::/32"
- – "2405:8100::/32"
- – "2a06:98c0::/29"
- – "2c0f:f248::/32"
-
- – tag: replace_cloudflare_ip
- type: blackhole
- args:
- rcode: 0
- ipv4: "${优选IPv4}"
- ipv6: "${优选IPv6}"
-
- – tag: main_sequence
- type: sequence
- args:
- exec:
-
- – forward_remote
-
- – if: response_has_cloudflare_ip
- exec:
- – replace_cloudflare_ip
- – _return
-
- – _return
-
- servers:
- – exec: main_sequence
- listeners:
- – protocol: udp
- addr: 127.0.0.1:53
复制代码
|