一键让vps的v6优先

一键让vps的v6优先,以xray,端口34928为例:


cat <<EOF > /usr/local/etc/xray/config.json

{

"log": {

"loglevel": "warning"

},

"inbounds": [

{

"port": 34928,

"protocol": "vless",

"settings": {

"clients": [

{

"id": "$(grep '"id":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')",

"flow": "xtls-rprx-vision"

}

],

"decryption": "none"

},

"streamSettings": {

"network": "tcp",

"security": "reality",

"realitySettings": {

"show": false,

"dest": "www.microsoft.com:443",

"xver": 0,

"serverNames": ["www.microsoft.com"],

"privateKey": "$(grep '"privateKey":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')",

"shortIds": ["$(grep '"shortIds":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')"]

}

},

"tag": "inbound-34928"

}

],

"outbounds": [

{

"protocol": "freedom",

"settings": {

"domainStrategy": "UseIPv6"

},

"tag": "direct"

},

{

"protocol": "black

"tag": "blocked"
}
],
"routing": {
"domainStrategy": "UseIPv6",
"rules": [
{
"type": "field",
"outboundTag": "direct",
"network": "udp,tcp"
}
]
}
}
EOF

之后语法检查:
/usr/local/bin/xray -test -config /usr/local/etc/xray/config.json

如果不报错就重启:

systemctl restart xray

如果无效,就来个暴力的:

cat <<EOF > /usr/local/etc/xray/config.json
{
"log": { "loglevel": "warning" },
"inbounds": [
{
"port": 34928,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "$(grep '"id":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "www.microsoft.com:443",
"xver": 0,
"serverNames": ["www.microsoft.com"],
"privateKey": "$(grep '"privateKey":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')",
"shortIds": ["$(grep '"shortIds":' /usr/local/etc/xray/config.json.bak | head -n 1 | awk -F '"' '{print $4}')"]
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {
"domainStrategy": "UseIPv6"
},
"tag": "direct"
}
],
"routing": {
"domainStrategy": "UseIPv6",
"rules": [
{
"type": "field",
"network": "tcp,udp",
"outboundTag": "direct"
}
]
}
}
EOF

systemctl restart xray

Next Post Previous Post
No Comment
Add Comment
comment url