适用于sfa的sing-box配置示例

基于官方手册少量修改,可用于最新sing-box for android 1.11.0,仅供参考。建议搭配sing-box-subscribe使用。

{
  "log": {
    "level": "info",
    "timestamp": true
  },
  "dns": {
    "servers": [
      {
        "tag": "google",
        "address": "https://dns.google/dns-query",
        "address_resolver": "resolver"
      },
      {
        "tag": "local",
        "address": "https://dns.alidns.com/dns-query",
        "address_resolver": "resolver",
        "detour": "direct"
      },
      {
        "tag": "resolver",
        "address": "114.114.114.114",
        "detour": "direct"
      }
    ],
    "rules": [
      {
        "outbound": "any",
        "server": "resolver"
      },
      {
        "clash_mode": "Direct",
        "server": "local"
      },
      {
        "clash_mode": "Global",
        "server": "google"
      },
      {
        "rule_set": "geosite-geolocation-cn",
        "server": "local"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "rule_set": "geosite-geolocation-!cn",
            "invert": true
          },
          {
            "rule_set": "geoip-cn"
          }
        ],
        "server": "google",
        "client_subnet": "1.0.8.0/24"
      }
    ]
  },
  "inbounds": [
    {
      "type": "tun",
      "address": [
        "172.18.0.1/30",
        "fdfe:dcba:9876::1/126"
      ],
      "auto_route": true,
      "strict_route": true
    }
  ],
  "outbounds": [
    {
      "type": "selector",
      "tag": "select",
      "outbounds": [
        "auto",
        "{all}"
      ]
    },
    {
      "type": "urltest",
      "tag": "auto",
      "outbounds": [
        "{all}"
      ]
    },
    {
      "type": "direct",
      "tag": "direct"
    }
  ],
  "route": {
    "rules": [
      {
        "action": "sniff"
      },
      {
        "protocol": "dns",
        "action": "hijack-dns"
      },
      {
        "ip_is_private": true,
        "outbound": "direct"
      },
      {
        "clash_mode": "Direct",
        "outbound": "direct"
      },
      {
        "clash_mode": "Global",
        "outbound": "select"
      },
      {
        "type": "logical",
        "mode": "or",
        "rules": [
          {
            "port": 853
          },
          {
            "network": "udp",
            "port": 443
          },
          {
            "protocol": "stun"
          }
        ],
        "action": "reject"
      },
      {
        "rule_set": [
          "geoip-cn",
          "geosite-geolocation-cn"
        ],
        "outbound": "direct"
      }
    ],
    "rule_set": [
      {
        "type": "remote",
        "tag": "geoip-cn",
        "format": "binary",
        "url": "https://ghproxy.net/https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geoip/geoip-cn.srs",
        "download_detour": "direct"
      },
      {
        "type": "remote",
        "tag": "geosite-geolocation-cn",
        "format": "binary",
        "url": "https://ghproxy.net/https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-geolocation-cn.srs",
        "download_detour": "direct"
      },
      {
        "type": "remote",
        "tag": "geosite-geolocation-!cn",
        "format": "binary",
        "url": "https://ghproxy.net/https://raw.githubusercontent.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-geolocation-!cn.srs",
        "download_detour": "direct"
      }
    ],
    "auto_detect_interface": true,
    "override_android_vpn": true
  },
  "experimental": {
    "cache_file": {
      "enabled": true,
      "store_rdrc": true
    },
    "clash_api": {
      "external_controller": "127.0.0.1:9090"
    }
  }
}
20 Likes

感谢大佬分享

1 Like

大佬太强了 :tieba_087:

1 Like

强大的佬 试试

感谢大佬分享,可以用上了。不过Sing-box的修改变动过大过于频繁,学习使用成本太高,建议作为备用选项。

已经在服务器上搭建好了hysteria2,该如何修改您的配置以便在安卓手机上导入sfa中呢?

看官方文档,在出站部分加上Hysteria2就行了

时常汇入就出现错误,必须复制贴上的方式才能成功。

按你这配置能用了,但是出现错误 transport endpoint is not connected,是不是endpoints没设置?

可能是服务端的问题。顺便更新一版

