SingBox自用完美配置文件

服务端#

singbox安装#

singbox官方文档

Debian

sudo apt update -y

sudo apt upgrade -y

sudo curl -fsSL https://sing-box.app/gpg.key -o /etc/apt/keyrings/sagernet.asc

sudo chmod a+r /etc/apt/keyrings/sagernet.asc

echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/sagernet.asc] https://deb.sagernet.org/ * *" | \
  sudo tee /etc/apt/sources.list.d/sagernet.list > /dev/null
  
sudo apt update

sudo apt install sing-box=1.10.1  #安装1.10.1版本

开启bbr和tcp-brutal#

bbr

vi /etc/sysctl.conf

添加下面代码

net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbr
net.ipv6.tcp_congestion_control=bbr

tcp-brutal

bash <(curl -fsSL https://tcp.hy2.sh/)

服务端

vi /etc/sing-box/config.json
{
    "log": {
        "disabled": false,
        "level": "info",
        "timestamp": true
    },
    "dns": {
        "servers": [
            {
                "tag": "local",
                "address": "local",
                "strategy": "ipv4_only",
                "detour": "direct"
            },
            {
                "tag": "netflix",
                "address": "103.148.72.249",          #netflixDNS劫持
                "strategy": "ipv4_only",
                "detour": "direct"
            }
        ],
        "rules": [
            {
                "ip_version": 4,
                "outbound": "any",
                "server": "local"
            },
            {
                "rule_set": [
                    "geosite-netflix"
                ],
                "server": "netflix"
            }
        ],
        "final": "local",
        "strategy": "ipv4_only",
        "disable_cache": false,
        "disable_expire": false,
        "independent_cache": false
    },
    "inbounds": [
        {
            "type": "shadowsocks",
            "tag": "ss-in",
            "listen": "::",
            "listen_port": 2222,
            "tcp_fast_open": true,
            "tcp_multi_path": true,
            "network": "tcp",
            "method": "2022-blake3-aes-128-gcm",
            "password": "",
            "sniff": true,
            "sniff_override_destination": true,
            "multiplex": {
                "enabled": true,
                "padding": false,
                "brutal": {
                    "enabled": true,
                    "up_mbps": 100,
                    "down_mbps": 100
                }
            }
        },
        {
            "type": "vless",
            "tag": "vless-in",
            "listen": "::",
            "listen_port": 6128,
            "tcp_fast_open": true,
            "tcp_multi_path": true,
            "sniff": true,
            "sniff_override_destination": false,
            "multiplex": {
                "enabled": true,
                "padding": false,
                "brutal": {
                    "enabled": false,
                    "up_mbps": 100,
                    "down_mbps": 100
                }
            },
            "users": [
                {
                    "uuid": "",
                    "flow": "xtls-rprx-vision"
                }
            ],
            "tls": {
                "enabled": true,
                "server_name": "",
                "reality": {
                    "enabled": true,
                    "handshake": {
                        "server": "",
                        "server_port": 443
                    },
                    "private_key": "",
                    "short_id": [
                        ""
                    ]
                }
            }
        }
    ],
    "outbounds": [
        {
            "type": "direct",
            "tag": "direct",
            "tcp_fast_open": true,
            "tcp_multi_path": true
        },
        {
            "type": "block",
            "tag": "block"
        },
        {
            "type": "socks",           #分流二级代理的节点,例如socks协议
            "tag": "kr",              
            "server": "",
            "server_port": 14900,
            "version": "5",
            "username": "",
            "password": ""
        }
    ],
    "route": {
        "rule_set": [
            {
                "tag": "geosite-openai",
                "type": "remote",
                "format": "binary",
                "url": "https://github.com/SagerNet/sing-geosite/raw/rule-set/geosite-openai.srs",
                "download_detour": "direct"
            },
            {
                "tag": "geosite-claude",
                "type": "remote",
                "format": "binary",
                "url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-anthropic.srs",
                "download_detour": "direct"
            },
            {
                "tag": "geosite-netflix",
                "type": "remote",
                "format": "binary",
                "url": "https://github.com/SagerNet/sing-geosite/raw/refs/heads/rule-set/geosite-netflix.srs",
                "download_detour": "direct"
            }
        ],
        "rules": [
            {
                "protocol": [
                    "bittorrent",
                    "quic"
                ],
                "outbound": "block"
            },
            {
                "rule_set": [
                    "geosite-claude",
                    "geosite-openai"
                ],
                "outbound": "kr"
            },
            {
                "inbound": [
                    "ss-in",
                    "vless-in"
                ],
                "outbound": "direct"
            }
        ]
    }
}

重启生效

启动服务端#

行动命令
启用sudo systemctl enable sing-box
禁用sudo systemctl disable sing-box
启动sudo systemctl start sing-box
停止sudo systemctl stop sing-box
强行停止sudo systemctl kill sing-box
重新启动sudo systemctl restart sing-box
查看日志sudo journalctl -u sing-box --output cat -e
实时日志sudo journalctl -u sing-box --output cat -f

客户端#

安卓

{
    "log": {
        "level": "error",
        "timestamp": true
    },
    "dns": {
        "servers": [
            {
                "tag": "dns_proxy",
                "address": "https://1.1.1.1/dns-query",
                "address_resolver": "dns_resolver",
                "address_strategy": "ipv4_only",
                "strategy": "ipv4_only",
                "detour": "vless-out",
                "client_subnet": "59.70.60.20"
            },
            {
                "tag": "dns_resolver",
                "address": "local",
                "detour": "direct",
                "strategy": "ipv4_only"
            }
        ],
        "rules": [
            {
                "outbound": "any",
                "server": "dns_resolver"
            },
            {
                "rule_set": "geosite-cn",
                "server": "dns_resolver"
            }
        ],
        "final": "dns_proxy",
        "strategy": "ipv4_only"
    },
    "inbounds": [
        {
            "type": "tun",
            "tag": "tun-in",
            "mtu": 1400,
            "auto_route": true,
            "strict_route": true,
            "stack": "gvisor",
            "sniff": true,
            "inet4_address": "172.16.0.1/30",
            "inet6_address": "fd00::1/126"
        }
    ],
    "outbounds": [
        {
            "type": "direct",
            "tag": "direct"
        },
        {
            "type": "block",
            "tag": "block"
        },
        {
            "type": "dns",
            "tag": "dns-out"
        },
        {
            "type": "shadowsocks",
            "tag": "ss-out",
            "tcp_fast_open": true,
            "tcp_multi_path": true,
            "server": "2001:250:4807:2534:20e",
            "server_port": 2222,
            "method": "2022-blake3-aes-128-gcm",
            "password": "68yXEwgvSjAUqLcrTA=="
        },
        {
            "type": "vless",
            "tag": "vless-out",
            "routing_mark": 100,
            "server": "156.26.11.82",
            "server_port": 233,
            "uuid": "5eb545d7-c25b-4e2c-b48a-66ef0c64ed07",
            "flow": "xtls-rprx-vision",
            "packet_encoding": "xudp",
            "tls": {
                "enabled": true,
                "server_name": "www.henau.edu.cn",
                "insecure": true,
                "utls": {
                    "enabled": true,
                    "fingerprint": "chrome"
                },
                "reality": {
                    "enabled": true,
                    "public_key": "sqNkNGBhIBploUcf9-aCzh51ETaKrYOS6b0Wz0gQE",
                    "short_id": "4cae74ba0ee703cc"
                }
            },
            "tcp_fast_open": true,
            "tcp_multi_path": true
        }
    ],
    "route": {
        "rules": [
            {
                "protocol": "dns",
                "outbound": "dns-out"
            },
            {
                "protocol": [
                    "bittorrent",
                    "quic"
                ],
                "outbound": "block"
            },
            {
                "rule_set": [
                    "geoip-cn",
                    "geosite-cn"
                ],
                "outbound": "direct"
            },
            {
                "ip_is_private": true,
                "outbound": "vless-out"
            }
        ],
        "rule_set": [
            {
                "type": "remote",
                "tag": "geoip-cn",
                "format": "binary",
                "url": "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/sing/geo-lite/geoip/cn.srs",
                "download_detour": "vless-out"
            },
            {
                "type": "remote",
                "tag": "geosite-cn",
                "format": "binary",
                "url": "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/sing/geo-lite/geosite/cn.srs",
                "download_detour": "vless-out"
            }
        ],
        "final": "vless-out",
        "auto_detect_interface": true
    },
    "experimental": {
        "cache_file": {
            "enabled": true,
            "path": "cache.db"
        }
    }
}

windows

{
    "log": {
        "disabled": true,
        "level": "info",
        "timestamp": true
    },
    "dns": {
        "servers": [
            {
                "tag": "default-dns",
                "address": "223.5.5.5",
                "detour": "direct-out"
            },
            {
                "tag": "system-dns",
                "address": "local",
                "detour": "direct-out"
            },
            {
                "tag": "block-dns",
                "address": "rcode://name_error"
            },
            {
                "tag": "cfg-google-dns",
                "address": "https://dns.google/dns-query",
                "address_resolver": "default-dns",
                "address_strategy": "ipv4_only",
                "strategy": "ipv4_only",
                "detour": "vless-out",
                "client_subnet": "59.70.63.26"
            }
        ],
        "rules": [
            {
                "ip_version": 4,
                "outbound": "any",
                "server": "default-dns"
            },
            {
                "rule_set": [
                    "cfg-cnsite-rule"
                ],
                "server": "default-dns"
            }
        ],
        "strategy": "ipv4_only",
        "disable_cache": false,
        "disable_expire": false,
        "independent_cache": false,
        "final": "cfg-google-dns"
    },
    "inbounds": [
        {
            "type": "tun",
            "tag": "tun-in",
            "inet4_address": "172.19.0.1/30",
            "mtu": 9000,
            "gso": true,
            "auto_route": true,
            "stack": "system",
            "sniff": true,
            "sniff_override_destination": false
        }
    ],
    "outbounds": [
        {
            "type": "direct",
            "tag": "direct-out",
            "routing_mark": 100
        },
        {
            "type": "block",
            "tag": "block-out"
        },
        {
            "type": "dns",
            "tag": "dns-out"
        },
        {
            "type": "shadowsocks",
            "tag": "ss-out",
            "routing_mark": 100,
            "server": "16.26.171.82",
            "server_port": 23233,
            "password": "Ji6vV7BCVQZ7ExzoA==",
            "method": "2022-blake3-aes-128-gcm",
            "multiplex": {
                "enabled": false,
                "protocol": "h2mux",
                "max_connections": 1,
                "min_streams": 4,
                "padding": false,
                "brutal": {
                    "enabled": false,
                    "up_mbps": 100,
                    "down_mbps": 100
                }
            },
            "tcp_fast_open": true,
            "tcp_multi_path": true
        },
		{
            "type": "vless",
            "tag": "vless-out",
            "routing_mark": 100,
            "server": "156.26.11.82",
            "server_port": 233,
            "uuid": "5eb545d7-c25b-4e2c-b48a-66ef0c64ed07",
            "flow": "xtls-rprx-vision",
            "packet_encoding": "xudp",
            "tls": {
                "enabled": true,
                "server_name": "www.henau.edu.cn",
                "insecure": true,
                "utls": {
                    "enabled": true,
                    "fingerprint": "chrome"
                },
                "reality": {
                    "enabled": true,
                    "public_key": "sqNkNGBhIBploUcf9-aCzh51ETaKrYOS6b0Wz0gQE",
                    "short_id": "4cae74ba0ee703cc"
                }
            },
            "tcp_fast_open": true,
            "tcp_multi_path": true
        }
    ],
    "route": {
        "rules": [
            {
                "protocol": "dns",
                "outbound": "dns-out"
            },
            {
                "protocol": [
                    "bittorrent",
                    "quic"
                ],
                "outbound": "block-out"
            },
            {
                "rule_set": [
                    "cfg-cnip-rule",
                    "cfg-cnsite-rule"
                ],
                "outbound": "direct-out"
            }
        ],
        "rule_set": [
            {
                "type": "remote",
                "tag": "cfg-cnip-rule",
                "format": "binary",
                "url": "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/sing/geo-lite/geoip/cn.srs",
                "download_detour": "vless-out"
            },
            {
                "type": "remote",
                "tag": "cfg-cnsite-rule",
                "format": "binary",
                "url": "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/sing/geo-lite/geosite/cn.srs",
                "download_detour": "vless-out"
            }
        ],
        "auto_detect_interface": true,
        "final": "vless-out"
    },
    "experimental": {
        "cache_file": {
            "enabled": true
        }
    }
}

所有评论(20)

  1. situs slot gacor说道:

    Hey There. I discovered your weblog using msn. That is a really well written article.
    I’ll be sure to bookmark it and return to learn extra of your helpful info.
    Thanks for the post. I’ll certainly comeback.

  2. These are genuinely great ideas in about blogging. You have touched some fastidious points here.
    Any way keep up wrinting.

  3. Hi! Do you know if they make any plugins to safeguard
    against hackers? I’m kinda paranoid about losing
    everything I’ve worked hard on. Any suggestions?

  4. situs slot gacor说道:

    Greate pieces. Keep writing such kind of info on your site.

    Im really impressed by your site.
    Hi there, You’ve performed a fantastic job. I will certainly digg it and for my part
    suggest to my friends. I’m sure they will be benefited from this site.

  5. demo pg说道:

    I know this site gives quality based content and other data, is there any
    other website which presents such stuff in quality?

  6. slot gacor说道:

    Wow, marvelous weblog structure! How long have you been running a blog for?
    you made running a blog glance easy. The full glance of your web
    site is fantastic, as smartly as the content!

  7. lesbian说道:

    Great site. Lots of useful info here. I am sending it to
    several buddies ans additionally sharing in delicious.
    And of course, thank you in your sweat!

  8. demo pg说道:

    Hello there, just became aware of your blog through Google, and found that it’s
    truly informative. I’m gonna watch out for brussels.

    I will be grateful if you continue this in future. A lot of people will be benefited
    from your writing. Cheers!

  9. bokep说道:

    Hi! I just would like to offer you a big thumbs up for the excellent info you have got right here on this post.
    I will be coming back to your site for more soon.

  10. Way cool! Some very valid points! I appreciate you writing this post and
    the rest of the site is extremely good.

  11. Hi there, just wanted to say, I liked this blog post. It was funny.
    Keep on posting!

  12. Thank you for any other magnificent post. The place else may just anybody get that kind of info in such an ideal method of
    writing? I’ve a presentation subsequent week, and I am on the look for such
    information.

  13. Wacaco Wacaco说道:

    I like it when folks come together and share opinions.

    Great website, continue the good work!

  14. Hola! I’ve been reading your blog for a while now and finally got the bravery to go ahead and give you a
    shout out from Kingwood Texas! Just wanted to say keep up the fantastic work!

  15. Have you ever considered about adding a little bit more
    than just your articles? I mean, what you say is fundamental and everything.
    Nevertheless think of if you added some great images or videos to
    give your posts more, “pop”! Your content is excellent but with pics and clips, this site could certainly be one of the greatest in its field.

    Superb blog!

  16. plaster key说道:

    I am really loving the theme/design of your website.
    Do you ever run into any web browser compatibility problems?
    A number of my blog readers have complained about my site
    not working correctly in Explorer but looks great in Firefox.
    Do you have any tips to help fix this problem?

  17. xnxx说道:

    Right here is the right webpage for everyone who hopes to find
    out about this topic. You realize so much its almost hard to argue
    with you (not that I actually would want to…HaHa). You definitely put
    a fresh spin on a topic that has been discussed for ages.
    Wonderful stuff, just wonderful!

  18. What’s up to all, the contents existing at this web page are really
    remarkable for people experience, well, keep up the
    good work fellows.

  19. An outstanding share! I’ve just forwarded this onto a coworker who had been doing
    a little research on this. And he actually ordered me breakfast because I found
    it for him… lol. So allow me to reword this…. Thanks for the meal!!
    But yeah, thanx for spending some time to discuss this topic here on your
    blog.

  20. I pay a quick visit daily some blogs and blogs to read content, but
    this web site offers feature based writing.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注