-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This walks you from nothing to a working VPN connection.
- A Linux host with Docker (and ideally Docker Compose)
- The
/dev/net/tundevice available on the host (standard on virtually all Linux) - A TCP (and optionally UDP) port reachable from your clients —
443by default - A TLS certificate for your server (self-signed for testing, or Let's Encrypt for production — see Reverse Proxy and Certificates)
mkdir -p ocserv-server/volumes/config
cd ocserv-serverThe container ships a default ocserv.conf template that it copies in on first start if none exists, but you almost always want to start from one of the documented configuration variants:
| Variant | Use it for |
|---|---|
| Basic Standalone | Standalone server, you supply certs |
| Self-Signed | Local testing with a self-signed cert |
| SWAG Integration | Production behind SWAG / Let's Encrypt |
Copy one to volumes/config/ocserv.conf and edit it (domain, subnet, cert paths). See ocserv Configuration for what the directives mean.
services:
ocserv:
image: azinchen/ocserv-server:latest
container_name: ocserv-server
restart: unless-stopped
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun:/dev/net/tun
sysctls:
- net.ipv4.ip_forward=1
- net.ipv6.conf.all.forwarding=1
ports:
- 443:443/tcp
- 443:443/udp
environment:
- VPN_SUBNET=10.20.0.0/24
volumes:
- ./volumes/config:/etc/ocservEvery knob here is explained in Configuration Reference.
docker compose up -d
docker compose logs -fA healthy startup looks like:
[INIT-CONFIG] ocserv configuration file is present
[INIT-NAT] Setting up IPv4 NAT for subnet 10.20.0.0/24 via eth0
[INIT-NAT] NAT and forwarding setup complete
[SVC-OCSERV] Starting ocserv service
listening (TCP) on 0.0.0.0:443...
sec-mod: sec-mod initialized
docker exec -it ocserv-server ocpasswd -c /etc/ocserv/ocpasswd aliceIt prompts for a password. More in User Management.
sudo openconnect https://vpn.example.com --user=aliceIf you used a self-signed cert, pin it instead of disabling verification — see Clients and Devices. If you enabled camouflage, the URL must include the secret — see Camouflage Mode.
Connecting only proves authentication. To confirm the data plane works, see the verification steps in Troubleshooting.
ocserv-server · MIT License · Built on ocserv + s6-overlay