About this project

hwdsl2/setup-ipsec-vpn is a collection of shell scripts that automate the deployment of a personal IPsec VPN server on a Linux machine. The project uses Libreswan as the IPsec server and xl2tpd as the L2TP provider, and supports three VPN modes: IPsec/L2TP, Cisco IPsec (IPsec/XAuth), and IKEv2. IKEv2 is recommended as it supports strong and fast ciphers such as AES-GCM and works well behind NAT. The setup is fully automated with no user input required. A single one-liner downloads and runs the script, which generates random VPN credentials and displays them upon completion. Users can also provide their own credentials via environment variables or by editing the script. The script supports multiple Linux distributions including Ubuntu (22.04, 24.04, 26.04), Debian (12, 13), CentOS Stream (9, 10), Rocky Linux, AlmaLinux, Oracle Linux, Raspberry Pi OS, Kali Linux, Alpine Linux, and RHEL. The project generates VPN configuration profiles that can auto-configure iOS, macOS, and Android devices. It also supports Windows, Chrome OS, and Linux as VPN clients. Helper scripts are included for managing VPN users, viewing or updating the IPsec pre-shared key, and uninstalling the VPN. Advanced customization options include specifying alternative DNS servers (Google Public DNS, Cloudflare, Quad9, OpenDNS, CleanBrowsing, NextDNS, Control D), customizing IKEv2 options such as DNS name, client name, certificate validity, and MOBIKE support, customizing VPN subnets, enabling split tunneling, deploying Google BBR congestion control, and supporting IPv6. The project also provides a pre-built Docker image for containerized deployment. The scripts back up existing configuration files before making changes, and an upgrade script is available to update Libreswan to the latest supported version (5.4). The project is licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License.