sing-box使用教程与分流规则,包括ios sing-box和安卓的配置。
已经有订阅转换了,不用自己手搓;比如开源的:开源订阅转换,安全:https://scg.jokin.uk/
更多订阅转换: https://jichanggo.com/clash2sing-box
singbox 客户端教程:
https://jichanggo.com/singbox
本文不能复制,原文才可以.原文地址
为了方便规则文件已经上传到 github: https://github.com/hwanz/sing-box
sing-box for ios/sfi
下载和文档:https://sing-box.sagernet.org/installation/clients/sfi/
ios sing-box reality-tcp配置模版,略长,点击展开
{
"log": {
"disabled": false,
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://dns.google/dns-query",
"address_resolver": "dns-direct",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "dns-direct",
"address": "https://dns.alidns.com/dns-query",
"address_resolver": "dns-local",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "direct"
},
{
"tag": "dns-local",
"address": "local",
"detour": "direct"
},
{
"tag": "dns-block",
"address": "rcode://success"
},
{
"tag": "dns-fake",
"address": "fakeip",
"strategy": "ipv4_only"
}
],
"rules": [
{
"geosite": "private",
"server": "dns-local"
},
{
"geosite": "category-ads-all",
"server": "dns-block",
"disable_cache": true
},
{
"inbound": "tun-in",
"query_type": [
"A",
"AAAA"
],
"geosite": "geolocation-!cn",
"server": "dns-fake",
"rewrite_ttl": 999999999
},
{
"geosite": [
"category-games@cn",
"cn"
],
"server": "dns-direct"
}
],
"final": "dns-remote",
"reverse_mapping": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"strategy": "ipv4_only",
"independent_cache": true
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
},
{
"type": "direct",
"tag": "dns-in",
"listen": "127.0.0.1",
"listen_port": 6450,
"override_address": "8.8.8.8",
"override_port": 53
},
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"endpoint_independent_nat": true,
"stack": "system",
"platform": {
"http_proxy": {
"enabled": true,
"server": "127.0.0.1",
"server_port": 2080
}
},
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "", // 服务端的 IP
"server_port": 443,
"uuid": "", // 与服务端一致
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "", // 与服务端一致
"utls": {
"enabled": true,
"fingerprint": "chrome" // 使用 uTLS 库模拟客户端 TLS 指纹
},
"reality": {
"enabled": true,
"public_key": "", // 填 "PublicKey" 的值
"short_id": "" // 与服务端一致
}
},
"packet_encoding": "xudp"
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "direct",
"tag": "bypass"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"port": 53,
"outbound": "dns-out"
},
{
"inbound": "dns_in",
"outbound": "dns-out"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"geosite": "private",
"outbound": "bypass"
},
{
"network": "udp",
"port": 443,
"outbound": "block"
},
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"geosite": [
"category-games@cn",
"cn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "bypass"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "clash_api",
"external_ui_download_detour": "proxy",
"default_mode": "rule",
"store_fakeip": true,
"cache_file": "cache.db"
}
}
}
ios sing-box reality-grcp配置模版,和tcp不一样的就是outbond部分
{
"log": {
"disabled": false,
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://dns.google/dns-query",
"address_resolver": "dns-direct",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "dns-direct",
"address": "https://dns.alidns.com/dns-query",
"address_resolver": "dns-local",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "direct"
},
{
"tag": "dns-local",
"address": "local",
"detour": "direct"
},
{
"tag": "dns-block",
"address": "rcode://success"
},
{
"tag": "dns-fake",
"address": "fakeip",
"strategy": "ipv4_only"
}
],
"rules": [
{
"geosite": "private",
"server": "dns-local"
},
{
"geosite": "category-ads-all",
"server": "dns-block",
"disable_cache": true
},
{
"inbound": "tun-in",
"query_type": [
"A",
"AAAA"
],
"geosite": "geolocation-!cn",
"server": "dns-fake",
"rewrite_ttl": 999999999
},
{
"geosite": [
"category-games@cn",
"cn"
],
"server": "dns-direct"
}
],
"final": "dns-remote",
"reverse_mapping": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"strategy": "ipv4_only",
"independent_cache": true
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
},
{
"type": "direct",
"tag": "dns-in",
"listen": "127.0.0.1",
"listen_port": 6450,
"override_address": "8.8.8.8",
"override_port": 53
},
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"endpoint_independent_nat": true,
"stack": "system",
"platform": {
"http_proxy": {
"enabled": true,
"server": "127.0.0.1",
"server_port": 2080
}
},
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "", // 服务端的 IP
"server_port": 443,
"uuid": "", // 与服务端一致
"flow": "", // 留空
"tls": {
"enabled": true,
"server_name": "", // 与服务端一致
"utls": {
"enabled": true,
"fingerprint": "chrome" // 使用 uTLS 库模拟客户端 TLS 指纹
},
"reality": {
"enabled": true,
"public_key": "", // 填 "PublicKey" 的值
"short_id": "" // 与服务端一致
}
},
"packet_encoding": "xudp",
"transport": {
"type": "grpc",
"service_name": "grpc" // 与服务端一致
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "direct",
"tag": "bypass"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"port": 53,
"outbound": "dns-out"
},
{
"inbound": "dns_in",
"outbound": "dns-out"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"geosite": "private",
"outbound": "bypass"
},
{
"network": "udp",
"port": 443,
"outbound": "block"
},
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"geosite": [
"category-games@cn",
"cn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "bypass"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "clash_api",
"external_ui_download_detour": "proxy",
"default_mode": "rule",
"store_fakeip": true,
"cache_file": "cache.db"
}
}
}
点击Profiles-New Profile--Name随便起名字--Create--点击刚才创建的配置--Edit Content--删除里面的本来的{}--复制粘贴配置进去--check检查下弹窗success表示格式正确
short_id 可以空。
ios:sfi不支持system stack,所以配置里面用的是gvisor。
安卓
下载地址:https://sing-box.sagernet.org/zh/installation/clients/sfa/
安卓 sing-box reality-tcp配置模版,安卓10以上,略长
{
"log": {
"disabled": false,
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://dns.google/dns-query",
"address_resolver": "dns-direct",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "dns-direct",
"address": "https://223.5.5.5/dns-query",
"strategy": "ipv4_only",
"detour": "direct"
},
{
"tag": "dns-local",
"address": "local",
"detour": "direct"
},
{
"tag": "dns-block",
"address": "rcode://success"
},
{
"tag": "dns-fake",
"address": "fakeip",
"strategy": "ipv4_only"
}
],
"rules": [
{
"geosite": "private",
"server": "dns-direct"
},
{
"geosite": "category-ads-all",
"server": "dns-block",
"disable_cache": true
},
{
"inbound": "tun-in",
"query_type": [
"A",
"AAAA"
],
"geosite": "geolocation-!cn",
"server": "dns-fake",
"rewrite_ttl": 999999999
},
{
"geosite": [
"category-games@cn",
"cn"
],
"server": "dns-direct"
}
],
"final": "dns-remote",
"reverse_mapping": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"strategy": "ipv4_only",
"independent_cache": true
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
},
{
"type": "direct",
"tag": "dns-in",
"listen": "127.0.0.1",
"listen_port": 6450,
"override_address": "8.8.8.8",
"override_port": 53
},
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1",
"198.18.0.0/15"
],
"inet6_route_address": [
"::/1",
"8000::/1",
"fc00::/18"
],
"endpoint_independent_nat": true,
"stack": "gvisor",
"platform": {
"http_proxy": {
"enabled": true,
"server": "127.0.0.1",
"server_port": 2080
}
},
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "", // 服务端的 IP
"server_port": 443,
"uuid": "", // 与服务端一致
"flow": "xtls-rprx-vision",
"tls": {
"enabled": true,
"server_name": "", // 与服务端一致
"utls": {
"enabled": true,
"fingerprint": "chrome" // 使用 uTLS 库模拟客户端 TLS 指纹
},
"reality": {
"enabled": true,
"public_key": "", // 填 "PublicKey" 的值
"short_id": "" // 与服务端一致
}
},
"packet_encoding": "xudp"
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "direct",
"tag": "bypass"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"port": 53,
"outbound": "dns-out"
},
{
"inbound": "dns_in",
"outbound": "dns-out"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"geosite": "private",
"outbound": "bypass"
},
{
"network": "udp",
"port": 443,
"outbound": "block"
},
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"geosite": [
"category-games@cn",
"cn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "bypass"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "clash_api",
"external_ui_download_detour": "proxy",
"default_mode": "rule",
"store_fakeip": true,
"cache_file": "cache.db"
}
}
}
安卓 sing-box reality-grpc配置模版,安卓10以上,略长
{
"log": {
"disabled": false,
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://dns.google/dns-query",
"address_resolver": "dns-direct",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "dns-direct",
"address": "https://223.5.5.5/dns-query",
"strategy": "ipv4_only",
"detour": "direct"
},
{
"tag": "dns-local",
"address": "local",
"detour": "direct"
},
{
"tag": "dns-block",
"address": "rcode://success"
},
{
"tag": "dns-fake",
"address": "fakeip",
"strategy": "ipv4_only"
}
],
"rules": [
{
"geosite": "private",
"server": "dns-direct"
},
{
"geosite": "category-ads-all",
"server": "dns-block",
"disable_cache": true
},
{
"inbound": "tun-in",
"query_type": [
"A",
"AAAA"
],
"geosite": "geolocation-!cn",
"server": "dns-fake",
"rewrite_ttl": 999999999
},
{
"geosite": [
"category-games@cn",
"cn"
],
"server": "dns-direct"
}
],
"final": "dns-remote",
"reverse_mapping": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"strategy": "ipv4_only",
"independent_cache": true
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
},
{
"type": "direct",
"tag": "dns-in",
"listen": "127.0.0.1",
"listen_port": 6450,
"override_address": "8.8.8.8",
"override_port": 53
},
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1",
"198.18.0.0/15"
],
"inet6_route_address": [
"::/1",
"8000::/1",
"fc00::/18"
],
"endpoint_independent_nat": true,
"stack": "gvisor",
"platform": {
"http_proxy": {
"enabled": true,
"server": "127.0.0.1",
"server_port": 2080
}
},
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
}
],
"outbounds": [
{
"type": "vless",
"tag": "proxy",
"server": "", // 服务端的 IP
"server_port": 443,
"uuid": "", // 与服务端一致
"flow": "", // 留空
"tls": {
"enabled": true,
"server_name": "", // 与服务端一致
"utls": {
"enabled": true,
"fingerprint": "chrome" // 使用 uTLS 库模拟客户端 TLS 指纹
},
"reality": {
"enabled": true,
"public_key": "", // 填 "PublicKey" 的值
"short_id": "" // 与服务端一致
}
},
"packet_encoding": "xudp",
"transport": {
"type": "grpc",
"service_name": "grpc" // 与服务端一致
}
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "direct",
"tag": "bypass"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"port": 53,
"outbound": "dns-out"
},
{
"inbound": "dns_in",
"outbound": "dns-out"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"geosite": "private",
"outbound": "bypass"
},
{
"network": "udp",
"port": 443,
"outbound": "block"
},
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"geosite": [
"category-games@cn",
"cn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "bypass"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "clash_api",
"external_ui_download_detour": "proxy",
"default_mode": "rule",
"store_fakeip": true,
"cache_file": "cache.db"
}
}
}
我手机不是安卓10,自测吧。
安卓10以下也可以用的:outbounds里面的自行替换就好。不重复了。
安卓 sing-box reality配置模版,安卓10以下也可以用,略长
{
"log": {
"disabled": false,
"level": "error",
"timestamp": true
},
"dns": {
"servers": [
{
"tag": "dns-remote",
"address": "https://dns.google/dns-query",
"address_resolver": "dns-direct",
"address_strategy": "ipv4_only",
"strategy": "ipv4_only",
"detour": "proxy"
},
{
"tag": "dns-direct",
"address": "https://223.5.5.5/dns-query",
"strategy": "ipv4_only",
"detour": "direct"
},
{
"tag": "dns-local",
"address": "local",
"detour": "direct"
},
{
"tag": "dns-block",
"address": "rcode://success"
},
{
"tag": "dns-fake",
"address": "fakeip",
"strategy": "ipv4_only"
}
],
"rules": [
{
"geosite": "private",
"server": "dns-direct"
},
{
"geosite": "category-ads-all",
"server": "dns-block",
"disable_cache": true
},
{
"inbound": "tun-in",
"query_type": [
"A",
"AAAA"
],
"geosite": "geolocation-!cn",
"server": "dns-fake",
"rewrite_ttl": 999999999
},
{
"geosite": [
"category-games@cn",
"cn"
],
"server": "dns-direct"
}
],
"final": "dns-remote",
"reverse_mapping": true,
"fakeip": {
"enabled": true,
"inet4_range": "198.18.0.0/15",
"inet6_range": "fc00::/18"
},
"strategy": "ipv4_only",
"independent_cache": true
},
"inbounds": [
{
"type": "mixed",
"tag": "mixed-in",
"listen": "127.0.0.1",
"listen_port": 2080,
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
},
{
"type": "direct",
"tag": "dns-in",
"listen": "127.0.0.1",
"listen_port": 6450,
"override_address": "8.8.8.8",
"override_port": 53
},
{
"type": "tun",
"tag": "tun-in",
"mtu": 9000,
"inet4_address": "172.19.0.1/30",
"inet6_address": "fdfe:dcba:9876::1/126",
"auto_route": true,
"strict_route": true,
"inet4_route_address": [
"0.0.0.0/1",
"128.0.0.0/1",
"198.18.0.0/15"
],
"inet6_route_address": [
"::/1",
"8000::/1",
"fc00::/18"
],
"endpoint_independent_nat": true,
"stack": "gvisor",
"sniff": true,
"sniff_override_destination": false,
"domain_strategy": "ipv4_only"
}
],
"outbounds": [
{
"tag": "proxy"
//换成你的节点,注意tag必须为proxy,参考上方的
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "direct",
"tag": "bypass"
},
{
"type": "block",
"tag": "block"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"geoip": {
"download_url": "https://github.com/soffchen/sing-geoip/releases/latest/download/geoip.db",
"download_detour": "proxy"
},
"geosite": {
"download_url": "https://github.com/soffchen/sing-geosite/releases/latest/download/geosite.db",
"download_detour": "proxy"
},
"rules": [
{
"port": 53,
"outbound": "dns-out"
},
{
"inbound": "dns_in",
"outbound": "dns-out"
},
{
"protocol": "dns",
"outbound": "dns-out"
},
{
"geosite": "private",
"outbound": "bypass"
},
{
"network": "udp",
"port": 443,
"outbound": "block"
},
{
"geosite": "category-ads-all",
"outbound": "block"
},
{
"geosite": [
"category-games@cn",
"cn"
],
"outbound": "direct"
},
{
"geoip": [
"cn",
"private"
],
"outbound": "bypass"
}
],
"final": "proxy",
"auto_detect_interface": true
},
"experimental": {
"clash_api": {
"external_controller": "127.0.0.1:9090",
"external_ui": "clash_api",
"external_ui_download_detour": "proxy",
"default_mode": "rule",
"store_fakeip": true,
"cache_file": "cache.db"
}
}
}