Commands / Routing and tunnels

Routing and tunnels

openvpn

Also ovpn, ssl vpn, tls vpn, vpn client

Runs an SSL VPN, client or server, from a profile: a tun card on one side, one UDP or TCP connection on the other.

openvpn --config FILE does everything from a profile. proto and remote say how to reach the gateway, on UDP 1194 by default and often on TCP 443 where only the web gets out. ca, cert and key prove both ends to each other in a TLS session, and the gateway pushes the tunnel's address and routes as it comes up. Initialization Sequence Completed in the log means the tunnel is up. On TCP, one lost packet holds up every packet behind it, so it stalls on a bad line.

openvpn command usage

openvpn --config FILE
openvpn --config FILE --daemon --log FILE

Options

--config FILE
read every setting from this profile
--daemon
go into the background once started
--log FILE
write the log to this file, replacing what was there

openvpn examples

openvpn --config /etc/openvpn/office.conf
Starts the tunnel in front of you, printing its log.
openvpn --config /etc/openvpn/office.conf --daemon --log /var/log/openvpn.log
Starts it in the background, with the log in a file.
grep -E "WARNING|VERIFY|Peer Connection" /var/log/openvpn.log
Shows which certificate the other end offered and whether it passed.

Pitfalls

  • VERIFY OK says a trusted CA signed the certificate, not that this is your gateway. Name the gateway with verify-x509-name.
  • A connected VPN has only proved the two ends trust each other. What it reaches depends on the routes the gateway pushes.

Run it on real machines

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab