Guides, Nov 19, 2026

# OpenConnect VPN not working: an ocserv troubleshooting guide

When an OpenConnect client connects to ocserv but pages don't load, the cause is almost always on the server's network side: IP forwarding or NAT is missing, the route list doesn't cover what the user wants, or the pushed DNS server can't be reached through the tunnel. When the VPN works but is slow, DTLS (UDP) is usually blocked and the session fell back to TCP. \`occtl show users\` shows that last case at a glance: \`(no-dtls)\` in the dtls-cipher column.

Tahir Mehmood, 11 min read

I checked the directives and defaults below against the ocserv 1.6.0 sample config (October 2026) and the occtl manual, and the client messages against the openconnect 9.21 source. Three names get mixed up, so first: **ocserv** is the server, **openconnect** is the open source client, and Cisco AnyConnect (now Cisco Secure Client) is Cisco's client. ocserv speaks the AnyConnect protocol: a TLS connection over TCP (CSTP) for login and control, plus an optional DTLS channel over UDP for data.

## Is the problem the login, the tunnel or the traffic?

Start by finding the stage that fails. It saves you from changing DNS settings when the real problem is NAT.

| What the user sees | Where to look |
| --- | --- |
| Certificate warning, or "failed verification" | [Certificates and pins](#why-does-the-client-reject-the-server-certificate) |
| Password rejected, or refused at once | [Bans and login limits](#why-does-login-fail-or-stop-after-a-few-tries) |
| Connected, but nothing loads, not even `ping 1.1.1.1` | [NAT and forwarding](#why-does-openconnect-connect-but-no-traffic-passes) |
| Connected, IP addresses work, names don't | [DNS](#why-does-openconnect-have-no-dns) |
| Some sites or networks work, others don't | [Routes](#how-do-routes-work-in-ocserv) |
| Works, but slow, video stutters | [DTLS fallback](#why-is-openconnect-slow) |

On the server, these four commands answer most questions. occtl talks to ocserv over a local socket, which `use-occtl = true` enables (it is on in the sample config):

```
occtl show status          # uptime, active sessions, banned IPs
occtl show users           # who is connected, their VPN IP, device, DTLS cipher
occtl show user alice      # one user in detail
journalctl -u ocserv -f    # the log, while the user connects
```

On a Linux client, run `openconnect -v vpn.yourdomain.com` in a terminal. While it is connected, `kill -USR1 $(pidof openconnect)` makes it print its state, for example `Configured as 10.20.0.5, with SSL connected and DTLS established`.

## Why does OpenConnect connect but no traffic passes?

Because ocserv gives the client an address and a tunnel, and nothing more. Getting packets from the tunnel to the internet is the Linux kernel's job, and two things have to be on: IP forwarding, and NAT (masquerade) for the VPN subnet. ocserv does neither.

Assume the VPN subnet is `ipv4-network = 10.20.0.0/24` and the server's internet interface is `eth0`:

```
# forwarding, now and after reboot
sysctl -w net.ipv4.ip_forward=1
echo 'net.ipv4.ip_forward = 1' > /etc/sysctl.d/90-ocserv.conf

# NAT with nftables
nft add table ip ocserv
nft add chain ip ocserv postrouting '{ type nat hook postrouting priority 100 ; }'
nft add rule ip ocserv postrouting ip saddr 10.20.0.0/24 oifname "eth0" masquerade

# or the same with iptables
iptables -t nat -A POSTROUTING -s 10.20.0.0/24 -o eth0 -j MASQUERADE
```

Then check the FORWARD chain. Docker and ufw both set its policy to DROP, which silently eats VPN traffic even when NAT is right. If `iptables -S FORWARD` starts with `-P FORWARD DROP`, allow the VPN subnet:

```
iptables -A FORWARD -s 10.20.0.0/24 -j ACCEPT
iptables -A FORWARD -d 10.20.0.0/24 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
```

To see where packets stop, let the user ping something and watch both sides. ocserv names its tun devices after the `device` directive (`vpns` by default), so the first user is usually `vpns0`, and `occtl show users` lists the device for each user:

```
tcpdump -ni vpns0 icmp     # do packets arrive from the client?
tcpdump -ni eth0 icmp      # do they leave, with the server's public address?
```

If they arrive on `vpns0` but never leave on `eth0`, it is forwarding or the FORWARD chain. If they leave with the 10.20.0.x source address, NAT is missing. One more ocserv option can cause this: with `restrict-user-to-routes = true`, ocserv's firewall script only lets users reach the routes they were given.

If small requests work but large pages or uploads hang, it is MTU, not routing. Clamping the TCP MSS on the server usually fixes it:

```
iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
```

How to find the real path MTU is the same for any tunnel; the [WireGuard MTU post](https://tunnelhq.com/blog/wireguard-mtu-problems/) walks through `ping -M do -s`.

## How do routes work in ocserv?

ocserv sends the client a list of routes at connect time, and the client sends only those destinations through the tunnel. The rules come straight from the sample config:

-   No `route` lines at all, or `route = default`: full tunnel, everything goes through the VPN.
-   One or more `route = network/mask` lines: split tunnel, only those networks go through the VPN.
-   `no-route = network/mask`: a subset that stays outside the tunnel.

```
# full tunnel, but keep the user's own LAN local
route = default
no-route = 192.168.0.0/255.255.0.0

