Easily Connect to l2tp/IPsec VPN in Ubuntu 18.04

creating an l2tp over IPsec connection in Ubuntu proved to be a nontrivial task, so here is the process in case I ever need to remember in the future.

1. Install network-manager-l2tp:

sudo add-apt-repository ppa:nm-l2tp/network-manager-l2tp 
sudo apt-get update
sudo apt-get install network-manager-l2tp

If using gnome, install the gnome plugin (if using another desktop environment, see if there’s a plugin for its network manager):

sudo apt-get install network-manager-l2tp-gnome

2. Create a New VPN Connection

Navigate to Settings > Network > Click the + button > Select “Layer 2 Tunneling Protocol (L2TP)”

Name the new VPN connection something
Put the hostname or address in the Gateway field.
Put username in the Username field.
Click the icon in the Password field and select your preference for how to supply the password.

Click IPSec Settings…
Click the box for “Enable IPsec tunnel to L2TP host”
Enter the shared secret into the Pre-shared key field.
Leave the Gateway ID field empty.
Expand the Advanced options area
Enter “3des-sha1-modp1024” into the Phase 1 Algorithms box.
Enter “3des-sha1” into the Phase 2 Algorithms box.
Leave the box checked for “Enforce UDP encapsulation”.
Click OK.
Click Save.

3. disable xl2tpd

Open a terminal and enter the following commands to permanently disable the xl2tpd service:

sudo service xl2tpd stop
sudo systemctl disable xl2tpd

Open Network Settings and try to turn the VPN on

and there you go!