{"id":143,"date":"2020-11-07T09:19:47","date_gmt":"2020-11-07T01:19:47","guid":{"rendered":"http:\/\/blog.goodshub.com.cn\/?p=143"},"modified":"2023-03-12T22:23:05","modified_gmt":"2023-03-12T14:23:05","slug":"linux%e7%b3%bb%e7%bb%9f%e4%b8%8b%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91","status":"publish","type":"post","link":"https:\/\/blog.qutongbuluo.cn\/index.php\/2020\/11\/07\/linux%e7%b3%bb%e7%bb%9f%e4%b8%8b%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91\/","title":{"rendered":"linux\u7cfb\u7edf\u4e0b\u79d1\u5b66\u4e0a\u7f51"},"content":{"rendered":"\n<p>1\u3001\u540c\u6b65\u7cfb\u7edf\u65f6\u95f4<\/p>\n\n\n\n<p>\u5b89\u88c5ntpdate\u5de5\u5177yum -y install ntp ntpdate<\/p>\n\n\n\n<p>\u8bbe\u7f6e\u7cfb\u7edf\u65f6\u95f4\u4e0e\u7f51\u7edc\u65f6\u95f4\u540c\u6b65ntpdate cn.pool.ntp.org<\/p>\n\n\n\n<p>2\u3001\u4e0b\u8f7d\u811a\u672c<\/p>\n\n\n\n<p>wget https:\/\/raw.githubusercontent.com\/wulabing\/V2Ray_ws-tls_bash_onekey\/master\/install.sh<\/p>\n\n\n\n<p>3\u3001\u6309\u7167\u9700\u6c42\u5b89\u88c5v2ray\u548cbbr<\/p>\n\n\n\n<p>4\u3001 \u7f16\u8f91 \/etc\/v2ray\/config.json \u6587\u4ef6\u6765\u914d\u7f6e\u4f60\u9700\u8981\u7684\u4ee3\u7406\u65b9\u5f0f <\/p>\n\n\n\n<p>\/usr\/local\/bin\/v2ray\uff1aV2Ray \u7a0b\u5e8f\uff1b<br> \/usr\/local\/bin\/v2ctl\uff1aV2Ray \u5de5\u5177\uff1b<br> \/usr\/local\/etc\/v2ray\/config.json\uff1a\u914d\u7f6e\u6587\u4ef6\uff1b<br> \/usr\/local\/share\/v2ray\/geoip.dat\uff1aIP \u6570\u636e\u6587\u4ef6<br> \/usr\/local\/share\/v2ray\/geosite.dat\uff1a\u57df\u540d\u6570\u636e\u6587\u4ef6<\/p>\n\n\n\n<p>5\u3001\u76f8\u5173\u547d\u4ee4<\/p>\n\n\n\n<p>## \u542f\u52a8systemctl start v2ray<\/p>\n\n\n\n<p>## \u505c\u6b62systemctl stop v2ray<\/p>\n\n\n\n<p>## \u91cd\u542fsystemctl restart v2ray<\/p>\n\n\n\n<p>## \u5f00\u673a\u81ea\u542fsystemctl enable v2ray<\/p>\n\n\n\n<p>6\u3001\u4fee\u6539\u5168\u5c40\u53d8\u91cf\uff0c\u6240\u6709\u7528\u6237\u751f\u6548<\/p>\n\n\n\n<p>\u7f16\u8f91\u6587\u4ef6\/etc\/profile\uff0c\u589e\u52a0\u5982\u4e0b\u4e24\u884c<\/p>\n\n\n\n<p>export http_proxy=http:\/\/proxy.com:8080\/<br> export https_proxy=http:\/\/proxy.com:8080\/<\/p>\n\n\n\n<p>7\u3001 \u6dfb\u52a0\u591a\u7528\u6237<\/p>\n\n\n\n<p>\u8fd0\u7528\u6307\u4ee4\uff1acat \/proc\/sys\/kernel\/random\/uuid \u518d\u521b\u5efa\u4e00\u4e2a\u7528\u6237 id \uff0c\u5e76\u8bb0\u4f4f\u8fd9\u4e2aid\u53f7\uff1b<\/p>\n\n\n\n<p>\u7528\u6307\u4ee4\u7f16\u8f91config.json\u6587\u4ef6\uff0c\u6307\u4ee4\uff1a vi \/etc\/v2ray\/config.json \uff0c\u8f93\u5165 i \u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\uff0c\u590d\u5236inbounds[ ]\u4e2d\u7684\u5185\u5bb9\uff0c\u518d\u7c98\u8d34\u4e00\u4e2a\u51fa\u6765\uff0c\u5982\u4e0b\u683c\u5f0f\uff0c\u8bb0\u4f4f\u683c\u5f0f\uff0c\u5f88\u91cd\u8981\uff0c\u76f4\u63a5\u770b\u4e0b\u9762\u7684\u4ee3\u7801\u3002\u63a5\u4e0b\u6765\uff0c\u6309esc\u63a8\u51fa\uff0c\u8f93\u5165\uff1a\u53f7\uff0c\u9000\u51fa\u7f16\u8f91\u72b6\u6001\uff0c\u7136\u540e\u8f93\u5165wq\uff0c\u4fdd\u5b58\u5e76\u9000\u51fa\u3002 \u7136\u540e\u91cd\u542fV2Ray\u670d\u52a1 <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"716\" height=\"588\" src=\"https:\/\/blog.goodshub.com.cn\/wp-content\/uploads\/2020\/12\/image_20200103222616_823.png\" alt=\"\" class=\"wp-image-174\" srcset=\"https:\/\/blog.qutongbuluo.cn\/wp-content\/uploads\/2020\/12\/image_20200103222616_823.png 716w, https:\/\/blog.qutongbuluo.cn\/wp-content\/uploads\/2020\/12\/image_20200103222616_823-300x246.png 300w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><\/figure>\n\n\n\n<p>8\u3001\u7528\u6237\u6d41\u91cf\u7edf\u8ba1\u529f\u80fd<\/p>\n\n\n\n<p>\u53c2\u89c1\uff1ahttps:\/\/guide.v2fly.org\/advanced\/traffic.html#%E9%85%8D%E7%BD%AE%E7%BB%9F%E8%AE%A1%E5%8A%9F%E8%83%BD<\/p>\n\n\n\n<p>\u914d\u7f6e\u5b9e\u4f8b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"stats\": {},\n    \"api\": {\n        \"tag\": \"api\",\n        \"services\": &#91;\n            \"StatsService\"\n        ]\n    },\n    \"policy\": {\n        \"levels\": {\n            \"0\": {\n                \"statsUserUplink\": true,\n                \"statsUserDownlink\": true\n            }\n        },\n        \"system\": {\n            \"statsInboundUplink\": true,\n            \"statsInboundDownlink\": true,\n            \"statsOutboundUplink\": true,\n            \"statsOutboundDownlink\": true\n        }\n    },\n    \"inbounds\": &#91;\n        {\n            \"tag\": \"tcp\",\n            \"port\": 3307,\n            \"protocol\": \"vmess\",\n            \"settings\": {\n                \"clients\": &#91;\n                    {\n                        \"email\": \"auser\",\n                        \"id\": \"e731f153-4f31-49d3-9e8f-ff8f396135ef\",\n                        \"level\": 0,\n                        \"alterId\": 64\n                    },\n                    {\n                        \"email\": \"buser\",\n                        \"id\": \"e731f153-4f31-49d3-9e8f-ff8f396135ee\",\n                        \"level\": 0,\n                        \"alterId\": 64\n                    }\n                ]\n            }\n        },\n        {\n            \"listen\": \"127.0.0.1\",\n            \"port\": 10085,\n            \"protocol\": \"dokodemo-door\",\n            \"settings\": {\n                \"address\": \"127.0.0.1\"\n            },\n            \"tag\": \"api\"\n        }\n    ],\n    \"outbounds\": &#91;\n        {\n            \"tag\": \"direct\",\n            \"protocol\": \"freedom\",\n            \"settings\": {}\n        }\n    ],\n    \"routing\": {\n        \"settings\": {\n            \"rules\": &#91;\n                {\n                    \"inboundTag\": &#91;\n                        \"api\"\n                    ],\n                    \"outboundTag\": \"api\",\n                    \"type\": \"field\"\n                }\n            ]\n        },\n        \"strategy\": \"rules\"\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u67e5\u770b\u6d41\u91cf\u4fe1\u606f<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n_APISERVER=127.0.0.1:10085\n_V2CTL=\/usr\/local\/bin\/v2ctl\n\napidata () {\n    local ARGS=\n    if &#91;&#91; $1 == \"reset\" ]]; then\n      ARGS=\"reset: true\"\n    fi\n    $_V2CTL api --server=$_APISERVER StatsService.QueryStats \"${ARGS}\" \\\n    | awk '{\n        if (match($1, \/name:\/)) {\n            f=1; gsub(\/^\"|link\"$\/, \"\", $2);\n            split($2, p,  \"&gt;&gt;&gt;\");\n            printf \"%s:%s-&gt;%s\\t\", p&#91;1],p&#91;2],p&#91;4];\n        }\n        else if (match($1, \/value:\/) &amp;&amp; f){ f = 0; printf \"%.0f\\n\", $2; }\n        else if (match($0, \/^&gt;$\/) &amp;&amp; f) { f = 0; print 0; }\n    }'\n}\n\nprint_sum() {\n    local DATA=\"$1\"\n    local PREFIX=\"$2\"\n    local SORTED=$(echo \"$DATA\" | grep \"^${PREFIX}\" | sort -r)\n    local SUM=$(echo \"$SORTED\" | awk '\n        \/-&gt;up\/{us+=$2}\n        \/-&gt;down\/{ds+=$2}\n        END{\n            printf \"SUM-&gt;up:\\t%.0f\\nSUM-&gt;down:\\t%.0f\\nSUM-&gt;TOTAL:\\t%.0f\\n\", us, ds, us+ds;\n        }')\n    echo -e \"${SORTED}\\n${SUM}\" \\\n    | numfmt --field=2 --suffix=B --to=iec \\\n    | column -t\n}\n\nDATA=$(apidata $1)\necho \"------------Inbound----------\"\nprint_sum \"$DATA\" \"inbound\"\necho \"-----------------------------\"\necho \"------------Outbound----------\"\nprint_sum \"$DATA\" \"outbound\"\necho \"-----------------------------\"\necho\necho \"-------------User------------\"\nprint_sum \"$DATA\" \"user\"\necho \"-----------------------------\"<\/code><\/pre>\n\n\n\n<p> \u8fd0\u884c\u6548\u679c\uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ .\/traffic.sh\n------------Inbound----------\ninbound:ws-&gt;up      0B\ninbound:ws-&gt;down    0B\ninbound:tcp-&gt;up     47B\ninbound:tcp-&gt;down   0B\ninbound:kcp-&gt;up     259MB\ninbound:kcp-&gt;down   2.4GB\ninbound:api-&gt;up     2.0KB\ninbound:api-&gt;down   6.6KB\nSUM-&gt;up:            259MB\nSUM-&gt;down:          2.4GB\nSUM-&gt;TOTAL:         2.6GB\n-----------------------------\n\n-------------User------------\nuser:me@kcp-&gt;up    240MB\nuser:me@kcp-&gt;down  2.3GB\nSUM-&gt;up:           240MB\nSUM-&gt;down:         2.3GB\nSUM-&gt;TOTAL:        2.5GB\n-----------------------------<\/code><\/pre>\n\n\n\n<p> \u811a\u672c\u4f7f\u7528&nbsp;<code>reset<\/code>&nbsp;\u53c2\u6570\u8ba9\u8c03\u7528\u7684\u8ba1\u6570\u5355\u5143\u7f6e\u96f6 <\/p>\n\n\n\n<p>\u6700\u8fd1\u5728Centos7\u5b89\u88c5\u4e00\u4e9b\u8f6f\u4ef6.\/configure\u65f6\u51fa\u73b0configure: error: C preprocessor &#8220;\/lib\/cpp&#8221; fails sanity check<\/p>\n\n\n\n<p>\u53ef\u80fd\u539f\u56e0\u6ca1\u6709\u5b89\u88c5kernel-headersyum install kernel-headers<\/p>\n\n\n\n<p>\u5df2\u7ecf\u5347\u7ea7\u5230\u6700\u65b0\u7248\u672c\u5e76\u51fa\u73b0\u95ee\u9898\u7684\uff0c\u9000\u56de\u5230 v4.34.0\u4e4b\u524d\u7684\u7248\u672c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bash &lt;(curl -L https:\/\/raw.githubusercontent.com\/v2fly\/fhs-install-v2ray\/master\/install-release.sh) --version v4.34.0<\/pre>\n\n\n\n<p>\u516b\u5408\u4e00\u5171\u5b58\u811a\u672c+\u4f2a\u88c5\u7ad9\u70b9<\/p>\n\n\n\n<p>wget -P \/root -N &#8211;no-check-certificate &#8220;https:\/\/raw.githubusercontent.com\/mack-a\/v2ray-agent\/master\/install.sh&#8221; &amp;&amp; chmod 700 \/root\/install.sh &amp;&amp; \/root\/install.sh<\/p>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6bd5\u540e\uff0cshell\u8f93\u5165\u3010<strong>vasma<\/strong>\u3011\u5373\u53ef\u6253\u5f00\u811a\u672c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u540c\u6b65\u7cfb\u7edf\u65f6\u95f4 \u5b89\u88c5ntpdate\u5de5\u5177yum -y install ntp ntpdate \u8bbe\u7f6e\u7cfb\u7edf\u65f6\u95f4\u4e0e\u7f51 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.qutongbuluo.cn\/index.php\/2020\/11\/07\/linux%e7%b3%bb%e7%bb%9f%e4%b8%8b%e7%a7%91%e5%ad%a6%e4%b8%8a%e7%bd%91\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201clinux\u7cfb\u7edf\u4e0b\u79d1\u5b66\u4e0a\u7f51\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-143","post","type-post","status-publish","format-standard","hentry","category-qy"],"_links":{"self":[{"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/posts\/143"}],"collection":[{"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/comments?post=143"}],"version-history":[{"count":13,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/posts\/143\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/posts\/143\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/media?parent=143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/categories?post=143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qutongbuluo.cn\/index.php\/wp-json\/wp\/v2\/tags?post=143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}