各个linux发行版的网络略有差异,这里以火山引擎的ubuntu22为例,其他系统请根据相应的系统修改
首先在火山引擎的平台申请IP
在网卡添加内网IP以后绑定公网IP
2025-07-01T06:01:27.png

tee /etc/netplan/01-eth0-config.yaml <<EOF
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 172.31.0.2/20
        - 172.31.0.3/20
      routes:
        - to: default
          via: 172.31.0.1
      nameservers:
        addresses: [100.96.0.2, 100.96.0.3] #内网DNS,不配置的话内网服务会失效
EOF
mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak
netplan apply
{
  "inbounds": [
    {
      "tag": "in_0",
      "type": "vmess",
      "listen": "::",
      "listen_port": 56786,
      "users": [
        {
          "uuid": "9f587f14-c9eb-4dbb-813e-fcf062f4a3f3"
        }
      ],
      "transport": {
        "type": "ws",
        "early_data_header_name": "Sec-WebSocket-Protocol"
      }
    },
    {
      "tag": "in_1",
      "type": "vmess",
      "listen": "::",
      "listen_port": 56787,
      "users": [
        {
          "uuid": "d2b8b7ba-395d-4387-97ef-307cc02513da"
        }
      ],
      "transport": {
        "type": "ws",
        "early_data_header_name": "Sec-WebSocket-Protocol"
      }
    }
  ],
  "outbounds": [
    {
      "tag": "out_0",
      "type": "direct",
      "inet4_bind_address": "172.31.0.2"
    },
    {
      "tag": "out_1",
      "type": "direct",
      "inet4_bind_address": "172.31.0.3"
    }
  ],
  "route": {
    "rules": [
      {
        "inbound": ["in_0"],
        "outbound": "out_0"
      },
      {
        "inbound": ["in_1"],
        "outbound": "out_1"
      }
    ]
  }
}