# or: split tunnel, only the office networks
#route = 10.10.10.0/255.255.255.0
#route = 172.16.0.0/255.240.0.0
```

The common mistake is a full-tunnel server where someone adds one `route` line for an internal network. From that moment the server is split-tunnel, and internet traffic no longer uses the VPN. The reverse also happens: a split-tunnel config loses its last `route` line and becomes full tunnel.

Routes can also be set per user or per group with `config-per-user` and `config-per-group`. Any `route`, `no-route` or `dns` line in those files replaces the global ones instead of adding to them. After a change, run `occtl reload`. The client gets routes when it connects, so users must reconnect to see new ones. On the client, `ip route` (Linux) or `route print` (Windows) shows what it really received.

## Why does OpenConnect have no DNS?

There are three places it can break, and it helps to check them in order: what the server pushes, whether that server is reachable, and whether the client applies it.

**What the server pushes.** ocserv sends the `dns` lines from its config. No `dns` line, no DNS server for the client. With a full tunnel, all DNS queries go through the VPN: `tunnel-all-dns` is the default when a default route is set. With a split tunnel, use `split-dns` to say which domains use the VPN's DNS. Here the office DNS server sits in one of the routed office networks:

```
route = 10.10.10.0/255.255.255.0
dns = 10.10.10.53
split-dns = internal.yourdomain.com
```

**Whether it is reachable.** The DNS address must be inside the VPN subnet or covered by a `route` line. In a split tunnel, a pushed resolver like `10.0.0.53` with no route to `10.0.0.0/8` sends queries out of the user's normal connection, to a private address that doesn't exist there. The resolver must also answer queries from the VPN subnet. A resolver that only listens on loopback (such as the systemd-resolved stub at `127.0.0.53`), or an unbound or BIND server with an access list that doesn't include `10.20.0.0/24`, never answers. Test from the server, then from a connected client:

```
dig @10.10.10.53 internal.yourdomain.com +short
```

**Whether the client applies it.** openconnect does not change DNS itself. It runs vpnc-script, which writes the DNS servers into systemd-resolved, resolvconf or `/etc/resolv.conf`, depending on what the system uses. An old copy of vpnc-script from a distribution package may not know systemd-resolved, so the tunnel works and DNS doesn't. The current script is on the [vpnc-script page](https://www.infradead.org/openconnect/vpnc-script.html). If openconnect runs with no script at all, it says so: `No --script argument provided; DNS and routing are not configured`. On a systemd-resolved system, check what the tun interface got:

```
resolvectl status tun0
```

NetworkManager's OpenConnect plugin applies DNS through NetworkManager instead, so if users connect from the desktop menu, check there.

## Why is OpenConnect slow?

Usually because DTLS failed and all traffic goes over the TLS connection on TCP. Carrying TCP inside TCP works, but when packets are lost, both layers retransmit and throughput falls hard. The tunnel stays up, so users report "slow", not "down".

ocserv listens on both `tcp-port = 443` and `udp-port = 443` by default. If the UDP port is blocked anywhere on the path (a cloud security group, the server firewall, or the user's network), the client logs a failed DTLS handshake (`DTLS handshake failed: ...`, or `DTLS handshake timed out` at debug level) and continues over TLS. The state line from `kill -USR1` then shows `DTLS` as `in progress` or `disabled` instead of `established`.

On the server, it is one column:

```
occtl show users
      id     user    vhost             ip         vpn-ip device   since    dtls-cipher    status
   48211    alice  default  176.61.144.30      10.20.0.5  vpns0  2h:11m      (no-dtls) connected
```

`(no-dtls)` means that session has no DTLS channel. If every user shows it, check the server side first:

```
ss -ulpn | grep ocserv          # is ocserv listening on UDP 443?
nft list ruleset | grep 443     # or: iptables -S | grep 443
```

If only some users show it, their networks block UDP. Some networks block UDP 443 to stop QUIC, which hits DTLS on the same port, and trying a different `udp-port` can help (it is a non-reloadable setting, so restart ocserv). To tell blocking from a broken server, the [post on checking whether a server IP is blocked](https://tunnelhq.com/blog/check-vpn-server-ip-blocked/) has the method. On the client, `openconnect --no-dtls` forces TCP, which is a quick way to compare.

Two timers matter here. `dpd = 90` and `mobile-dpd = 1800` are the dead peer detection intervals in seconds, for desktop and mobile clients. `switch-to-tcp-timeout = 25` means that if no UDP traffic arrives for 25 seconds, ocserv sends over TCP instead, which recovers sessions whose NAT mapping for UDP expired. If you want TCP only, `no-udp = true` turns DTLS off, per user or group, and per vhost since ocserv 1.4.2.

## Why does the client reject the server certificate?

openconnect checks the server certificate like a browser does. When the check fails, it prints the reason and a pin you could use to trust the server anyway:

```
Certificate from VPN server "vpn.yourdomain.com" failed verification.
Reason: signer not found
To trust this server in future, perhaps add this to your command line:
    --servercert pin-sha256:Dkww8SEQ3xLYx7ImyG6PppaqavD1ktbflkXsdqh1ft4=
