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!

11 Replies to “Easily Connect to l2tp/IPsec VPN in Ubuntu 18.04”

    1. In all honestly I don’t think that the PPA is required, but it is included in the tutorial simply because it is the method that I used to do the install, I would re-test the tutorial without it but I no longer have access to the VPN that I was using, so if you try it without the PPA and it work feel free to let me know and I will update the post!


  1. I have tried all things, nothing works, I cannot connect to my remote Draytek Vigor from my Ubuntu PC.

    Conversely, all of my Win PCs connect without issue.

    It is all very frustrating.

  2. Hi,

    I see this error message in journalctl when I try to save the algorithms
    gnome-control-c[2475]: ((libnm-core/nm-setting-vpn.c:193)): assertion ” failed

    Any ideas?

  3. It’s the same for me. I managed to tick the “Enfore UDP encapsulation” button before, but it has suddenly begun to untick itself, making my VPN unable to connect.
    I tick the box and press OK, but every time I check it has mysteriously unticked itself.
    Is it possible to do this via Terminal to get a better output of what’s going on? I receive no error messages.

Leave a Reply

Your email address will not be published. Required fields are marked *