{"id":33,"date":"2023-04-24T23:25:54","date_gmt":"2023-04-24T15:25:54","guid":{"rendered":"https:\/\/jjm6.com\/?p=33"},"modified":"2023-04-24T23:25:54","modified_gmt":"2023-04-24T15:25:54","slug":"sing-box%e6%90%ad%e5%bb%bavless-xtls-vision-reality","status":"publish","type":"post","link":"https:\/\/jjm6.com\/index.php\/2023\/04\/24\/sing-box%e6%90%ad%e5%bb%bavless-xtls-vision-reality\/","title":{"rendered":"sing-box\u642d\u5efavless-xtls-vision-reality"},"content":{"rendered":"\n<p><strong>1\u3001\u5f00\u542fBBR\u52a0\u901f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">echo \"net.core.default_qdisc=fq\" &gt;&gt; \/etc\/sysctl.conf\necho \"net.ipv4.tcp_congestion_control=bbr\" &gt;&gt; \/etc\/sysctl.conf\nsysctl -p<\/pre>\n\n\n\n<p><strong>2\u3001\u66f4\u65b0\u8f6f\u4ef6\u6e90\u53ca\u5b89\u88c5\u4f9d\u8d56<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt update &amp;&amp; apt -y install wget git libc6-dev build-essential zlib1g-dev libssl-dev libevent-dev mingw-w64<\/pre>\n\n\n\n<p><strong>3\u3001\u5b89\u88c5go<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget -c https:\/\/go.dev\/dl\/go1.20.3.linux-amd64.tar.gz -O - | tar -xz -C \/usr\/local<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">echo 'export PATH=$PATH:\/usr\/local\/go\/bin' &gt; \/etc\/profile<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">source \/etc\/profile<\/pre>\n\n\n\n<p><strong>4\u3001\u7f16\u8bd1\u5b89\u88c5sing-box<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">go install -v -tags \\\nwith_quic,\\\nwith_grpc,\\\nwith_dhcp,\\\nwith_wireguard,\\\nwith_shadowsocksr,\\\nwith_ech,\\\nwith_utls,\\\nwith_reality_server,\\\nwith_acme,\\\nwith_clash_api,\\\nwith_v2ray_api,\\\nwith_gvisor,\\\nwith_lwip \\\ngithub.com\/sagernet\/sing-box\/cmd\/sing-box@latest<\/pre>\n\n\n\n<p><strong>5\u3001\u590d\u5236\u7f16\u8bd1\u597d\u7684sing-box\u5230\/usr\/local\/bin\/\u76ee\u5f55<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cp ~\/go\/bin\/sing-box \/usr\/local\/bin\/\n\u53ef\u80fd\u4e0d\u6210\u529f\u3002\u7528\u4e0b\u9762\u547d\u4ee4\uff1a\nwget https:\/\/github.com\/SagerNet\/sing-box\/releases\/download\/v1.2.4\/sing-box_1.2.4_linux_arm64.deb\r\ndpkg -i sing-box_1.2.4_linux_amd64.deb\r\ncp \/usr\/bin\/sing-box \/usr\/local\/bin\/<\/pre>\n\n\n\n<p><strong>6\u3001\u4e3asing-box\u914d\u7f6e\u5f00\u673a\u81ea\u542f\u670d\u52a1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cat > \/etc\/systemd\/system\/sing-box.service &lt;&lt;EOF\n\n\r\n[Unit]\r\nDescription=sing-box service\r\nDocumentation=https:\/\/sing-box.sagernet.org\r\nAfter=network.target nss-lookup.target\r\n[Service]\r\nCapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE\r\nAmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE\r\nExecStart=\/usr\/local\/bin\/sing-box run -c \/usr\/local\/etc\/sing-box\/config.json\r\nRestart=on-failure\r\nRestartSec=1800s\r\nLimitNOFILE=infinity\r\n[Install]\r\nWantedBy=multi-user.target\r\nEOF<\/pre>\n\n\n\n<p><strong>7\u3001\u521b\u5efasing-box\u6587\u4ef6\u5939<\/strong>\uff0c<strong>\u521b\u5efasing-box\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mkdir \/usr\/local\/etc\/sing-box &amp;&amp; cd $_\n\ntouch config.json\r\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">{\n  \"log\": {\n    \"level\": \"info\",\n    \"timestamp\": true\n  },\n  \"dns\": {\n    \"servers\": [\n      { \n        \"tag\": \"local\",\n        \"address\": \"https:\/\/1.1.1.1\/dns-query\",\n        \"detour\": \"direct\"\n      },\n      {\n        \"tag\": \"block\",\n        \"address\": \"rcode:\/\/success\"\n      }\n    ],\n    \"rules\": [\n      { \n        \"geosite\": \"cn\",\n        \"server\": \"local\"\n      },\n      {\n        \"geosite\": \"category-ads-all\",\n        \"server\": \"block\",\n        \"disable_cache\": true\n      }\n    ]\n  },\n  \"inbounds\": [\n    {\n      \"type\": \"vless\",\n      \"tag\": \"vless-in\",\n      \"listen\": \"::\",\n      \"listen_port\": 10010, \/\/\u76d1\u542c\u7aef\u53e3\n      \"users\": [\n        {\n          \"uuid\": \"bf000d23-0752-40b4-affe-68f7707a9661\", \/\/\u6267\u884c sing-box generate uuid \u751f\u6210\n          \"flow\": \"xtls-rprx-vision\"\n        }\n      ],\n      \"tls\": {\n        \"enabled\": true,\n        \"server_name\": \"www.microsoft.com\", \/\/\u5ba2\u6237\u7aef\u53ef\u7528\u7684 serverName \u5217\u8868\uff0c\u6682\u4e0d\u652f\u6301 * \u901a\u914d\u7b26\n        \"reality\": {\n          \"enabled\": true,\n          \"handshake\": {\n            \"server\": \"www.microsoft.com\", \/\/\u76ee\u6807\u7f51\u7ad9\uff0c\u6807\u51c6\uff1a\u56fd\u5916\u7f51\u7ad9\uff0c\u652f\u6301 TLSv1.3 \u4e0e H2\n            \"server_port\": 443\n          },\n          \"private_key\": \"UuMBgl7MXTPx9inmQp2UC7Jcnwc6XYbwDNebonM-FCc\", \/\/ \u6267\u884c sing-box generate reality-keypair \u751f\u6210\n          \"short_id\": [ \/\/\u5ba2\u6237\u7aef\u53ef\u7528\u7684 shortId \u5217\u8868\uff0c\u53ef\u7528\u4e8e\u533a\u5206\u4e0d\u540c\u7684\u5ba2\u6237\u7aef\n            \"0123456789abcdef\" \/\/\u6267\u884c openssl rand -hex 8 \u751f\u6210\u6216\u7559\u7a7a\n          ]\n        }\n      }\n    }\n  ],\n  \"outbounds\": [\n    {\n      \"type\": \"direct\",\n      \"tag\": \"direct\"\n    },\n    {\n      \"type\": \"block\",\n      \"tag\": \"block\"\n    }\n  ],\n  \"route\": {\n    \"rules\": [\n      {\n        \"geosite\": \"cn\",\n        \"geoip\": \"cn\",\n        \"outbound\": \"direct\"\n      },\n      {\n        \"geosite\": \"category-ads-all\",\n        \"outbound\": \"block\"\n      }\n    ]\n  }\n}<\/pre>\n\n\n\n<p><strong>8\u3001\u6d4b\u8bd5\u914d\u7f6e\u6587\u4ef6\u662f\u5426\u6709\u6548<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/usr\/local\/bin\/sing-box run -c \/usr\/local\/etc\/sing-box\/config.json<\/pre>\n\n\n\n<p><strong>9\u3001\u542f\u52a8\u5e76\u8bbe\u7f6esing-box\u4e3a\u5f00\u673a\u81ea\u542f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable --now sing-box<\/pre>\n\n\n\n<p><strong>10\u3001\u67e5\u770bsing-box\u542f\u52a8\u72b6\u6001<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status sing-box<\/pre>\n\n\n\n<p><strong>#Clash\u914d\u7f6e\u793a\u4f8b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">- name: vless\n  type: vless\n  server: x.x.x.x  #ip\u5730\u5740\n  port: 10018  #\u7aef\u53e3\n  uuid: 0cd4ef7d-2d2b-4cc0-abba-57b6322e7575  #UUID\n  network: tcp\n  udp: true\n  tls: true\n  flow: xtls-rprx-vision\n  servername: www.microsoft.com  #\u670d\u52a1\u7aefserver_nam\n  client-fingerprint: chrome\n  reality-opts:\n    public-key: ajBkMYVvF14hVLPw1cKwyMzHdAj7Rg6L6MyMg6btYV8  #\u670d\u52a1\u7aef\u79c1\u94a5\u5bf9\u5e94\u7684\u516c\u94a5\n    short-id: 0123456789abcdef  #\u670d\u52a1\u7aefshort_id<\/pre>\n\n\n\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/www.ssllabs.com\/ssltest\/\" target=\"_blank\"><strong>\u76ee\u6807\u7f51\u7ad9\u662f\u5426\u7b26\u5408\u6807\u51c6\u68c0\u67e5\u7f51\u7ad9<\/strong><\/a><br><a href=\"https:\/\/www.ssllabs.com\/ssltest\/\">https:\/\/www.ssllabs.com\/ssltest\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u5f00\u542fBBR\u52a0\u901f echo &#8220;net.core.default_qdisc=fq&#8221; &gt;&gt; \/et &hellip; <a href=\"https:\/\/jjm6.com\/index.php\/2023\/04\/24\/sing-box%e6%90%ad%e5%bb%bavless-xtls-vision-reality\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201csing-box\u642d\u5efavless-xtls-vision-reality\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[6,7],"_links":{"self":[{"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/posts\/33"}],"collection":[{"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":1,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/posts\/33\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jjm6.com\/index.php\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}