Skip to content

Instantly share code, notes, and snippets.

@wd
Created February 2, 2025 17:18
Show Gist options
  • Save wd/9e900f43b1fd535dbcefbaf322963a23 to your computer and use it in GitHub Desktop.
Save wd/9e900f43b1fd535dbcefbaf322963a23 to your computer and use it in GitHub Desktop.
一个简单的 sing-box 配置
{
"inbounds": [
{
"type": "tun",
"address": [ "172.19.0.1/30" ],
"auto_route": true,
"strict_route": false
}
],
"outbounds": [
{
"tag": "proxy",
// your outbound server, don't change the above line
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"log": {
"level": "warn"
},
"dns": {
"servers": [
{
"tag": "google",
"address": "tls://8.8.8.8",
"detour": "proxy"
},
{
"tag": "local",
"address": "https://223.5.5.5/dns-query",
"detour": "direct"
}
],
"strategy": "ipv4_only",
"rules": [
{
"outbound": "any",
"server": "local"
},
{
"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": "114.114.114.114/24" // Any China client IP address
}
]
},
"route": {
"final": "proxy",
"rule_set": [
{
"type": "remote",
"tag": "geosite-geolocation-cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-cn.srs"
},
{
"type": "remote",
"tag": "geosite-geolocation-!cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs"
},
{
"type": "remote",
"tag": "geoip-cn",
"format": "binary",
"url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs"
}
],
"rules": [
{
"type": "logical",
"mode": "or",
"rules": [
{
"protocol": "dns"
},
{
"port": 53
}
],
"outbound": "dns-out"
},
{
"geoip": [
"private"
],
"outbound": "direct"
},
{
"type": "logical",
"mode": "or",
"rules": [
{
"port": 853
},
{
"network": "udp",
"port": 443
},
{
"protocol": "stun"
}
],
"outbound": "block"
},
{
"rule_set": [
"geoip-cn",
"geosite-geolocation-cn"
],
"outbound": "direct"
}
],
"auto_detect_interface": true
},
"experimental": {
"cache_file": {
"enabled": true,
"store_rdrc": true
},
"clash_api": {
"default_mode": "Enhanced"
}
}
}
@wd
Copy link
Author

wd commented Feb 2, 2025

保存放到 /etc/sing-box/ 目录下面。gentoo 可以通过 gentoo-zh overlay 安装 sing-box,然后使用 systemctl 启动就可以。
启动之后就会自动代理系统全部流量,然后分流。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment