Skip to content

Example sing-box Config

DNS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{
  "$schema": "https://gist.github.com/artiga033/fea992d95ad44dc8d024b229223b1002/raw/83c676c1ec9f37af2bce0505da396b5444b30032/sing-box.schema.json",
  "dns": {
    "servers": [
      { "tag": "dns:proxy", "address": "https://8.8.8.8/dns-query" },
      { "tag": "dns:local", "address": "local", "detour": "DIRECT" },
      { "tag": "dns:reject", "address": "rcode://refused" }
    ],
    "rules": [
      { "outbound": "any", "server": "dns:local" },
      {
        "rule_set": "geosite:ads",
        "server": "dns:reject",
        "disable_cache": true
      },
      { "rule_set": "geosite:private", "server": "dns:local" },
      { "clash_mode": "direct", "server": "dns:local" },
      { "clash_mode": "global", "server": "dns:proxy" },
      { "rule_set": "geosite:cn", "server": "dns:local" },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          { "rule_set": "geosite:proxy", "invert": true },
          { "rule_set": "geoip:cn" }
        ],
        "server": "dns:proxy",
        "client_subnet": "101.6.6.6"
      }
    ],
    "final": "dns:proxy",
    "independent_cache": true
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
  "$schema": "https://gist.github.com/artiga033/fea992d95ad44dc8d024b229223b1002/raw/83c676c1ec9f37af2bce0505da396b5444b30032/sing-box.schema.json",
  "dns": {
    "servers": [
      { "tag": "dns:proxy", "address": "https://8.8.8.8/dns-query" },
      { "tag": "dns:local", "address": "local", "detour": "DIRECT" },
      { "tag": "dns:reject", "address": "rcode://refused" },
      { "tag": "dns:fakeip", "address": "fakeip" }
    ],
    "rules": [
      { "outbound": "any", "server": "dns:local" },
      {
        "rule_set": "geosite:ads",
        "server": "dns:reject",
        "disable_cache": true
      },
      { "rule_set": "geosite:private", "server": "dns:local" },
      { "query_type": ["A", "AAAA"], "server": "dns:fakeip", "rewrite_ttl": 1 },
      { "clash_mode": "direct", "server": "dns:local" },
      { "clash_mode": "global", "server": "dns:proxy" },
      { "rule_set": "geosite:cn", "server": "dns:local" },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          { "rule_set": "geosite:proxy", "invert": true },
          { "rule_set": "geoip:cn" }
        ],
        "server": "dns:proxy",
        "client_subnet": "101.6.6.6"
      }
    ],
    "final": "dns:proxy",
    "independent_cache": true,
    "fakeip": {
      "enabled": true,
      "inet4_range": "198.18.0.0/15",
      "inet6_range": "fc00::/18"
    }
  }
}

Route

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  "$schema": "https://gist.github.com/artiga033/fea992d95ad44dc8d024b229223b1002/raw/83c676c1ec9f37af2bce0505da396b5444b30032/sing-box.schema.json",
  "route": {
    "rules": [
      {
        "type": "logical",
        "mode": "or",
        "rules": [{ "protocol": "dns" }, { "port": 53 }],
        "outbound": "out:dns"
      },
      {
        "type": "logical",
        "mode": "or",
        "rules": [
          { "port": 853 },
          { "network": "udp", "port": 443 },
          { "protocol": "stun" }
        ],
        "outbound": "REJECT"
      },
      { "rule_set": "rule-set:ads", "outbound": "REJECT" },
      {
        "ip_is_private": true,
        "rule_set": "rule-set:private",
        "outbound": "DIRECT"
      },
      { "clash_mode": "direct", "outbound": "DIRECT" },
      { "clash_mode": "global", "outbound": "PROXY" },
      { "rule_set": "rule-set:cn", "outbound": "DIRECT" },
      { "rule_set": "rule-set:ai", "outbound": "🤖 AI" },
      { "rule_set": "rule-set:download", "outbound": "☁️ Download" },
      { "rule_set": "rule-set:emby", "outbound": "🍟 Emby" },
      { "rule_set": "rule-set:media", "outbound": "📺 Media" }
    ],
    "final": "PROXY",
    "auto_detect_interface": true
  }
}