Skip to content

Instantly share code, notes, and snippets.

@Hansimov
Last active June 26, 2024 07:59
Show Gist options
  • Save Hansimov/05ae4e81bc8349131e939ed4753304db to your computer and use it in GitHub Desktop.
Save Hansimov/05ae4e81bc8349131e939ed4753304db to your computer and use it in GitHub Desktop.
Setup v2ray server (linux) and client (windows)

One-line Setup

sudo su
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

Thanks @NINOMAE1995 very much!

Custom Setup

Server (Linux)

Download and install v2ray:

curl -Ls https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh | sudo bash

Enable and start v2ray:

systemctl enable v2ray; systemctl start v2ray

Check v2ray running status:

systemctl status v2ray

Generate random UUID:

cat /proc/sys/kernel/random/uuid

Modify config.json:

  • Usually in /usr/local/etc/v2ray/config.json
  • Example: See z-linux-server.config.json below
    • Only need to change inbounds > clients > [id], which is generated above

Restart v2ray service:

systemctl restart v2ray

Client (Windows)

Download and extract:

Modify config.json:

  • Usually located in .\v2ray-windows-64\config.json
  • Example: See z-windows-client.config.json below
    • Only need to change outbounds > vnext > [address] | users > [id]
    • The address is the IP of server, and id is same to the uuid in server

References:

{
"inbounds": [
{
"port": 9999,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "********-****-****-****-************",
"alterId": 0
}
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"port": 11110,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"port": 11111,
"listen": "127.0.0.1",
"protocol": "http",
"settings": {
"auth": "noauth",
"udp": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "***.**.***.***", // <CloudFlare IP>
"port": 80,
"users": [
{
"id": "********-****-****-****-************",
"encryption": "none",
"level": 0
}
]
}
]
},
"streamSettings": {
"network": "tcp"
}
},
{
"protocol": "freedom",
"tag": "direct",
"settings": {}
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "direct"
}
]
}
}
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"port": 11110,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},
{
"port": 11111,
"listen": "127.0.0.1",
"protocol": "http",
"settings": {
"auth": "noauth",
"udp": false
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "***.***.***.***",
"port": 9999,
"users": [
{
"id": "********-****-****-****-************",
"alterId": 0
}
]
}
]
}
},
{
"protocol": "freedom",
"tag": "direct",
"settings": {}
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "direct"
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment