本站支持「有偿」远程协助!

多 IP 服务器 Xray 玩法

多公网 IP 服务器搭建 VMESS 节点.

单 IP

wget -O /usr/local/bin/xray https://cdn.jsdelivr.net/gh/none-blue/xray-amd64@main/xray
chmod +x /usr/local/bin/xray

cat <<EOF > /etc/systemd/system/xray.service
[Unit]
Description=The Xray Proxy Serve
After=network-online.target

[Service]
ExecStart=/usr/local/bin/xray -c /etc/xray/serve.toml
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
RestartSec=15s

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable xray

mkdir -p /etc/xray
cat <<EOF > /etc/xray/serve.toml
[log]
loglevel = "none"

[[inbounds]]
protocol = "vless"
port = "8443"

[inbounds.settings]
decryption = "none"

[[inbounds.settings.clients]]
id = "none.blue"

[inbounds.streamSettings]
network = "tcp"

[[outbounds]]
protocol = "freedom"
EOF

systemctl start xray
#systemctl status xray

多 IP


xray_port="1080"
xray_uuid="b9ca9e73-ee13-5229-ad96-4045ea0342a7"

ips=(
    1.2.3.4
    5.6.7.8
)

wget -O /usr/local/bin/xray https://cdn.jsdelivr.net/gh/none-blue/xray-amd64@main/xray
chmod +x /usr/local/bin/xray

cat <<EOF > /etc/systemd/system/xray.service
[Unit]
Description=The Xray Proxy Serve
After=network-online.target

[Service]
ExecStart=/usr/local/bin/xray -c /etc/xray/serve.toml
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=always
RestartSec=15s

[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable xray


# Xray Configuration
mkdir -p /etc/xray
echo -n "" > /etc/xray/serve.toml
for ((i = 0; i < ${#ips[@]}; i++)); do
cat <<EOF >> /etc/xray/serve.toml
[[inbounds]]
listen = "${ips[i]}"
port = $xray_port
protocol = "vmess"
tag = "$((i+1))"
[inbounds.settings]
decryption = "none"
[[inbounds.settings.clients]]
id = "$xray_uuid"
[inbounds.streamSettings]
network = "tcp"

[[routing.rules]]
type = "field"
inboundTag = "$((i+1))"
outboundTag = "$((i+1))"

[[outbounds]]
sendThrough = "${ips[i]}"
protocol = "freedom"
tag = "$((i+1))"
EOF
done

systemctl stop xray
systemctl start xray
#systemctl status xray
for ((i = 0; i < ${#ips[@]}; i++)); do
echo vmess://`echo "{
  \"v\": \"2\",
  \"ps\": \""$i"\",
  \"add\": \""${ips[i]}"\",
  \"port\": \""$xray_port"\",
  \"id\": \""$xray_uuid"\",
  \"aid\": \"0\",
  \"scy\": \"auto\",
  \"net\": \"tcp\",
  \"type\": \"none\",
  \"host\": \"\",
  \"path\": \"\",
  \"tls\": \"\",
  \"sni\": \"\"
}" | base64`
done
Loading ...
无广告!