Skip to content

Instantly share code, notes, and snippets.

@z-x-f
Forked from piyoki/auto-artifact-export.yml
Created July 9, 2023 12:46
Show Gist options
  • Select an option

  • Save z-x-f/d481adb2c9eb8ddc438bccfa45966da4 to your computer and use it in GitHub Desktop.

Select an option

Save z-x-f/d481adb2c9eb8ddc438bccfa45966da4 to your computer and use it in GitHub Desktop.
mosdns-v5 config template
---
# /etc/mosdns/config.yaml
## -- Log Config -- ##
log:
level: error # ["debug", "info", "warn", and "error"], default is set to "info"
# file: "/var/log/mosdns.log"
## -- API Config -- ##
api:
http: "0.0.0.0:8080"
## -- Plugins Config -- ##
plugins:
## --- Cache --- ##
- tag: custom_cache
type: cache
args:
size: 10240
lazy_cache_ttl: 86400 # ttl set to 1 day
dump_file: ./cache.dump
dump_interval: 120 # autosave interval (s)
## --- Upstream Servers --- ##
- tag: upstreams
type: forward
args:
upstreams:
## --- Domestic DNS Servers --- ##
- tag: ali_dot
addr: tls://223.5.5.5
enable_pipeline: true
idle_timeout: 50
insecure_skip_verify: true
# - tag: ali_doh
# addr: https://223.5.5.5/dns-query
# enable_pipeline: true
# enable_pipeline: true
# idle_timeout: 50
# insecure_skip_verify: true
## --- Remote DNS Servers --- ##
- tag: google_dot
addr: tls://8.8.8.8
enable_pipeline: true
idle_timeout: 50
insecure_skip_verify: true
# - tag: google_doh
# addr: https://8.8.8.8/dns-query
# enable_pipeline: true
# idle_timeout: 50
# insecure_skip_verify: true
- tag: cloudflare_dot
addr: tls://1.1.1.1
enable_pipeline: true
idle_timeout: 50
insecure_skip_verify: true
# - tag: cloudflare_doh
# addr: https://1.1.1.1/dns-query
# enable_pipeline: true
# idle_timeout: 50
# insecure_skip_verify: true
## --- Domestic Sequence --- ##
- tag: domestic_seq
type: sequence
args:
- exec: $upstreams ali_dot
## --- Remote Sequence --- ##
- tag: remote_seq
type: sequence
args:
- exec: $upstreams google_dot
## --- CN-IP Sequence --- ##
# if response does NOT has CN IP, drop it
- tag: cn_ip
type: sequence
args:
- exec: $upstreams ali_dot
- matches: "!resp_ip &ips/cn.txt"
exec: drop_resp
## --- Fallback --- ###
# (ip split) if response has CN ip, accept it; otherwise, drop --> forward it to remote upstream servers
- tag: fallback_ip
type: fallback
args:
primary: cn_ip # empty response
secondary: remote_seq
always_standby: true
## --- Main Sequence --- ##
- tag: main
type: sequence
args:
- exec: query_summary entry
- exec: prefer_ipv4 # prefer ipv4 for remote
- matches:
- qname &./domains/category-ads-all.txt
exec: reject 0
- exec: $custom_cache # enable cache
- {matches: has_resp, exec: accept} # end if reponse found in cache
- matches:
- qname &./custom/remote.txt # custom remote domains
exec: goto remote_seq
- matches:
- qname &./domains/cn.txt # cn domains
exec: goto domestic_seq
- matches:
- qname &./domains/geolocation-!cn.txt # non-cn domains
- qname &./domains/gfw.txt
- qname &./domains/google-scholar.txt
- qname &./domains/category-scholar-!cn.txt
- qname &./domains/icloud.txt
- qname &./domains/apple-cn.txt
- qname &./domains/twitter.txt
- qname &./domains/telegram.txt
- qname &./domains/google.txt
exec: goto remote_seq
- exec: $fallback_ip # use ip to split the rest domains
## --- Server Configuration --- ##
- tag: server
type: udp_server
args:
entry: main
listen: :53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment