Monitoring, Published Nov 27, 2026

# How to test a VPN config before you ship it to users

Test a VPN config the way your users' clients will use it: parse the link or file, resolve the server name, complete the handshake, send real traffic through the tunnel, and check DNS inside it. Automate that in CI by running sing-box or Xray for V2Ray-family links, and WireGuard or OpenVPN clients for those configs, and fail the build if a request through the tunnel doesn't come back. Then give the new config to a few canary users on your users' networks before everyone gets it.

Tahir Mehmood, 10 min read

This is for operators who generate configs for other people: from a panel, a script or a subscription. A broken config in a subscription reaches every user on their next update, and most of them won't report it. They will just switch to another server or another provider. Testing before you ship is cheaper than finding out from support tickets.

## What should I test in a VPN config before users get it?

Test the same steps a client goes through, in the same order, because each one fails in its own way:

| Step | What it catches | How |
| --- | --- | --- |
| 1\. Parse | Malformed links, missing REALITY keys, bad escaping, wrong port | A small parser script |
| 2\. Resolve | The server name doesn't resolve, or points at an old server | `dig` |
| 3\. Handshake | Wrong UUID, password, keys, certificate, SNI | A real client |
| 4\. Real traffic | Server forwarding or NAT broken, routing rules on the server blocking traffic | A request through the tunnel |
| 5\. DNS in the tunnel | The resolver your clients use is dead | A name lookup through the tunnel |
| 6\. Exit IP | The link points at the wrong server, or traffic leaves from somewhere unexpected | Compare the exit IP with the server IP |
| 7\. User networks | Blocks, MTU and ISP problems that a data center never sees | Canary users |

Steps 1 to 6 run in CI in a minute or two. Step 7 needs people, and it is the step most often skipped.

## How do I check that a share link parses correctly?

