Table of Contents
What you will read?
Setting up an L2TP VPN on Ubuntu 25.10 allows you to create a secure, encrypted connection to a remote network. This guide will walk you through all the necessary steps to get your VPN running properly, including installation, configuration, and connection using Network Manager.
Step 1: Install Required Packages
Install the necessary packages to enable L2TP VPN support on Ubuntu, including Network Manager, IPsec, and xl2tpd.
sudo apt update
sudo apt install network-manager-l2tp-gnome strongswan xl2tpd -y
Step 2: Configure IPsec
IPsec encrypts your VPN traffic, ensuring a secure and private connection between your Ubuntu 25.10 system and the VPN server. Proper configuration is essential for authentication and stable VPN performance.
sudo nano /etc/ipsec.conf
Add the following, replacing VPN_SERVER_IP with your server address:
config setup
charondebug="ike 1, knl 1, cfg 0"
conn l2tp
keyexchange=ikev1
authby=secret
type=transport
left=%defaultroute
leftprotoport=17/1701
right=VPN_SERVER_IP
rightprotoport=17/1701
auto=start
Step 3: Configure L2TP
The L2TP configuration defines the tunnel through which your VPN traffic travels. Setting the correct IP range, local IP, and authentication options ensures a stable and secure connection between your Ubuntu system and the VPN server.
sudo nano /etc/xl2tpd/xl2tpd.conf
Add the following configuration, replacing SERVER_IP with your server address:
[global]
ipsec saref = yes
listen-addr = SERVER_IP
[lns default]
ip range = 192.168.100.10-192.168.100.20
local ip = 192.168.100.1
require chap = yes
refuse pap = yes
require authentication = yes
name = l2tpclient
ppp debug = yes
pppoptfile = /etc/ppp/options.l2tpd
length bit = yes
Step 4: Configure PPP
PPP settings handle authentication for your VPN connection. Providing the correct username, password, and DNS ensures your connection can authenticate and resolve addresses properly.
sudo nano /etc/ppp/options.l2tpd
Add the following configuration:
# PPP Configuration
name VPN_USERNAME
password VPN_PASSWORD
refuse-pap
require-chap
ms-dns 8.8.8.8
mtu 1410
mru 1410
persist
noauth
Step 5: Start and Enable Services
Once configuration files are set, you need to start the services responsible for L2TP and IPsec. Enabling them ensures they run automatically after server restarts.
sudo systemctl restart strongswan xl2tpd
sudo systemctl enable strongswan xl2tpd
Step 6: Configure Firewall
For a secure VPN, specific UDP ports must be open. Configuring the firewall allows VPN traffic to pass without blocking legitimate connections.
sudo ufw allow 500,4500/udp
sudo ufw reload
Step 7: Connect via Network Manager
Use Network Manager to create and activate your L2TP VPN connection easily with a graphical interface.
nm-connection-editor
L2TP VPN Setup:
# 1. Click "Add" → Select "Layer 2 Tunneling Protocol (L2TP)" → Create
# 2. Enter connection name, server IP, username, and password
# 3. Enable "IPsec tunnel" and enter the pre-shared key
# 4. Save and connect
