From a24aec9914614d1699850b4c591e27bf4f735068 Mon Sep 17 00:00:00 2001 From: JamesFlare1212 Date: Tue, 7 May 2024 14:37:02 +0800 Subject: [PATCH] update sing-box config --- .../get-my-config/client-android.json | 2 +- .../get-my-config/client-windows.json | 162 +++++++++++++----- .../en/posts/sing-box/get-my-config/index.md | 162 +++++++++++++----- .../get-my-config/client-android.json | 2 +- .../get-my-config/client-windows.json | 162 +++++++++++++----- .../posts/sing-box/get-my-config/index.md | 162 +++++++++++++----- 6 files changed, 486 insertions(+), 166 deletions(-) diff --git a/content/en/posts/sing-box/get-my-config/client-android.json b/content/en/posts/sing-box/get-my-config/client-android.json index 06dd365..a1b6fe0 100644 --- a/content/en/posts/sing-box/get-my-config/client-android.json +++ b/content/en/posts/sing-box/get-my-config/client-android.json @@ -131,7 +131,7 @@ "mtu": 1400, "auto_route": true, "strict_route": true, - "stack": "gvisor", + "stack": "mixed", "sniff": true, "sniff_override_destination": false } diff --git a/content/en/posts/sing-box/get-my-config/client-windows.json b/content/en/posts/sing-box/get-my-config/client-windows.json index 79b11bc..894e4a9 100644 --- a/content/en/posts/sing-box/get-my-config/client-windows.json +++ b/content/en/posts/sing-box/get-my-config/client-windows.json @@ -6,17 +6,121 @@ "dns": { "servers": [ { - "tag": "cloudflare", - "address": "1.1.1.1" + "tag": "dns_proxy", + "address": "https://1.1.1.1/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "proxy" + }, + { + "tag": "dns_direct", + "address": "https://dns.alidns.com/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "direct" + }, + { + "tag": "dns_resolver", + "address": "223.5.5.5", + "detour": "direct" } ], "rules": [ { "outbound": "any", - "server": "cloudflare" + "server": "dns_resolver" + }, + { + "rule_set": "geosite-geolocation-!cn", + "server": "dns_proxy" + }, + { + "rule_set": "geosite-cn", + "server": "dns_direct" } ], - "strategy": "ipv4_only" + "final": "dns_proxy" + }, + "route": { + "rule_set": [ + { + "tag": "geosite-geolocation-!cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geoip-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geosite-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "proxy" + } + ], + "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + }, + { + "port": 853, + "network": "tcp", + "outbound": "block" + }, + { + "port": [ + 443, + 853 + ], + "network": "udp", + "outbound": "block" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn", + "invert": true + }, + { + "rule_set": "geosite-geolocation-!cn" + } + ], + "outbound": "proxy" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn" + }, + { + "rule_set": "geosite-cn" + } + ], + "outbound": "direct" + }, + { + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, + "outbound": "direct" + } + ], + "final": "proxy", + "auto_detect_interface": true }, "inbounds": [ { @@ -26,14 +130,14 @@ "inet4_address": "172.28.0.1/30", "auto_route": true, "strict_route": true, - "stack": "system", + "stack": "mixed", "sniff": true } ], "outbounds": [ { "type": "vless", - "tag": "vless-out", + "tag": "proxy", "server": "154.17.5.35", "server_port": 443, "uuid": "9337d5ec-b489-4bf4-a22c-19f7f6e8fbbd", @@ -51,49 +155,25 @@ "short_id": "7fcff4362963e98e" } }, - "packet_encoding": "xudp", - "multiplex": { - "enabled": false, - "protocol": "h2mux", - "max_streams": 10, - "padding": true, - "brutal": { - "enabled": false, - "up_mbps": 200, - "down_mbps": 200 - } - } + "packet_encoding": "xudp" }, { "type": "direct", "tag": "direct" }, + { + "type": "block", + "tag": "block" + }, { "type": "dns", - "tag": "dns" + "tag": "dns-out" } ], - "route": { - "geoip": { - "download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db", - "download_detour": "vless-out" - }, - "geosite": { - "download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db", - "download_detour": "vless-out" - }, - "rules": [ - { - "protocol": "dns", - "outbound": "dns" - }, - { - "geoip": [ - "private" - ], - "outbound": "direct" - } - ], - "auto_detect_interface": true + "experimental": { + "cache_file": { + "enabled": true, + "path": "cache.db" + } } } \ No newline at end of file diff --git a/content/en/posts/sing-box/get-my-config/index.md b/content/en/posts/sing-box/get-my-config/index.md index cdff067..4be7df0 100644 --- a/content/en/posts/sing-box/get-my-config/index.md +++ b/content/en/posts/sing-box/get-my-config/index.md @@ -142,17 +142,121 @@ This is my personal configuration. Obviously, exposing it to the public network "dns": { "servers": [ { - "tag": "cloudflare", - "address": "1.1.1.1" + "tag": "dns_proxy", + "address": "https://1.1.1.1/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "proxy" + }, + { + "tag": "dns_direct", + "address": "https://dns.alidns.com/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "direct" + }, + { + "tag": "dns_resolver", + "address": "223.5.5.5", + "detour": "direct" } ], "rules": [ { "outbound": "any", - "server": "cloudflare" + "server": "dns_resolver" + }, + { + "rule_set": "geosite-geolocation-!cn", + "server": "dns_proxy" + }, + { + "rule_set": "geosite-cn", + "server": "dns_direct" } ], - "strategy": "ipv4_only" + "final": "dns_proxy" + }, + "route": { + "rule_set": [ + { + "tag": "geosite-geolocation-!cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geoip-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geosite-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "proxy" + } + ], + "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + }, + { + "port": 853, + "network": "tcp", + "outbound": "block" + }, + { + "port": [ + 443, + 853 + ], + "network": "udp", + "outbound": "block" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn", + "invert": true + }, + { + "rule_set": "geosite-geolocation-!cn" + } + ], + "outbound": "proxy" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn" + }, + { + "rule_set": "geosite-cn" + } + ], + "outbound": "direct" + }, + { + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, + "outbound": "direct" + } + ], + "final": "proxy", + "auto_detect_interface": true }, "inbounds": [ { @@ -169,7 +273,7 @@ This is my personal configuration. Obviously, exposing it to the public network "outbounds": [ { "type": "vless", - "tag": "vless-out", + "tag": "proxy", "server": "154.17.5.35", "server_port": 443, "uuid": "9337d5ec-b489-4bf4-a22c-19f7f6e8fbbd", @@ -187,50 +291,26 @@ This is my personal configuration. Obviously, exposing it to the public network "short_id": "7fcff4362963e98e" } }, - "packet_encoding": "xudp", - "multiplex": { - "enabled": false, - "protocol": "h2mux", - "max_streams": 10, - "padding": true, - "brutal": { - "enabled": false, - "up_mbps": 200, - "down_mbps": 200 - } - } + "packet_encoding": "xudp" }, { "type": "direct", "tag": "direct" }, + { + "type": "block", + "tag": "block" + }, { "type": "dns", - "tag": "dns" + "tag": "dns-out" } ], - "route": { - "geoip": { - "download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db", - "download_detour": "vless-out" - }, - "geosite": { - "download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db", - "download_detour": "vless-out" - }, - "rules": [ - { - "protocol": "dns", - "outbound": "dns" - }, - { - "geoip": [ - "private" - ], - "outbound": "direct" - } - ], - "auto_detect_interface": true + "experimental": { + "cache_file": { + "enabled": true, + "path": "cache.db" + } } } ``` @@ -446,7 +526,7 @@ Download [client-windows.json](client-windows.json) Run the client ```bash -./sing-box -c client-windows.json +sing-box -c client-windows.json ``` ### Run sing-box Android Client diff --git a/content/zh-cn/posts/sing-box/get-my-config/client-android.json b/content/zh-cn/posts/sing-box/get-my-config/client-android.json index 06dd365..a1b6fe0 100644 --- a/content/zh-cn/posts/sing-box/get-my-config/client-android.json +++ b/content/zh-cn/posts/sing-box/get-my-config/client-android.json @@ -131,7 +131,7 @@ "mtu": 1400, "auto_route": true, "strict_route": true, - "stack": "gvisor", + "stack": "mixed", "sniff": true, "sniff_override_destination": false } diff --git a/content/zh-cn/posts/sing-box/get-my-config/client-windows.json b/content/zh-cn/posts/sing-box/get-my-config/client-windows.json index 79b11bc..894e4a9 100644 --- a/content/zh-cn/posts/sing-box/get-my-config/client-windows.json +++ b/content/zh-cn/posts/sing-box/get-my-config/client-windows.json @@ -6,17 +6,121 @@ "dns": { "servers": [ { - "tag": "cloudflare", - "address": "1.1.1.1" + "tag": "dns_proxy", + "address": "https://1.1.1.1/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "proxy" + }, + { + "tag": "dns_direct", + "address": "https://dns.alidns.com/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "direct" + }, + { + "tag": "dns_resolver", + "address": "223.5.5.5", + "detour": "direct" } ], "rules": [ { "outbound": "any", - "server": "cloudflare" + "server": "dns_resolver" + }, + { + "rule_set": "geosite-geolocation-!cn", + "server": "dns_proxy" + }, + { + "rule_set": "geosite-cn", + "server": "dns_direct" } ], - "strategy": "ipv4_only" + "final": "dns_proxy" + }, + "route": { + "rule_set": [ + { + "tag": "geosite-geolocation-!cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geoip-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geosite-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "proxy" + } + ], + "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + }, + { + "port": 853, + "network": "tcp", + "outbound": "block" + }, + { + "port": [ + 443, + 853 + ], + "network": "udp", + "outbound": "block" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn", + "invert": true + }, + { + "rule_set": "geosite-geolocation-!cn" + } + ], + "outbound": "proxy" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn" + }, + { + "rule_set": "geosite-cn" + } + ], + "outbound": "direct" + }, + { + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, + "outbound": "direct" + } + ], + "final": "proxy", + "auto_detect_interface": true }, "inbounds": [ { @@ -26,14 +130,14 @@ "inet4_address": "172.28.0.1/30", "auto_route": true, "strict_route": true, - "stack": "system", + "stack": "mixed", "sniff": true } ], "outbounds": [ { "type": "vless", - "tag": "vless-out", + "tag": "proxy", "server": "154.17.5.35", "server_port": 443, "uuid": "9337d5ec-b489-4bf4-a22c-19f7f6e8fbbd", @@ -51,49 +155,25 @@ "short_id": "7fcff4362963e98e" } }, - "packet_encoding": "xudp", - "multiplex": { - "enabled": false, - "protocol": "h2mux", - "max_streams": 10, - "padding": true, - "brutal": { - "enabled": false, - "up_mbps": 200, - "down_mbps": 200 - } - } + "packet_encoding": "xudp" }, { "type": "direct", "tag": "direct" }, + { + "type": "block", + "tag": "block" + }, { "type": "dns", - "tag": "dns" + "tag": "dns-out" } ], - "route": { - "geoip": { - "download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db", - "download_detour": "vless-out" - }, - "geosite": { - "download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db", - "download_detour": "vless-out" - }, - "rules": [ - { - "protocol": "dns", - "outbound": "dns" - }, - { - "geoip": [ - "private" - ], - "outbound": "direct" - } - ], - "auto_detect_interface": true + "experimental": { + "cache_file": { + "enabled": true, + "path": "cache.db" + } } } \ No newline at end of file diff --git a/content/zh-cn/posts/sing-box/get-my-config/index.md b/content/zh-cn/posts/sing-box/get-my-config/index.md index 62fd92e..bd2f16e 100644 --- a/content/zh-cn/posts/sing-box/get-my-config/index.md +++ b/content/zh-cn/posts/sing-box/get-my-config/index.md @@ -142,17 +142,121 @@ repost: "dns": { "servers": [ { - "tag": "cloudflare", - "address": "1.1.1.1" + "tag": "dns_proxy", + "address": "https://1.1.1.1/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "proxy" + }, + { + "tag": "dns_direct", + "address": "https://dns.alidns.com/dns-query", + "address_resolver": "dns_resolver", + "strategy": "ipv4_only", + "detour": "direct" + }, + { + "tag": "dns_resolver", + "address": "223.5.5.5", + "detour": "direct" } ], "rules": [ { "outbound": "any", - "server": "cloudflare" + "server": "dns_resolver" + }, + { + "rule_set": "geosite-geolocation-!cn", + "server": "dns_proxy" + }, + { + "rule_set": "geosite-cn", + "server": "dns_direct" } ], - "strategy": "ipv4_only" + "final": "dns_proxy" + }, + "route": { + "rule_set": [ + { + "tag": "geosite-geolocation-!cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-geolocation-!cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geoip-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geoip/rule-set/geoip-cn.srs", + "download_detour": "proxy" + }, + { + "tag": "geosite-cn", + "type": "remote", + "format": "binary", + "url": "https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-cn.srs", + "download_detour": "proxy" + } + ], + "rules": [ + { + "protocol": "dns", + "outbound": "dns-out" + }, + { + "port": 853, + "network": "tcp", + "outbound": "block" + }, + { + "port": [ + 443, + 853 + ], + "network": "udp", + "outbound": "block" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn", + "invert": true + }, + { + "rule_set": "geosite-geolocation-!cn" + } + ], + "outbound": "proxy" + }, + { + "type": "logical", + "mode": "and", + "rules": [ + { + "rule_set": "geoip-cn" + }, + { + "rule_set": "geosite-cn" + } + ], + "outbound": "direct" + }, + { + "rule_set": "geoip-cn", + "outbound": "direct" + }, + { + "ip_is_private": true, + "outbound": "direct" + } + ], + "final": "proxy", + "auto_detect_interface": true }, "inbounds": [ { @@ -169,7 +273,7 @@ repost: "outbounds": [ { "type": "vless", - "tag": "vless-out", + "tag": "proxy", "server": "154.17.5.35", "server_port": 443, "uuid": "9337d5ec-b489-4bf4-a22c-19f7f6e8fbbd", @@ -187,50 +291,26 @@ repost: "short_id": "7fcff4362963e98e" } }, - "packet_encoding": "xudp", - "multiplex": { - "enabled": false, - "protocol": "h2mux", - "max_streams": 10, - "padding": true, - "brutal": { - "enabled": false, - "up_mbps": 200, - "down_mbps": 200 - } - } + "packet_encoding": "xudp" }, { "type": "direct", "tag": "direct" }, + { + "type": "block", + "tag": "block" + }, { "type": "dns", - "tag": "dns" + "tag": "dns-out" } ], - "route": { - "geoip": { - "download_url": "https://github.com/SagerNet/sing-geoip/releases/latest/download/geoip.db", - "download_detour": "vless-out" - }, - "geosite": { - "download_url": "https://github.com/SagerNet/sing-geosite/releases/latest/download/geosite.db", - "download_detour": "vless-out" - }, - "rules": [ - { - "protocol": "dns", - "outbound": "dns" - }, - { - "geoip": [ - "private" - ], - "outbound": "direct" - } - ], - "auto_detect_interface": true + "experimental": { + "cache_file": { + "enabled": true, + "path": "cache.db" + } } } ``` @@ -446,7 +526,7 @@ sudo systemctl start sing-box 运行客户端 ```bash -./sing-box -c client-windows.json +sing-box -c client-windows.json ``` ### 配置 sing-box Android 客户端