Parse every link with a script before any client sees it, and check the fields that clients need. For `vless://` links, the de facto format is the [VLESS share link proposal](https://github.com/XTLS/Xray-core/discussions/716) in the Xray-core repo: `vless://<uuid>@<host>:<port>?<parameters>#<name>`, where `security` is `none`, `tls` or `reality`, a REALITY link must carry `pbk` (the server's public key) and `fp` (the TLS fingerprint), `sid` is the short ID, and every value must be URL-escaped.

This Python script reads links from standard input and exits non-zero if any of them has a problem:

```python
import sys
import uuid
from urllib.parse import urlsplit, parse_qs

def problems(link):
    u = urlsplit(link.strip())
    if u.scheme != "vless":
        return [f"not a vless:// link ({u.scheme or 'no scheme'})"]
    found = []
    try:
        uuid.UUID(u.username or "")
    except ValueError:
        found.append("user id is not a UUID")
    try:
        port = u.port
    except ValueError:
        port = None
    if not u.hostname or not port:
        found.append("missing or invalid host or port")
    q = {k: v[0] for k, v in parse_qs(u.query, keep_blank_values=True).items()}
    if q.get("security") == "reality":
        for key in ("pbk", "fp"):
            if not q.get(key):
                found.append(f"REALITY link without {key}")
    if q.get("type") in ("ws", "httpupgrade", "xhttp") and not q.get("path"):
        found.append(f"{q['type']} link without a path")
    return found

bad = 0
for line in sys.stdin:
    if line.startswith("vless://"):
        for p in problems(line):
            print(f"{p}: {line.strip()[:60]}")
            bad += 1
sys.exit(1 if bad else 0)
```

A truncated UUID, a REALITY link without `pbk` and a port of `99999` all fail here, before any network test. The proposal says a missing `path` means `/` but recommends against leaving it out, so I treat it as an error in my own links. If you use custom strings instead of UUIDs as VLESS IDs, which Xray allows, drop the UUID check.

For a subscription, decode it first and run every line through the script. I went through the formats in [how to decode a V2Ray subscription link](https://tunnelhq.com/blog/decode-v2ray-subscription-link/). WireGuard and OpenVPN files have no separate parse step worth writing: the client refuses a broken file when it starts, which is step 3.

## How do I test a V2Ray or Xray config in CI?

Check the server config with the core's own test flag, then start a real client with the config you will ship and send a request through it. For the server side, both cores have a check command that loads the config and exits:

```
xray run -test -c /usr/local/etc/xray/config.json
sing-box check -c /etc/sing-box/config.json
```

`xray run -test` prints `Configuration OK.` and exits with 0 when the config loads. On a config error, [Xray-core](https://github.com/XTLS/Xray-core) 26.10.31 exits with code 23. Run it before every deploy, so a typo never reaches a running server.

For the client side, I use sing-box because one JSON format covers VLESS, VMess, Trojan, Shadowsocks, Hysteria2, TUIC and WireGuard, and it works against Xray servers. The client config has a local SOCKS/HTTP inbound and the server as its outbound. This one is VLESS with TLS and the Vision flow, checked with sing-box 1.14.4:

```json
{
  "log": { "level": "warn" },
  "inbounds": [
    { "type": "mixed", "listen": "127.0.0.1", "listen_port": 2080 }
  ],
  "outbounds": [
    {
      "type": "vless",
      "tag": "proxy",
      "server": "vpn.yourdomain.com",
      "server_port": 443,
      "uuid": "3f6b2c1e-8d4a-4b7e-9c2f-5a1d0e7b6c48",
      "flow": "xtls-rprx-vision",
      "tls": {
        "enabled": true,
        "server_name": "vpn.yourdomain.com",
        "utls": { "enabled": true, "fingerprint": "chrome" }
      }
    }
  ]
}
```

For a REALITY link, set `server_name` to the link's `sni` and add `"reality": { "enabled": true, "public_key": "<pbk>", "short_id": "<sid>" }` inside `tls`. Generate this JSON from the same data that produces the share link, not by hand. Then the test covers the generator too. The [sing-box configuration docs](https://sing-box.sagernet.org/configuration/) list the fields for every protocol.

Then a script that starts the client, sends a request through it and checks where the traffic left from:

```sh
#!/bin/sh
# Usage: tunnel-test.sh client.json [expected-exit-ip]
# Exits 0 only if a real request goes through the tunnel.
set -eu
SB=${SB:-sing-box}
"$SB" check -c "$1"
"$SB" run -c "$1" > sb.log 2>&1 &
pid=$!
trap 'kill "$pid" 2>/dev/null' EXIT
sleep 3

code=$(curl -sS -m 20 -o /dev/null -w '%{http_code}' \
  --socks5-hostname 127.0.0.1:2080 https://www.gstatic.com/generate_204) || true
if [ "$code" != "204" ]; then
  echo "FAIL: no response through the tunnel (HTTP ${code:-none})"
  cat sb.log
  exit 1
fi

exit_ip=$(curl -sS -m 20 --socks5-hostname 127.0.0.1:2080 https://api.ipify.org)
if [ -n "${2:-}" ] && [ "$exit_ip" != "$2" ]; then
  echo "FAIL: traffic left from $exit_ip, expected $2"
  exit 1
fi
echo "OK: tunnel works, exit IP $exit_ip"
```

I tested this against a local sing-box VLESS server. With a correct config it prints `OK`. With a wrong UUID, curl's TLS connection fails, the script exits with 1, and the server logs `unknown UUID`. The second argument catches a link that works but points at the wrong server, which happens more than you would think when servers are renamed.

In CI, download a pinned sing-box release first, so a new upstream version doesn't change your results without warning:

```
curl -fsSL -o sb.tgz https://github.com/SagerNet/sing-box/releases/download/v1.14.4/sing-box-1.14.4-linux-amd64.tar.gz
tar -xzf sb.tgz
SB=./sing-box-1.14.4-linux-amd64/sing-box ./tunnel-test.sh client.json 176.61.144.20
```

sing-box also has a one-line version, `sing-box tools fetch -c client.json -o proxy <url>`, which exits with 1 when the request fails. It works for proxy outbounds. Through a WireGuard endpoint, it failed in my test with `WireGuard is not ready yet`, because it sends the request before the endpoint is up, so for WireGuard I use the script above.

If you prefer Xray, the same pattern works: an Xray client config with a `socks` inbound on 127.0.0.1, `xray run -c client.json` in the background, and the same curl lines. What a key check involves for a single VLESS link is covered in [how to check a VLESS key](https://tunnelhq.com/blog/how-to-check-vless-key/).

## How do I test WireGuard and OpenVPN configs in CI?

Run the real client where it can't break the CI machine's own network: in userspace through sing-box for WireGuard, or in a throwaway container for either protocol. A full-tunnel WireGuard or OpenVPN client started directly on a CI runner takes over the runner's default route, and the job can lose its connection to the CI service.

For WireGuard, sing-box has a userspace WireGuard endpoint that needs no root and no kernel module. Copy the values from the `.conf` file into it:

```json
{
  "log": { "level": "warn" },
  "inbounds": [
    { "type": "mixed", "listen": "127.0.0.1", "listen_port": 2080 }
  ],
  "endpoints": [
    {
      "type": "wireguard",
      "tag": "wg",
      "address": ["10.66.0.2/32"],
      "private_key": "<PrivateKey from [Interface]>",
      "peers": [
        {
          "address": "vpn.yourdomain.com",
          "port": 51820,
          "public_key": "<PublicKey from [Peer]>",
          "allowed_ips": ["0.0.0.0/0", "::/0"]
        }
      ]
    }
  ],
  "route": { "final": "wg" }
}
```

`Address` maps to `address`, the `[Peer]` `Endpoint` splits into `address` and `port`, and a `PresharedKey` goes into `pre_shared_key`. The same `tunnel-test.sh` then works unchanged. I ran it against a local userspace WireGuard server: with the right keys it prints `OK`, and with a wrong server public key curl waits until its 20-second timeout and the script fails, which is exactly what a real client sees. AmneziaWG configs need an AmneziaWG client (`awg-quick`), because plain WireGuard tools don't understand the `Jc`, `S1` and `H1` lines.

For OpenVPN, run the client in a container with the permissions a tunnel needs, wait for it to report that the tunnel is up, then send a request:

```
docker run --rm --cap-add NET_ADMIN --device /dev/net/tun \
  -v "$PWD/client.ovpn:/client.ovpn:ro" debian:stable-slim sh -c '
    apt-get update -qq && apt-get install -y -qq openvpn curl dnsutils >/dev/null
    openvpn --config /client.ovpn --log /tmp/ovpn.log --daemon
    for i in $(seq 1 30); do
      grep -q "Initialization Sequence Completed" /tmp/ovpn.log && break
      sleep 1
    done
    grep -q "Initialization Sequence Completed" /tmp/ovpn.log || { cat /tmp/ovpn.log; exit 1; }
    curl -sS -m 15 -o /dev/null -w "%{http_code}\n" https://www.gstatic.com/generate_204
  '
```

`Initialization Sequence Completed` is the line OpenVPN logs once the tunnel is up. If it doesn't appear within 30 seconds, the script prints the log, which usually names the problem (a TLS error, an auth failure, a certificate that expired).

## How do I test DNS through the tunnel?

Ask the resolver your users will use, through the tunnel, for a name you know exists. For proxy protocols, the `--socks5-hostname` request in the script already does this: curl passes the hostname to the proxy, and the server resolves it. If the server's resolver is broken, the request fails even though the handshake worked.

WireGuard and OpenVPN are different, because clients use the resolver from the config: the `DNS =` line in WireGuard, or `push "dhcp-option DNS ..."` from an OpenVPN server. Neither the sing-box endpoint nor the container above applies that setting, so query the resolver directly. In the OpenVPN container (which installs `dnsutils` for this), add a line after the curl call. With `verb 3` or higher, the pushed address is in the log line that starts with `PUSH: Received control message`:

```
dig +short @10.8.0.1 www.gstatic.com
```

The userspace sing-box test can't send `dig` through the tunnel, so for WireGuard I run the same query from a canary machine with the real client connected, against the address in its `DNS =` line. An empty answer or a timeout, while traffic by IP works, is the "connected but no internet" report you would otherwise get from users.

## How do I test from the networks my users are on?

CI runs in a data center, so it proves the config is valid and the server works, not that the config works from your users' ISPs. A config can pass every step above and still fail on a mobile network that blocks the protocol, or on a line with a smaller MTU. The only test for that is a real person on that network.

The cheap version is a canary group: a few people (staff, friends, volunteers) on the main ISPs and mobile networks of each country you serve. They get new servers and config changes first, through a separate subscription. Wait a day, collect their results, then roll out to everyone. When the canary group reports a failure that CI didn't see, test DNS, IP, TLS name and protocol one layer at a time, as described in [how to check if your VPN server IP is blocked](https://tunnelhq.com/blog/check-vpn-server-ip-blocked/).

After the rollout, keep checking. A config that passed on Monday can fail on Thursday because a certificate expired or a key rotation missed one server. That is monitoring, not testing, and it runs the same handshake on a schedule.

## When is an online config tester enough?

An online tester is enough for a one-off question about a single link: does this config work right now, from outside? It saves you writing a client config by hand. For anything you ship repeatedly, use the CI scripts above, because they run on every change and keep a record.

One rule for any online tester: a share link is a credential. Anyone who has it can use the server. Only paste links into a tester you trust, and prefer a test account over a real user's link.

Full disclosure: TunnelHQ has two tools for this. The [free config tester](https://tunnelhq.com/test/) runs one real handshake for a pasted config or link, with no account needed. The `thq` CLI's `thq test` does the same from a terminal or a CI job, for a config file, a share link or a subscription URL, and exits with 0 when the test passes and 1 when it fails. It runs on TunnelHQ's checkers and needs an API key.

Source: https://tunnelhq.com/blog/test-vpn-config-before-shipping/
