# ============================================ # MosDNS v5 配置(GFW 解析并写入 MikroTik) # ============================================ log: level: info plugins: # ========= 规则集 ========= # GFW 域名(解析并写入 MikroTik) - tag: GFW_domains type: domain_set args: files: - "/usr/local/jinlingma/config/gfwlist.out.txt" # 中国大陆 IP 列表 - tag: geoip_cn type: ip_set args: files: - "/usr/local/jinlingma/config/cn.txt" # 缓存 - tag: cache type: cache args: size: 32768 lazy_cache_ttl: 43200 # ========= 上游定义 ========= # 国内上游 - tag: china-dns type: forward args: concurrent: 6 upstreams: - addr: "udp://202.96.128.86" - addr: "udp://202.96.128.166" - addr: "udp://119.29.29.29" - addr: "udp://223.5.5.5" - addr: "udp://114.114.114.114" - addr: "udp://180.76.76.76" # 国外上游(DoT) - tag: overseas-dns type: forward args: concurrent: 4 upstreams: - addr: "tls://1dot1dot1dot1.cloudflare-dns.com" dial_addr: "1.1.1.1" enable_pipeline: true - addr: "tls://1dot1dot1dot1.cloudflare-dns.com" dial_addr: "1.0.0.1" enable_pipeline: true - addr: "tls://dns.google" dial_addr: "8.8.8.8" enable_pipeline: true - addr: "tls://dns.google" dial_addr: "8.8.4.4" enable_pipeline: true # fallback 封装 - tag: forward_local type: fallback args: primary: china-dns secondary: china-dns threshold: 500 always_standby: true - tag: forward_remote type: fallback args: primary: overseas-dns secondary: overseas-dns threshold: 500 always_standby: true # 便捷封装:国内/国外 - tag: forward_local_upstream type: sequence args: - exec: prefer_ipv4 - exec: query_summary forward_local - exec: $forward_local - tag: forward_remote_upstream type: sequence args: - exec: prefer_ipv4 - exec: query_summary forward_remote - exec: $forward_remote # 若已有响应则直接返回 - tag: has_resp_sequence type: sequence args: - matches: has_resp exec: accept # ========= 🚀 增强的 MikroTik 插件(支持多设备多规则)========= # 设备 A:Amazon 相关域名 - tag: mikrotik_amazon type: mikrotik_addresslist domain_files: - "/usr/local/jinlingma/config/amazon.txt" - "/usr/local/jinlingma/config/aws.txt" args: host: "10.96.1.22" port: 9728 username: "admin" password: "szn0s!nw@pwd()" use_tls: false timeout: 3 address_list4: "Amazon" address_list6: "Amazon6" mask4: 24 mask6: 64 comment: "Amazon-AutoAdd" timeout_addr: 43200 cache_ttl: 3600 verify_add: false add_all_ips: true max_ips: 20 # 设备 B:Google 相关域名 - tag: mikrotik_google type: mikrotik_addresslist domain_files: - "/usr/local/jinlingma/config/google.txt" - "/usr/local/jinlingma/config/youtube.txt" args: host: "10.96.1.23" port: 9728 username: "admin" password: "szn0s!nw@pwd()" use_tls: false timeout: 3 address_list4: "Google" mask4: 32 comment: "Google-AutoAdd" timeout_addr: 21600 cache_ttl: 1800 verify_add: false add_all_ips: true max_ips: 15 # 设备 C:流媒体相关域名(示例) - tag: mikrotik_streaming type: mikrotik_addresslist domain_files: - "/usr/local/jinlingma/config/netflix.txt" - "/usr/local/jinlingma/config/disney.txt" args: host: "10.96.1.24" port: 9728 username: "admin" password: "szn0s!nw@pwd()" use_tls: false timeout: 5 address_list4: "Streaming" mask4: 32 comment: "Streaming-AutoAdd" timeout_addr: 21600 cache_ttl: 1800 verify_add: false add_all_ips: true max_ips: 30 # ========= 🚀 简化的查询逻辑 ========= # 拒绝无效查询 - tag: reject_invalid type: sequence args: - matches: qtype 65 exec: reject 3 # GFW 域名分流(仅解析,不写入设备) - tag: gfw_routing_only type: sequence args: - matches: qname $GFW_domains exec: $forward_remote_upstream - exec: query_summary gfw_overseas_routing # 智能 fallback 处理 - tag: smart_fallback_handler type: sequence args: - exec: prefer_ipv4 - exec: $forward_local - matches: resp_ip $geoip_cn exec: accept - exec: $forward_remote_upstream - exec: query_summary fallback_to_overseas # 🚀 极简主序列 - tag: main_sequence type: sequence args: # 1. 缓存检查 - exec: $cache # 2. 拒绝无效查询 - exec: $reject_invalid - exec: jump has_resp_sequence # 3. GFW 域名分流(仅解析) - exec: $gfw_routing_only - exec: jump has_resp_sequence # 4. 智能 fallback - exec: $smart_fallback_handler - exec: jump has_resp_sequence # 5. 🚀 MikroTik 设备处理(每个插件自动匹配域名) - exec: $mikrotik_amazon # 自动处理 Amazon 域名 - exec: $mikrotik_google # 自动处理 Google 域名 - exec: $mikrotik_streaming # 自动处理流媒体域名 # ========= 服务 ========= - tag: udp_server type: udp_server args: entry: main_sequence listen: ":5322" - tag: tcp_server type: tcp_server args: entry: main_sequence listen: ":5322"