This article describes how to set up L2TP VPN using the UniFi Security Gateway (USG) as a RADIUS Server.
Table of Contents
UniFi Controller Setup
1. Configure the USG as a RADIUS server
1.1. Navigate to Settings > Services > RADIUS.
1.2. Enable the RADIUS server under the "Server" tab.
- Secret: Pre-shared key provisioned to the authenticator devices and the RADIUS server. This provides authentication between the two types of devices ensuring RADIUS message integrity.
NOTE: Its best to use your own randomly generated RADIUS secret. "RADIUSAuth" is a placeholder. Spaces are not allowed in the key.
- Authentication port: The port in which RADIUS authentication messages are to be sent and received by authenticator and RADIUS server devices.
- Accounting Port: The port in which RADIUS accounting messages are to be sent and received by authenticator and RADIUS server devices.
- Accounting Interim Interval: Time in milliseconds in which a RADIUS access request packet is sent with an Acct-Status-Type attribute with the value "interim-update". This update is sent to request the status of an active session. "Interim" records contain report the current session duration and can provide information on data usage.
2. Create User Accounts
2.1. Navigate to Settings > Services > RADIUS.
2.2. Create user accounts under the "User" tab.
2.3. Click Save.
3. Configure the L2TP Network
3.1. Navigate to Settings > Networks > Create New Network in the UniFi Controller.
3.2. Fill out necessary fields as shown in the image above:
3.3. Choose the Default RADIUS Profile from the dropdown.
3.4. Click SAVE.
If using a Windows machine to connect to L2TP, follow these steps to set it up:
1. Go to Settings
2. VPN > Add VPN connection
3. See the following screenshot and fill the information requested.
Windows Authentication Setup
- Go to Control Panel > Network & Sharing settings > Change Adapter Settings.
- Right click the L2TP adapter, then go to Properties > Security.
- Under Type of VPN, select Layer 2 Tunneling Protocol with IPsec.
- Click Advanced Settings. Select preshared key for authentication and enter it.
- Make sure to have the option of Allow these protocols enabled and mark the checkbox for Check Microsoft CHAP Version 2 (MS-CHAP v2), as shown in the screenshot below.
The macOS setup is more straightforward and no authentication modifications are needed.
1. Simply go to System Preferences > Network
2. Click the + button
2.1 Interface: VPN
2.2 VPN Type: L2TP over IPsec
3. In Authentication settings enter the preshared key.
Additional Notes & Considerations
- L2TP doesn't have a route distribution method. If the setting on the client device to route "all" traffic through the tunnel is not enabled, it will be necessary to add the manual routes on the client, to point to the USG's local networks. Search in each specific client device's documentation on how to enable sending all traffic over the VPN connection.
- Setting up L2TP will auto add firewall rules to WAN Local in Settings > Routing & Firewall, no manual rules are required on the user end.
- If your USG's WAN is behind NAT and has a private IP, it is necessary to configure port forwarding on the upstream router to forward UDP ports 500, 1701, and 4500 to the USG's WAN address.
- In pre-4.3.41 USG firmware, L2TP remote access VPN will not work if there are already one or more site-to-site IPsec VPNs configured. Please update to the latest firmware.
- In controller versions prior to 5.7.22, if UPnP is configured on the USG, an ACL will need to be created to deny UDP ports 500/4500. See this Community post for more. This community post is in the Early access section of our Community, see this article to learn How to Sign Up for Early Access.