> For the complete documentation index, see [llms.txt](https://docs.plenit.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.plenit.com/docs-en/productos/servers/how-to/how-to-configure-wireguard-for-multiple-vpn-connections.md).

# How to Configure WireGuard for Multiple VPN Connections from a Private Network

When multiple users connect from the same private network behind NAT, **L2TP only supports one concurrent session**.

In this guide you install **WireGuard**, an encrypted-tunnel VPN, to accept multiple clients at once without exposing them to the Internet.

> #### 👍 What you get
>
> A WireGuard server in your subscription accepting multiple simultaneous connections from a private network, with the port open in the Plenit firewall.

### Why WireGuard

L2TP behind NAT collapses all connections from the same public network into a single session. WireGuard works over UDP and treats **each client as an independent peer** with its own key pair, so multiple users on the same network connect without interfering with one another.

The key model is like SSH: each end has a private key (which it keeps) and a public key (which it shares with the other side).

### Before you begin

* Log in to the Plenit platform with an active organization.
* Have a subscription of **Servers** or **Remote Desktop** with a Linux server.
* Have the client machine ready where you will install WireGuard.

### Step 1. Install WireGuard on the Linux server

Installation varies depending on the distribution. On CentOS, as root user:

```bash
yum install yum-utils epel-release
yum-config-manager --setopt=centosplus.includepkgs=kernel-plus --enablerepo=centosplus --save
sed -e 's/^DEFAULTKERNEL=kernel$/DEFAULTKERNEL=kernel-plus/' -i /etc/sysconfig/kernel
yum install kernel-plus wireguard-tools
reboot
```

On Ubuntu, the base command is:

```bash
sudo apt install wireguard
```

Generate the server key pair: the private key stays on the server and the public key will be used by the clients.

```bash
wg genkey | tee server_private.key | wg pubkey > server_public.key
```

### Step 2. Install the client

In this example the client is Windows. Download the installer from the WireGuard website and run it as administrator. If the main installer fails, use the Windows client MSI package.

{/\* 📸 CAPTURE 1 · WireGuard window after installation on the client \*/}

![WireGuard installation completed on the client machine](https://reemplaza-url/servidores-howto-wireguard-01.png)

### Step 3. Create the tunnel on the client

With WireGuard open, click **Add Tunnel → Add empty tunnel…**. The client generates its key pair and shows an initial configuration that you complete with this structure:

```bash
[Interface]
PrivateKey = <CLIENT_PRIVATE_KEY>
Address = 10.0.0.2/32
DNS = 192.168.1.1

[Peer]
PublicKey = <SERVER_PUBLIC_KEY>
AllowedIPs = 0.0.0.0/0
Endpoint = <SERVER_PUBLIC_IP>:51820
```

| Field        | What it indicates                                                                                                       |
| ------------ | ----------------------------------------------------------------------------------------------------------------------- |
| `PrivateKey` | Client private key                                                                                                      |
| `Address`    | Client internal IP inside the tunnel (a private range, e.g. `10.0.0.2/32`)                                              |
| `DNS`        | Network DNS server                                                                                                      |
| `PublicKey`  | WireGuard server public key                                                                                             |
| `AllowedIPs` | What traffic is routed through the VPN. With `0.0.0.0/0` everything goes through; with a specific subnet, only that one |
| `Endpoint`   | Public IP and port of the server (UDP 51820)                                                                            |

{/\* 📸 CAPTURE 2 · tunnel configuration completed on the client \*/}

![Final tunnel configuration on the client](https://reemplaza-url/servidores-howto-wireguard-02.png)

### Step 4. Register the client on the server

The server only lets through the clients it knows. Add the client to the `[Peer]` section of the server configuration, or on the fly with:

```bash
wg set wg0 peer <CLIENT_PUBLIC_KEY> allowed-ips <CLIENT_INTERNAL_IP>
```

Where `<CLIENT_PUBLIC_KEY>` is the key generated by the client and `<CLIENT_INTERNAL_IP>` the internal IP it will use in the tunnel (the same `Address` from Step 3).

### Step 5. Open the port in the Plenit firewall

WireGuard listens on **UDP 51820**. Without that port open, the client will not connect even if the tunnel is configured correctly. In the Servers subscription, click **New rule** and configure it:

1. Select the network through which the service connects.
2. Define the source of the connections. If possible, filter the allowed IPs instead of opening it to all of them.
3. Protocol **UDP**.
4. Public IP through which WireGuard connects.
5. Public port **51820**.
6. Corresponding private IP and port.

{/\* 📸 CAPTURE 3 · firewall rule with UDP protocol and port 51820 \*/}

![Firewall rule for WireGuard UDP port 51820](https://reemplaza-url/servidores-howto-wireguard-03.png)

> #### 👍 Filter the source whenever you can
>
> Restricting source IPs in the rule reduces exposure compared to leaving the port open to the entire Internet.

### Step 6. Verify the connection

Activate the tunnel on the client. On the server, confirm that there is a handshake with each peer:

```shell
wg show
```

A `latest handshake` recent and counters of `transfer` that increase indicate that the tunnel is active. From the client, also check that you are exiting with the server's public IP.

If it doesn't come up, check:

* The server and client public keys are correctly exchanged.
* The client is registered on the server (section `[Peer]` or `wg set`).
* The Plenit firewall allows **UDP 51820**.
* The `Endpoint` points to the correct public IP of the server.

### Limitations and security

* This guide solves the L2TP session limit when several users share a private network behind NAT.
* WireGuard is not enough to just install it: each client must be registered on the server and UDP port 51820 opened.
* With `AllowedIPs = 0.0.0.0/0`, all client traffic goes through the VPN.
* Filtering the source in the firewall reduces the exposure surface.

### Conclusion

With WireGuard deployed, a private network behind NAT is no longer limited to a single session: each user connects as their own peer.

The key to the deployment is three pieces that must fit together: the keys correctly exchanged between client and server, the peer registration on the server, and UDP port 51820 open. To add more clients, repeat the tunnel setup on the client (Step 3) and its registration on the server (Step 4).

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.plenit.com/docs-en/productos/servers/how-to/how-to-configure-wireguard-for-multiple-vpn-connections.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
