Revision 2 of 2026-11-25 18:54 UTC by tux, the current one. Current version - History
VPN
5.1
A VPN links networks through a tunnel over the Internet: the traffic inside is encrypted, and the two ends see each other as if they were on the same local network. Use it to reach the machines of your home or office from outside, or to join the VPN of a company or a provider.
SliTaz 5.1 has WireGuard, the simplest, and OpenVPN, which most providers and companies hand out files for. There is no graphical tool for them: everything below is done as root in a terminal.
WireGuard
The WireGuard module is in the kernel; the wg tool is in
wireguard-tools:
# spk-add wireguard-tools
The package has wg only, not the wg-quick script of other
distributions: the interface is set up with ip and wg, which takes a
few more lines but hides nothing.
Keys
Each end has a private key and gives its public key to the other end:
# mkdir -p /etc/wireguard
# cd /etc/wireguard
# umask 077
# wg genkey > private.key
# wg pubkey < private.key > public.key
Client
The configuration file, /etc/wireguard/wg0.conf:
[Interface]
PrivateKey = the content of private.key
[Peer]
PublicKey = the public key of the server
Endpoint = vpn.example.org:51820
AllowedIPs = 10.0.0.0/24
PersistentKeepalive = 25
AllowedIPs is what goes through the tunnel: here the 10.0.0.x network
of the other end. A configuration made for wg-quick may also have
Address and DNS lines: wg refuses them. Remove them and set the
address with ip, as below.
Bring up the tunnel, with the address given by the other end:
# ip link add dev wg0 type wireguard
# ip address add 10.0.0.2/24 dev wg0
# wg setconf wg0 /etc/wireguard/wg0.conf
# ip link set wg0 up
Check:
# wg show
$ ping 10.0.0.1
wg show gives the time of the "latest handshake" with the server.
None means the keys or the endpoint are wrong, or a firewall blocks the
UDP port. To take the tunnel down:
# ip link del wg0
All the traffic through the tunnel
With AllowedIPs = 0.0.0.0/0, the default route must go through wg0,
except the route to the server itself, which stays on your normal
gateway. With a server at 203.0.113.5 and a box at 192.168.1.1:
# ip route add 203.0.113.5 via 192.168.1.1
# ip route replace default dev wg0
Then put the DNS server of the VPN in /etc/resolv.conf. Restarting
the network (/etc/init.d/network.sh restart) brings the normal routes
back.
Server
On the machine that waits for clients, /etc/wireguard/wg0.conf has a
listening port and one [Peer] per client:
[Interface]
PrivateKey = the private key of the server
ListenPort = 51820
[Peer]
PublicKey = the public key of the client
AllowedIPs = 10.0.0.2/32
Bring it up the same way, with the address 10.0.0.1/24. Open UDP port
51820 in the firewall (see the Handbook,
Firewall) and
forward it on your box.
OpenVPN
# spk-add openvpn
A provider or an administrator gives you a .ovpn file. Copy it to
/etc/openvpn/client.conf, then start it in the terminal:
# openvpn --config /etc/openvpn/client.conf
It prints "Initialization Sequence Completed" once connected; Ctrl+C stops it. To leave it in the background:
# openvpn --config /etc/openvpn/client.conf --daemon
# killall openvpn
Notes:
- If the VPN asks for a user name and a password, put them on two lines
in a file,
chmod 600it, and addauth-user-pass /etc/openvpn/loginto the configuration. - OpenVPN does not change
/etc/resolv.confby itself: if the VPN has its own DNS server, set it there by hand. - Removing the openvpn package deletes
/etc/openvpn. Keep a copy of your files. - The package has two boot scripts,
/etc/init.d/openvpn-clientandopenvpn-server, but they need anOPENVPN_OPTIONSline that/etc/daemons.confdoes not have. Until they are fixed, start OpenVPN at boot from/etc/init.d/local.sh, with the--daemonline above.
Your own OpenVPN server
The package has a helper, make-ovpn, written for SliTaz. It installs
easy-rsa, makes the certificates in /etc/openvpn/easy-rsa (it asks
for a country, a company and a city the first time), and writes
ready-to-use configuration files. Run each command once on the screen,
to answer the questions and make the keys, then a second time into a
file, which then holds the configuration only:
# make-ovpn server office 192.168.99 192.168.0.0/255.255.255.0
# make-ovpn server office 192.168.99 192.168.0.0/255.255.255.0 > server.ovpn
# make-ovpn client laptop myoffice.org
# make-ovpn client laptop myoffice.org > laptop.ovpn
The server gives the 192.168.99.x addresses to its clients and lets them reach the 192.168.0.0 network behind it. It listens on UDP port
- Start it with
openvpn --config server.ovpn --daemon, and copylaptop.ovpnto the client: it holds its keys, keep it private.make-ovpnwithout arguments prints its help.conf2ovpnturns a configuration with separate key files into a single.ovpnfile.
Other VPNs
openconnect: Cisco AnyConnect and compatible VPNs (openconnect vpn.example.org).vpnc: older Cisco VPN concentrators.tinc: a mesh VPN between several machines.
Links
- WireGuard: quick start
- OpenVPN: documentation
- OpenConnect
- Network profiles