Run it as a service
ezvpn server start and ezvpn client start are foreground processes: they log to the terminal and run until stopped. To keep a server or an unattended client running, let the platform's service manager start it at boot, restart it after a crash, and capture its logs — systemd on Linux, launchd on macOS, a service wrapper on Windows.On this page
All ezvpn guides
Foreground, daemon, or service
Every setup below runs ezvpn in the foreground and leaves backgrounding to the service manager, which must run it as root, or LocalSystem on Windows.
For a quick background client without a service manager, client start --daemon (Linux and macOS only) forks into the background. Stop it with the same --instance it was started with:
sudo ezvpn client start --daemon -c /etc/ezvpn/work.toml --instance work
sudo ezvpn client stop --instance work # leave out --instance for the default instanceA daemon logs to /var/log/ezvpn/ezvpn-client-<instance>.log. For anything unattended a service manager is still better, since it restarts a crashed client; under one, leave out --daemon.
The server has no --instance, --daemon, or server stop: a host runs one server, and the service manager stops it.
The runtime directory
ezvpn keeps each instance's lock file and control endpoint in a fixed, machine-wide runtime directory, so status, list, and client stop find an instance however it was started.
| Platform | Runtime directory | Control endpoint |
|---|---|---|
| Linux | /run/ezvpn | A Unix socket in the runtime directory |
| macOS | /var/run/ezvpn | A Unix socket in the runtime directory |
| Windows | %ProgramData%\ezvpn | A global named pipe, such as \\.\pipe\ezvpn-client-work |
status and list work without sudo or elevation; client stop needs sudo. To use another location, set EZVPN_RUNTIME_DIR (an absolute path) identically for the service and for the commands you type by hand.
Linux: systemd
A client
A template unit maps onto --instance: instance work reads /etc/ezvpn/work.toml.
[Unit]
Description=ezvpn client (%i)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/ezvpn client start -c /etc/ezvpn/%i.toml --instance %i
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now ezvpn-client@work # start now and at boot
sudo systemctl status ezvpn-client@work
sudo journalctl -u ezvpn-client@work -f # follow the logs
sudo systemctl restart ezvpn-client@work
sudo systemctl disable --now ezvpn-client@work # stop and remove from boot
sudo systemctl enable --now ezvpn-client@home # a second instance, /etc/ezvpn/home.toml
ezvpn client status --instance work # no sudo needed
ezvpn client listThe server
Keep the config, identity key, and authorized_keys in /etc/ezvpn, and use absolute paths inside vpn_server.toml, since a systemd service starts in /.
[Unit]
Description=ezvpn server
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/ezvpn server start -c /etc/ezvpn/vpn_server.toml
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now ezvpn-server
sudo journalctl -u ezvpn-server -f
ezvpn server status # includes the endpoint ID clients connect tomacOS: launchd
A client
launchd has no template units, so each instance gets a plist of its own: copy the file and change the Label, the config path, --instance, and the log path.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ezvpn.client.work</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/ezvpn</string>
<string>client</string>
<string>start</string>
<string>-c</string>
<string>/usr/local/etc/ezvpn/work.toml</string>
<string>--instance</string>
<string>work</string>
</array>
<key>RunAtLoad</key><true/>
<!-- restart on crash, but not after a clean exit -->
<key>KeepAlive</key>
<dict><key>SuccessfulExit</key><false/></dict>
<!-- launchd has no journald; capture logs to files -->
<key>StandardOutPath</key><string>/var/log/ezvpn-work.log</string>
<key>StandardErrorPath</key><string>/var/log/ezvpn-work.log</string>
</dict>
</plist>launchd rejects a plist not owned by root or writable by others, so set its owner and mode first:
sudo chown root:wheel /Library/LaunchDaemons/com.ezvpn.client.work.plist
sudo chmod 644 /Library/LaunchDaemons/com.ezvpn.client.work.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.ezvpn.client.work.plist
sudo launchctl print system/com.ezvpn.client.work # inspect
sudo launchctl kickstart -k system/com.ezvpn.client.work # restart
sudo launchctl bootout system/com.ezvpn.client.work # stop and unloadFor a single client, leave the two --instance strings out of the plist: that is the default instance.
The server
Keep the config, the identity key, and the authorized_keys file together in the system config directory, readable by root only:
sudo install -d -m 700 /usr/local/etc/ezvpn
sudo ezvpn generate-server-key --output /usr/local/etc/ezvpn/vpn-server.key
# then put vpn_server.toml and authorized_keys in the same directoryUse absolute paths inside vpn_server.toml, since launchd starts the job in /:
[auth]
authorized_keys_file = "/usr/local/etc/ezvpn/authorized_keys"
[iroh]
secret_file = "/usr/local/etc/ezvpn/vpn-server.key"<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.ezvpn.server</string>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<!-- exec: launchd's job (and its SIGTERM) is ezvpn itself; its output
goes through sed | logger into unified logging, prefixed -->
<string>exec /usr/local/bin/ezvpn server start -c /usr/local/etc/ezvpn/vpn_server.toml > >(/usr/bin/sed -l 's/^/ezvpn-server: /' | /usr/bin/logger) 2>&1</string>
</array>
<key>RunAtLoad</key><true/>
<!-- a server stays up: restart it whenever it exits -->
<key>KeepAlive</key><true/>
</dict>
</plist>The shell sends the server's output into macOS unified logging (see Logs), and exec keeps ezvpn itself as the job, so launchd's SIGTERM lets it close client connections cleanly. Keep /bin/bash: /bin/sh has no process substitution.
sudo chown root:wheel /Library/LaunchDaemons/com.ezvpn.server.plist
sudo chmod 644 /Library/LaunchDaemons/com.ezvpn.server.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.ezvpn.server.plist
sudo launchctl print system/com.ezvpn.server # inspect
sudo launchctl kickstart -k system/com.ezvpn.server # restart
sudo launchctl bootout system/com.ezvpn.server # stop and unload
ezvpn server status # includes the endpoint ID clients connect to
ezvpn server listTo upgrade, move the new binary into place at /usr/local/bin/ezvpn — do not copy over the running one — and restart the job with kickstart -k.
Windows: a service wrapper
ezvpn.exe is a console program, not a native service, so sc.exe create pointed at it fails. Use a wrapper such as NSSM (winget install --id NSSM.NSSM), shown here; WinSW works too. wintun.dll must be next to ezvpn.exe or on the system PATH (see Install ezvpn).
A client
One service per instance, from an elevated PowerShell:
$exe = "$env:ProgramData\ezvpn\ezvpn.exe"
nssm install ezvpn-work $exe client start -c "C:\ProgramData\ezvpn\work.toml" --instance work
# Logs (NSSM redirects the console output). NSSM does not create the
# directory, and the service will not start without it.
New-Item -ItemType Directory -Force C:\ProgramData\ezvpn\logs | Out-Null
nssm set ezvpn-work AppStdout C:\ProgramData\ezvpn\logs\work.log
nssm set ezvpn-work AppStderr C:\ProgramData\ezvpn\logs\work.log
nssm set ezvpn-work Start SERVICE_AUTO_START
nssm start ezvpn-work
nssm restart ezvpn-work
nssm stop ezvpn-work
nssm remove ezvpn-work confirm # uninstallezvpn client status --instance work and ezvpn client list need no elevation. For a single client, leave out --instance when creating the service and when querying it.
Windows: the server
This assumes the installer put ezvpn.exe in %ProgramData%\ezvpn with wintun.dll beside it, and that NSSM is installed. Run everything from an elevated PowerShell.
Files. Keep the config, the identity key, and
authorized_keysin%ProgramData%\ezvpn, and create the log directory, which NSSM does not:$dir = "$env:ProgramData\ezvpn" ezvpn generate-server-key --output "$dir\vpn-server.key" # then put vpn_server.toml and authorized_keys in $dir New-Item -ItemType Directory -Force "$dir\logs" | Out-NullUse absolute paths inside
vpn_server.toml, in single quotes so that TOML does not read the backslashes as escapes:vpn_server.toml[auth] authorized_keys_file = 'C:\ProgramData\ezvpn\authorized_keys' [iroh] secret_file = 'C:\ProgramData\ezvpn\vpn-server.key'Permissions. Other local users can read
%ProgramData%\ezvpn; take the identity key out of their reach:# S-1-5-18 = SYSTEM, S-1-5-32-544 = Administrators # (SIDs, so the command also works on a non-English Windows) icacls "$dir\vpn-server.key" /inheritance:r /grant:r "*S-1-5-18:F" "*S-1-5-32-544:F"Service.
nssm install ezvpn-server "$dir\ezvpn.exe" server start -c "$dir\vpn_server.toml" nssm set ezvpn-server Start SERVICE_AUTO_START # Logs: ezvpn logs to stderr nssm set ezvpn-server AppStderr "$dir\logs\server.log" nssm set ezvpn-server AppRotateFiles 1 nssm set ezvpn-server AppRotateOnline 1 nssm set ezvpn-server AppRotateBytes 10485760 nssm start ezvpn-server nssm restart ezvpn-server nssm stop ezvpn-server nssm remove ezvpn-server confirm # uninstall
NSSM restarts the server if it exits, and the service starts at boot. The log rotates at each start and at 10 MiB; nothing deletes the old files. Redirect AppStderr only: adding AppStdout with online rotation can leave the service stuck in "stop pending".
Upgrading: stop the service, run the installer again, and start the service.
Windows Firewall
The tunnel adapter comes up in the Public profile, so Windows Firewall drops what clients send to the server's VPN address. Allow the VPN prefix (the server config's network):
# everything from VPN clients
New-NetFirewallRule -DisplayName "ezvpn clients" -Direction Inbound -Action Allow -RemoteAddress 10.0.0.0/24
# or one service only, e.g. Remote Desktop
New-NetFirewallRule -DisplayName "ezvpn clients RDP" -Direction Inbound -Action Allow -RemoteAddress 10.0.0.0/24 -Protocol TCP -LocalPort 3389This covers the Windows host itself; using it as a gateway to its network is not documented yet.
Logs
| Run as | Where the output goes |
|---|---|
| systemd | The journal: journalctl -u <unit>. |
| launchd, server | Unified logging, through the plist's logger pipe. |
| launchd, client | The plist's StandardOutPath file, for example /var/log/ezvpn-work.log. |
| NSSM | The AppStdout / AppStderr file. |
--daemon | /var/log/ezvpn/ezvpn-client-<instance>.log, rotated at 10 MiB to one .log.1 backup. |
To read the macOS server's lines from unified logging (use /usr/bin/log in zsh, where log is a builtin):
P='process == "logger" AND eventMessage BEGINSWITH "ezvpn-server: "'
/usr/bin/log show --last 1h --predicate "$P" --style compact # recent
/usr/bin/log stream --predicate "$P" --style compact # followlaunchd never rotates the client's log file, but it grows slowly and can be emptied in place: sudo sh -c ': > /var/log/ezvpn-work.log'.
How much is logged
By default ezvpn logs its startup summary, clients connecting and disconnecting, and warnings. RUST_LOG=warn keeps only warnings and errors; RUST_LOG=warn,ezvpn=debug adds ezvpn's step-by-step detail. Leave RUST_LOG out of a service unless you are debugging: a plain RUST_LOG=info also turns on iroh's per-packet logging, which can grow a log by gigabytes.
Multiple instances
Each client is identified by --instance <NAME> (default default), so run one service per instance as above; ezvpn client list shows them together. A stopped instance may show as not responding (stale lock) for a while. More in Several clients on one host.