# VPN L2TP

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F8B9NvYxTElKw72UJ6iNm%2Fimage.png?alt=media&#x26;token=8e4b660d-b407-472d-9e03-b531b36ecb78" alt=""><figcaption></figcaption></figure>

#### Windows Server: <mark style="color:blue;">Eth1: NAT</mark>            <mark style="color:red;">Eth2: Custom (192.168.10.1/24)</mark> <a href="#ynttx0mf4ufy" id="ynttx0mf4ufy"></a>

#### Windows 10: <mark style="color:red;">Eth1:Custom (192.168.10.100/24 , GW: 192.168.10.1)</mark>

### Step 1: Configure Routing and Remote Access <a href="#id-5coha2cbl2bk" id="id-5coha2cbl2bk"></a>

Open Server Manager and Add **Roles and Feature> Add Remote Access “RAS and Routing”**

### Step 2: Configure Routing and Remote Access <a href="#ndcy6iu8myc9" id="ndcy6iu8myc9"></a>

On the left pane, right-click on your local server and click **Configure and Enable Routing and Remote Access**.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FNP5oBeo6fmYbHkZOkkrd%2Fimage.png?alt=media&#x26;token=a7e814bb-bc29-4582-9ae4-f91f0dd5d50f" alt=""><figcaption></figcaption></figure>

In *Configure and Enable Routing and Remote Access Wizard*, select **Custom Configuration** radio button as we will manually configure the routing and access. Click *Next* button.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FvcERZruRlSZ3wvnAiYsm%2Fimage.png?alt=media&#x26;token=ffc45296-c516-45b2-b2c5-06083e7f9637" alt=""><figcaption></figcaption></figure>

Next, select **VPN Access** and **NAT** checkboxes and click next to see a summary of the selection.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FX6cu4LNwEQRxw2uiBVbZ%2Fimage.png?alt=media&#x26;token=d2b7a156-fbff-40da-9aef-974c9db31112" alt=""><figcaption></figcaption></figure>

Finally, on clicking *Finish* button, you will see a prompt to start the Routing and Remote Access Services. Click on the *Start Service* button.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FVQgdvk8utNe5xXM4MbuX%2Fimage.png?alt=media&#x26;token=467fcb83-8b76-4a0a-8b62-77140358b18d" alt=""><figcaption></figcaption></figure>

### **Step 3: Configure VPN Properties**

Now that we have our VPN running, let’s go ahead and configure it. Under the Routing and Remote Access window, on the left pane, right-click on your local server and click **Properties**.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FrK8YG2OS2OHEuDDDhDzJ%2Fimage.png?alt=media&#x26;token=4f9a91be-4714-4631-89e4-1d12e81d4bf1" alt=""><figcaption></figcaption></figure>

Navigate to the security tab and click on **Allow custom IPSec policy for L2TP/IKEv2 connection** and put a very long PSK(Pre-shared key). You can use any tool to generate a random key.&#x20;

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FF9AVdtkg9OMUQGLgmW1Y%2Fimage.png?alt=media&#x26;token=aab042dc-50b3-49d4-b4b7-8f4f9ba497a5" alt=""><figcaption></figcaption></figure>

**Make sure to note down the PSK as we will need to share the PSK with every user who wants to connect to the VPN server.**

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FCZjqqhDgqnUWBoy0lEYy%2Fimage.png?alt=media&#x26;token=b8c78488-829e-4c77-a63b-65e32faa6db5" alt=""><figcaption></figcaption></figure>

Now, go to *IPv4* tab and under IPv4 address assignment select static address pool. Click **Add** button and you will get a pop up to put IP address ranges. Put the starting address and ending address of the IP address range you want the users to assign to.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FIGnS2JYhpHACRO1I5BLA%2Fimage.png?alt=media&#x26;token=0edb879f-4ddc-40fb-b5e7-db47fe35af97" alt=""><figcaption></figcaption></figure>

Click the *OK* button to save the address range and finally click **OK** to save the changes. You may get a warning saying you need to restart the Routing and Remote Access for changes to apply, you can safely click *OK* and ignore it for now as we will restart the service after completing the next step. Take a screenshot of your range of IP addresses.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FOmjQTHslIaYh9U8XfAmZ%2Fimage.png?alt=media&#x26;token=61451bbf-7d35-4830-b74a-94b3779f2aae" alt=""><figcaption></figcaption></figure>

### **Step 4: Configure NAT**

On the same left pane of Routing and Remote Access window, expand your local server and then expand *IPv4*. You will see the NAT object there. Right-click on NAT and then click on *New Interface* option.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FNlprgVvNHN16tb44fDOR%2Fimage.png?alt=media&#x26;token=aac4a207-0439-4c68-b714-2ca61913cf83" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FJeHsUcw6X6oVfwMIHLb7%2Fimage.png?alt=media&#x26;token=3cf8a136-7a3c-405e-827a-3c8ba8481390" alt=""><figcaption></figcaption></figure>