```

With the GnuTLS build of openconnect, the common reasons are `signer not found` (self-signed, or the chain is incomplete), `certificate expired`, and `certificate does not match hostname`. For the chain, point `server-cert` at the full chain file, not the leaf alone. With Let's Encrypt:

```
server-cert = /etc/letsencrypt/live/vpn.yourdomain.com/fullchain.pem
server-key = /etc/letsencrypt/live/vpn.yourdomain.com/privkey.pem
```

Pins cause a quieter failure later. The `pin-sha256:` value is a SHA-256 hash of the server's public key, not of the whole certificate. If a renewal creates a new key, which is certbot's default, every client started with `--servercert` stops with `None of the 1 fingerprint(s) specified via --servercert match server's certificate`. Either renew with certbot's `--reuse-key` so the pin stays valid, or update the pins. You can compute the current pin on the server:

```
openssl x509 -in /etc/ocserv/server-cert.pem -noout -pubkey \
  | openssl pkey -pubin -outform DER | openssl dgst -sha256 -binary | base64
```

ocserv checks its certificate files periodically and reloads them when they change, and `occtl reload` (the same as SIGHUP) forces it. The `server-cert` path itself is non-reloadable, so renew in place; Let's Encrypt's `live/` symlinks already do that. A certbot deploy hook makes the reload immediate: `--deploy-hook "occtl reload"`.

## Does ocserv work with Cisco AnyConnect?

Yes, that is what it was built for, with a few settings. `cisco-client-compat = true` is needed for older Cisco clients and for openconnect clients before 7.08; it also turns on `dtls-legacy`, the pre-standard DTLS that those older clients need. Newer openconnect clients use DTLS-PSK instead, which ocserv supports by default. If you hand out Cisco client profiles, `user-profile = profile.xml` serves one.

Certificates matter more with Cisco's client. It checks the server certificate against the operating system's trust store, so a self-signed certificate that openconnect users accept with a pin is a problem there. A publicly trusted certificate (Let's Encrypt is fine) avoids it for everyone.

The openconnect client is not limited to ocserv. Its `--protocol` option also covers Juniper Network Connect (`nc`), Pulse (`pulse`), GlobalProtect (`gp`), F5 (`f5`), Fortinet (`fortinet`) and Array (`array`). The default is `anyconnect`, which is what ocserv speaks.

## Why does login fail or stop after a few tries?

Check the ban list before you reset any passwords. ocserv scores each client IP: a wrong password is 10 points and a connection is 1 point. Above `max-ban-score = 80`, the IP is banned for `ban-time = 300` seconds, and scores reset after `ban-reset-time = 1200` seconds. So about eight wrong passwords in 20 minutes ban an IP for five minutes:

```
occtl show ip bans
occtl show ip ban points
occtl unban ip 176.61.144.30
```

This also catches monitoring. A health check that logs in with a wrong password gets its IP banned, and keeps failing for a few minutes after you fix the password. A whole office behind one NAT address shares one score, too.

The other common refusal is `max-same-clients`, the number of sessions one user may have at once. The sample config sets 2, so a third device is refused. For more detail in the log, raise `log-level` (`3` is debug, `9` adds TLS details). It is a non-reloadable setting, so restart ocserv for it.

Full disclosure: TunnelHQ's [OpenConnect monitor](https://tunnelhq.com/openconnect-monitoring/) logs in to ocserv the way a real client does, every 1 to 5 minutes depending on plan, and tells "the login failed" apart from "Tunnel established - Internet is stuck", which is exactly the NAT and DNS class of problem above. A TCP port check in TunnelHQ Uptime can also watch the certificate on port 443 and warn 21, 14 and 7 days before it expires, as long as it is publicly trusted. The details are in the [OpenConnect docs](https://docs.tunnelhq.com/protocols/openconnect/), and every plan has a 14-day free trial. For everything else, the [ocserv manual](https://ocserv.openconnect-vpn.net/ocserv.8.html) and [occtl manual](https://ocserv.openconnect-vpn.net/occtl.8.html) are the references I use.

Source: https://tunnelhq.com/blog/ocserv-openconnect-troubleshooting/