config
{
  "log": {
    "level": "info",
    "timestamp": true
  },
  "experimental": {
    "cache_file": {
      "enabled": true,
      "store_fakeip": true,
      "store_rdrc": true
    },
    "clash_api": {
      "external_controller": "127.0.0.1:9090",
      "external_ui": "ui",
      "external_ui_download_url": "https://ghproxy.cn/github.com/MetaCubeX/metacubexd/archive/gh-pages.zip",
      "external_ui_download_detour": "direct"
    }
  },
  "dns": {
    "servers": [
      {
        "tag": "google",
        "address": "https://8.8.8.8/dns-query"
      },
      {
        "tag": "local",
        "address": "https://223.5.5.5/dns-query",
        "detour": "direct"
      },
      {
        "tag": "remote",
        "address": "fakeip"
      }
    ],
    "rules": [
      {
        "outbound": "any",
        "server": "local"
      },
      {
        "clash_mode": "Direct",
        "server": "local"
      },
      {
        "clash_mode": "Global",
        "server": "google"
      },
      {
        "query_type": [
          "A",
          "AAAA"
        ],
        "rule_set": "geosite-cn",
        "server": "remote"
      },
      {
        "rule_set": "geosite-cn",
        "server": "local"
      },
      {
        "type": "logical",
        "mode": "and",
        "rules": [
          {
            "rule_set": "geosite-geolocation-!cn",
            "invert": true
          },
          {
            "rule_set": "geoip-cn"
          }
        ],
        "server": "google",
        "client_subnet": "1.0.8.0/24"
      },
      {
        "query_type": [
          "A",
          "AAAA"
        ],
        "server": "remote"
      }
    ],
    "fakeip": {
      "enabled": true,
      "inet4_range": "198.18.0.0/15",
      "inet6_range": "fc00::/18"
    },
    "strategy": "prefer_ipv4",
    "independent_cache": true
  },
  "inbounds": [
    {
      "type": "tun",
      "address": [
        "172.18.0.1/30",
        "fdfe:dcba:9876::1/126"
      ],
      "auto_route": true,
      "strict_route": true,
      "platform": {
        "http_proxy": {
          "enabled": true,
          "server": "127.0.0.1",
          "server_port": 7890
        }
      }
    },
    {
      "type": "mixed",
      "listen": "::",
      "listen_port": 7890
    }
  ],
  "outbounds": [
    {
      "tag": "select",
      "type": "selector",
      "outbounds": [
        "all",
        "auto",
        "HongKong",
        "TaiWan",
        "Singapore",
        "Japan",
        "America",
        "Others",
        "direct"
      ]
    },
    {
      "tag": "all",
      "type": "selector",
      "outbounds": [
        "{all}"
      ]
    },
    {
      "tag": "auto",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "interval": "6m"
    },
    {
      "tag": "AI",
      "type": "selector",
      "outbounds": [
        "TaiWan",
        "Singapore",
        "Japan",
        "America",
        "Others",
        "select"
      ]
    },
    {
      "tag": "HongKong",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "include",
          "keywords": [
            "🇭🇰|HK|hk|香港|港|HongKong"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "tag": "TaiWan",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "include",
          "keywords": [
            "🇹🇼|TW|tw|台湾|臺灣|台|Taiwan"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "tag": "Singapore",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "include",
          "keywords": [
            "🇸🇬|SG|sg|新加坡|狮|Singapore"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "tag": "Japan",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "include",
          "keywords": [
            "🇯🇵|JP|jp|日本|日|Japan"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "tag": "America",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "include",
          "keywords": [
            "🇺🇸|US|us|美国|美|United States"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "tag": "Others",
      "type": "urltest",
      "outbounds": [
        "{all}"
      ],
      "filter": [
        {
          "action": "exclude",
          "keywords": [
            "🇭🇰|HK|hk|香港|香|🇹🇼|TW|tw|台湾|台|🇸🇬|SG|sg|新加坡|狮|🇯🇵|JP|jp|日本|日|🇺🇸|US|us|美国|美"
          ]
        }
      ],
      "interval": "6m"
    },
    {
      "type": "direct",
      "tag": "direct"
    }
  ],
  "route": {
    "auto_detect_interface": true,
    "rules": [
      {
        "action": "sniff"
      },
      {
        "protocol": "dns",
        "action": "hijack-dns"
      },
      {
        "ip_is_private": true,
        "outbound": "direct"
      },
      {
        "clash_mode": "Direct",
        "outbound": "direct"
      },
      {
        "clash_mode": "Global",
        "outbound": "select"
      },
      {
        "rule_set": [
          "geosite-openai",
          "geosite-google-gemini"
        ],
        "outbound": "AI"
      },
      {
        "rule_set": [
          "geoip-cn",
          "geosite-cn"
        ],
        "outbound": "direct"
      }
    ],
    "rule_set": [
      {
        "tag": "geosite-openai",
        "type": "remote",
        "format": "binary",
        "url": "https://ghproxy.cn/https://raw.github.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-openai.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geosite-google-gemini",
        "type": "remote",
        "format": "binary",
        "url": "https://ghproxy.cn/https://raw.github.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-google-gemini.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geosite-cn",
        "type": "remote",
        "format": "binary",
        "url": "https://ghproxy.cn/https://raw.github.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-cn.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geosite-geolocation-!cn",
        "type": "remote",
        "format": "binary",
        "url": "https://ghproxy.cn/https://raw.github.com/lyc8503/sing-box-rules/rule-set-geosite/geosite-geolocation-!cn.srs",
        "download_detour": "direct"
      },
      {
        "tag": "geoip-cn",
        "type": "remote",
        "format": "binary",
        "url": "https://ghproxy.cn/https://raw.github.com/lyc8503/sing-box-rules/rule-set-geoip/geoip-cn.srs",
        "download_detour": "direct"
      }
    ]
  }
}

看到官网更新了一个第三方singbox gui,试试

有吗?哪个?

咦我好像点叉网址了,应该不在官网上
是这个:GitHub - GUI-for-Cores/GUI.for.SingBox: GUI for SingBox

用过,很屎,win端建议v2rayn或者直接裸核

请问一下rule和dns的final不指定的话,是会怎么走呢

看官方文档
路由.final:如果为空,将使用第一个可用于对应协议的出站。
dns.final:默认使用第一个服务器。