Select **Ethernet** and click OK to proceed further. On the NAT tab, select *Public interface connected to Internet* radio button and also select *Enable NAT on this interface* checkbox.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FnOVsU9HHbIh4tI7LsjGr%2Fimage.png?alt=media&#x26;token=388bd9e9-0dbc-4f50-b400-c41c53952dbc" alt=""><figcaption></figcaption></figure>

Now, go to *Services and Ports* tab and select *VPN Server(L2TP/IPSec – running on this server)* checkbox. It will open up a new interface for editing the service. Take a screenshot

Change the private address from **0.0.0.0** to **127.0.0.1** and click OK to save.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FIBCNpchThB8NIn84rWSH%2Fimage.png?alt=media&#x26;token=bbf75ea3-141e-493b-bbdc-ad57d58b9343" alt=""><figcaption></figcaption></figure>

Finally, Click OK to save the NAT interface.

### **Step 5: Restart Routing and Remote Access**

On the left pane of the Routing and Remote Access window, right-click on your local server and click on *Restart* under *All Tasks*.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FNejmchWfoYdjFaY0uFG1%2Fimage.png?alt=media&#x26;token=ab51a208-f94b-405b-9749-82ef876b52b4" alt=""><figcaption></figcaption></figure>

This will restart the Routing and Remote Access services and all the changes we have made will be applied.

### **Step 6: Configure Windows Firewall**

On the start menu, search for Windows defender firewall and open it. Click on *Advanced settings* on the windows defender firewall.

![windows defender firewall](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FujMJEaJbqmbhwuw0Kh6P%2F12.png?alt=media)

Under *Advanced setting*, click on *Inbound Rules* on the left pane and then click on *New Rule* on right side pane.

![new rule windows defender firewall](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F8pZBIS4CF4i1vnMsKJ7S%2F13.png?alt=media)

Windows Server 2019 has predefined rules which we need to enable for VPN to work. In *New Inbound Rule Wizard* click on *Predefined* radio button and select the *Routing and Remote Access* from the drop-down.

![advanced security windows defender firewall](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F81Gx5Dv8M1VxB0s3Zf97%2F14.png?alt=media)

Under Predefined Rules select *Routing and Remote Access(L2TP-In)* checkbox and click *Next*.

![new inbound firewall wizard](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FMv5WVSYCtJunwedmWGA7%2F15.png?alt=media)

Under *Action* select, the option *Allow the connection* and click *Finish*.

![windows defender firewall allow connection](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FC4Kbv1ONYXhbkqGcuUym%2F16.png?alt=media)

The firewall is now configured to allow inbound traffic on UDP port 1701.

### **Step 7: Create VPN User**

Search for *Computer Management* in the start menu and under *Computer Management* window expand *Local users and group*.

Right-click on *Users* and click on *New User* under *Local users and group* to create a new user.

![create new user](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FdUbTYHeBNupYG5linak5%2F17.png?alt=media)

On *New User* prompt, provide a username, full name, and strong password. Uncheck *User must change the password on next login* checkbox. Click **Create** to create a new user. Take a screenshot

![computer management](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2F6SWT3mx6pIvtDg3Qp2iQ%2F18.png?alt=media)

Once the user is created, return to the Computer *Management* interface and you will find the user which you have just created in the list of users. Right-click on the user and click the Properties option.

![computer management properties](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FdSiSAtl0J0ayMJdPCSl0%2F19.png?alt=media)

On your VPN users properties, navigate to *Dial-in* tab. Now, select *Allow access* option for *Network Access Permissions* setting. Click OK to save the properties. Take a screenshot

![computer management permission](https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2Fh088GUnroSWdMCeGtBWN%2F20.png?alt=media)

Our L2TP/IPSec VPN server is now ready and can accept the connections.

### **Step 8: Connecting VPN Client**

You will need to share the PSK and Windows username and password to the user who wishes to connect to the remote VPN server. Create a VPN connection L2TP on windows and enter the key under the security tab for your connection.&#x20;

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FKXPctQiAoQgwkmAMRIjh%2Fimage.png?alt=media&#x26;token=3ad0f4ee-1e89-4276-afa3-4df45ad970c8" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2FAAI8iIkMbp3HDLEQomZ5%2Fimage.png?alt=media&#x26;token=cfaa84d8-459d-4b19-9ea9-fb216ff82c5c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2Fbrc6QULrloeuVOInz0oT%2Fimage.png?alt=media&#x26;token=0559cc78-89ee-49fe-992d-b00e0c58665d" alt=""><figcaption></figcaption></figure>

### **Step 9: Monitoring VPN**

Search for *Remote Access Management Console* in the start menu and open the console. You should see the status of the VPN. If you have followed the tutorial correctly, you will see all green checkmark on all services. You can also view the details of connected clients on this console.

<figure><img src="https://2438328698-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPf7CIJDZ869PqrsNNvPr%2Fuploads%2Fh6iSVnxgPWPmNklas6n4%2Fimage.png?alt=media&#x26;token=51754c86-1977-4426-95c4-140dc01bc5bf" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://talebi.gitbook.io/windows-server/vpn/vpn-l2tp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
