Ubiquiti: How to configure an L2TP/IPSEC VPN on UDM Pro and SE – Tech2Tech

Today we will see together how to configure a VPN server on the UDM Pro or UDM Pro SE. For some time now, the UDM Pro SE has offered two options for setting up a VPN, either the traditional and well-known L2TP/IPSEC VPN, or WireGuard. This is the first solution I’m going to present to you today, however, I’ll be back shortly with another article about setting up a VPN with WireGuard.

The VPN (Virtual Private Network) is a way to connect your devices (computers, tablets, smartphones, etc.) remotely to your network using a secure and private connection. This will allow you to access your Windows servers, NAS servers or even your printing devices from the outside in complete safety. One of the most widely used VPN protocols is L2TP/IPSEC, which offers a combination of security and ease of use. L2TP (Layer 2 Tunneling Protocol) was created by a collaboration between Microsoft and Cisco Systems in 1999.

Configuration VPN L2TP/IPSEC sur Unifi

Attention, in my case, the UDM Pro being behind a Livebox, it is configured in DMZ. that is to say that all the ports are open to the UDM Pro, it is then this one which will act as firewall and router. Depending on your configuration (if you are in bridge for example), the procedure may differ slightly. What you have to keep in mind is that the L2TP/IPsec protocol uses UDP ports 500 and 4500. It is therefore necessary that they are open.

On the UDM side, this will be done automatically, on your box side, it depends on your configuration. In Bridge, no port to open, if like me you are in DMZ, no port to open either, if your UDM is not in DMZ, then you will have to open these ports and redirect them to your UDM in order to do dual-NAT.

If it’s not clear, feel free to use the comments. We will now move on to setting up the VPN.

VPN configuration on UDM (Pro and SE)

From the Network application of your UDM Pro / SE, click on ” Settings » then in the section « Teleport & VPN ” click on ” Create New ” in front of ” VPN Server« .

Here, if you have a UDMPRO in “SE” version, select L2TP, we will see in a future article the configuration with WireGuard. Add a name to your VPN network.
You can retrieve the pre-shared key or create your own, finally, in the ” Server Address » , it is the WAN IP which must appear, unless like me you are in DMZ, then it will be the IP of your UDM on the network of your Box.
This is where you will also be able to create your users, to do this click on ” Create New User » .

Create your users here to grant them the right to connect to the VPN. Click on ” Create User ” to validate.

You will then be able to use this VPN as it is, or go a little further in the configuration by selecting “Manual” in the “Advanced” section.
In particular, you will be able to change the network used by the VPN, add your DNS or even activate strong authentication for the use of the MS-Chapv2 protocol for Windows.

Firewall rules are automatically created on UDM once the VPN is created.

Connexion au VPN Unifi UDM via Windows

Now that our VPN is installed and configured, we will see how to connect to the VPN from outside with Windows. Remember to do your tests from outside your network (with connection sharing for example). The protocol advantage L2TP/IPSEC is that we will not need to install any application, it is integrated into Windows.
Here is the method on Windows 11 (it remains very similar to Windows 10)

  1. From the Windows settings, click on ” Network and Internet » then select VPN
  2. Click on Add a VPN
  3. Here select Windows (embedded) as a VPN provider, add a custom name for your VPN, your UDM’s WAN ip or its custom DNS.
    Select L2TP/IPsec with pre-shared key then enter the pre-shared key that you had configured in the UDM VPN.
  4. Finish by adding your username and associated password. Click “Save to Finish”.
  5. We must now activate MS Chap v2 on our virtual network card.
  6. Right-click on the start menu and select “Run” (or use the shortcut “Win+R”)
  7. Launch the command ncpa.cpl which will allow you to directly access all of your network cards.
  8. Access the properties of the virtual network card dedicated to your VPN
  9. In the security tab, click on “Allow these protocols” then select “MS-CHAP v2”, validate by clicking on “OK”.
Related Articles:  Appl iPhone 14 would be the last with a Lightning port

We’re almost done. If you have your UDM in bridge, then your VPN should already be functional. However if like me it is behind NAT (DMZ or Double NAT), it is necessary to add a registry key so that it is functional. (More info here)

For UDMs in NAT

As explained above, if you want to use Windows as a VPN client and your UDM is in NAT, then you will have to make a small modification in the registry. Here’s how :

  1. On your Windows computer, use the “Win ​​+ R” shortcut to be able to run the “Regedit” command.
  2. From the registry, find and select it under the following registry key:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetServicesPolicyAgent
  3. Add a DWORD value (32 bit) bearing the name AssumeUDPEncapsulationContextOnSendRule
  4. Give the value “2”
  5. Restart the computer (essential).

Now that our machine is configured correctly, we will be able to launch the VPN connection. To do this, either directly from the settings in the “Networks” option.

Either directly from quick actions, you should now see your VPN. Just click on ” Connect » !

A simple ipconfig will then allow you to check that you have correctly recovered the IP address of your VPN tunnel.

That’s it, you should now be able to easily create a VPN connection from your Ubiquiti UDM. L2TP being a recognized protocol, it is available on any type of device, so it will be possible to mount your VPN also on Linux, macOS or even your smartphone.

Be careful, by default once connected to your VPN, you have full access to all of your network and your VLANs. If you need to block access to certain IP addresses or VLANs, you will need to create new “LAN OUT” firewall rules. I talk about it in my video, feel free to take a look if you want to deepen the subject.

We will come back soon with an article to explain how to set up a site-to-site VPN, but also a VPN via WireGuard.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.