> This is part 1 of 2 of the full documentation (pages 1–100 of 200).
> The content is paginated: fetch every part to see all of it.
> Next part: https://docs.pritunl.com/kb/llms-full.txt/1
> Page index: https://docs.pritunl.com/kb/llms.txt

> Agents can also search and read this documentation through its [MCP server](https://docs.pritunl.com/kb/~gitbook/mcp).

# 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
This site has an agentic ask interface you may use to query the documentation dynamically by asking a question.

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

```
GET https://docs.pritunl.com/kb/index.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.

---

# Pritunl Documentation

![](https://4081911837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxwsRNY57JB88wGOcyVKP%2Fuploads%2Fgit-blob-bffe4da6ec8c8d3c41bd0fc8c0cde39ac457b5b3%2Flogo_code.png?alt=media)

Welcome to the Pritunl documentation. Use the links below to view the documentation for each product.

### Product Documentation

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><mark style="color:orange;"><strong>Pritunl VPN</strong></mark></td><td>VPN Server Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/vpn/">Pritunl VPN</a></td></tr><tr><td><mark style="color:$primary;"><strong>Pritunl Zero</strong></mark></td><td>Zero Trust Server Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/zero/">Pritunl Zero</a></td></tr><tr><td><mark style="color:purple;"><strong>Pritunl Cloud</strong></mark></td><td>Self Hosted Declarative Virtualization Platform Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/cloud/">Pritunl Cloud</a></td></tr></tbody></table>

### Open Source Tools

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><mark style="color:$primary;"><strong>Pritunl Boot</strong></mark></td><td>Interactive web based iPXE Linux distribution installer</td><td></td><td></td><td><a href="https://boot.pritunl.com/">https://boot.pritunl.com/</a></td></tr><tr><td><mark style="color:$primary;"><strong>lsync</strong></mark></td><td>Python based live file syncing to remote hosts using rsync and inotifywait</td><td></td><td></td><td><a href="https://github.com/pritunl/toolbox/tree/master/lsync">https://github.com/pritunl/toolbox/tree/master/lsync</a></td></tr><tr><td><mark style="color:$primary;"><strong>s3c</strong></mark></td><td>Lightweight Python based S3 client inside a single file</td><td></td><td></td><td><a href="https://github.com/pritunl/toolbox/tree/master/s3c">https://github.com/pritunl/toolbox/tree/master/s3c</a></td></tr></tbody></table>

### Legacy Documentation

The documentation was recently upgraded, the legacy documentation will remain available at the location below.

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Legacy Documentation</strong></td><td><a href="https://docs.pritunl.com/docs">https://docs.pritunl.com/docs</a></td></tr></tbody></table>


# Pritunl VPN Documentation

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FfpgpMUSNUtc2WSBrb8Vn%2Flogo_code.png?alt=media\&token=18e814e6-28f9-4bf2-927f-2e21960bba1e)

Welcome to the [**Pritunl Enterprise VPN**](https://pritunl.com/) server documentation. Use the links below to get started with the Pritunl VPN server or view documentation for other Pritunl products.

### Product Specific Documentation

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Pritunl VPN</strong></td><td>VPN Server Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/vpn/getting-started/getting-started">Getting Started</a></td></tr><tr><td><strong>Pritunl Zero</strong></td><td>Zero Trust Server Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/zero/">Pritunl Zero</a></td></tr><tr><td><strong>Pritunl Cloud</strong></td><td>Self Hosted Declarative Virtualization Platform Documentation</td><td></td><td></td><td><a href="https://docs.pritunl.com/kb/cloud/">Pritunl Cloud</a></td></tr></tbody></table>

### Legacy Documentation

The documentation was recently upgraded, the legacy documentation will remain available at the location below.

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Legacy Documentation</strong></td><td><a href="https://docs.pritunl.com/docs">https://docs.pritunl.com/docs</a></td></tr></tbody></table>


# Current Issues

Top current issues with Pritunl

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FfpgpMUSNUtc2WSBrb8Vn%2Flogo_code.png?alt=media\&token=18e814e6-28f9-4bf2-927f-2e21960bba1e)

## Current Issues

If you are having issues with your Pritunl server review the list of current issues below. For new installations go to the [**Getting Started**](https://docs.pritunl.com/kb/vpn/getting-started/getting-started) page.

#### Azure Entra and Google Workspace Groups Migration

Newer versions of Pritunl by default will only accept Google Workspace groups created by administrators and Azure Entra security enabled groups. If an update caused your groups to not be recognized or users are being added to the wrong organization the commands below will need to be used. There is no option to convert existing groups.

```shellscript
sudo pritunl set app.sso_azure_security_groups_only false
sudo pritunl set app.sso_google_admin_groups_only false
```

Once this is done it is also recommended to disable non-administrators from creating groups so that employees in the company cannot create groups themselves to obtain access to a different organization.

For Google Workspaces open Apps -> Google Workspace -> Settings for Groups for Business -> Sharing Settings. Then select *Only organization admins can create groups*.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FCLsvn1T354vgamkbSbjF%2Fgoogle_groups_permissions.png?alt=media&amp;token=5322d4eb-5da2-42bb-be82-27b25bf0988f" alt=""><figcaption></figcaption></figure>

For Azure Entra open Microsoft Entra ID then select Manage -> Groups -> Settings -> General. Then set the *Security Groups* and *Microsoft 365 Groups* options to no.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FpVt53cPs6xl2PbjViiYX%2Fazure_groups_permissions.png?alt=media&amp;token=868ad2c6-d264-4076-b636-839f86550000" alt=""><figcaption></figcaption></figure>

#### Azure AD Graph Migration

[**Azure AD Graph Migration**](https://docs.pritunl.com/kb/vpn/sso/azure-ad-migration) will need to be completed for all Azure configurations. Connection errors will start occurring on configurations that have not completed the migration.

#### Debugging Information

The [**Client Debugging**](https://github.com/pritunl/pritunl-docs/blob/master/debugging/client.md) and [**Server Debugging**](https://github.com/pritunl/pritunl-docs/blob/master/debugging/server.md) documentation has detailed information on debugging the software.

#### EPEL OpenVPN Issue

There is currently an issue with the compilation options used on the OpenVPN package in the EPEL repository. This issue will cause routing issues on some connections. To fix this issue run the command below to install the newer OpenVPN package from the Pritunl repository. This issue will only occur on UDP servers, TCP can also be used as a workaround.

The `pritunl-openvpn` package is only available on the Pritunl RHEL based repositories and will provide the latest version of OpenVPN.

```shell
sudo yum swap openvpn pritunl-openvpn
```

```shell
sudo yum --allowerasing install pritunl-openvpn
```

This can be reverted by running the command below.

```shell
sudo yum --allowerasing install openvpn
```

#### CentOS Discontinued

CentOS was discontinued and the operating system will no longer be updated. The Pritunl repositories for CentOS were also discontinued. The [**Oracle Linux Repositories**](https://github.com/pritunl/pritunl-docs/blob/master/repositories.md) are fully compatible with CentOS. These can be used to recieve updates for Pritunl. To continue getting system updates the system must be switched to Oracle Linux. Oracle providers a script to [**upgrade CentOS to Oracle Linux**](https://linux.oracle.com/switch/centos/) that will convert an existing CentOS system to Oracle Linux.

#### Connection MTU Issues

Some connections may have MTU issues this can be fixed by entering a lower MSS Fix value in the server settings. First test 1200 or lower to confirm that it is an MTU issue. If this fixes the connection increase the MTU in a range of 1200-1400 to find a working MTU.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fa4nFjkypEmfzJP9xOdHM%2Fmss_fix.png?alt=media\&token=25b265dc-d839-4fcb-a841-5ed3bd9e96fd)

#### Carrier-Grade NAT

Carrier-grade NATs are becoming more common to mitigate IPv4 address exhaustion. These are common with all cellular connections and wired ISP connections in foreign countries with limited IPv4 address space. These can cause issues with MTU detection and UDP VPN servers. Switching the server protocol to TCP with a lower MTU may fix issues when a carrier-grade NAT is present.

#### iOS DNS Issue

There are currently three fixes for the DNS issue on iOS.

Add the DNS server to the server routes. The default DNS server used is `8.8.8.8` add the route `8.8.8.8/32` to the server routes for this configuration.

Remove the DNS server from the settings. This will instruct the client to use their current DNS configuration. This could cause problems with some clients if that DNS configuration becomes unroutable due to the VPN routes.

Enable *VPN Client DNS Mapping* in the advanced server settings. This will start a DNS server on the Pritunl server that will proxy all DNS requests and will always be available to the client.

### Ubuntu Update Issue

If Ubuntu 20.04 is configured with the Ubuntu 18.04 Pritunl repository the error `ModuleNotFoundError: No module named 'encodings'` will be shown when attempting to start Pritunl. This can be fixed by running the commands below to update the repository files to the correct distribution.

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb http://repo.pritunl.com/stable/apt focal main
EOF

sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list << EOF
deb https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse
EOF

wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

sudo apt update
sudo apt upgrade
```

### Lets Encrypt Root Certificate Issue

Due to the Oct 1st expiration of the Lets Encrypt root certificate all v1.29 versions of Pritunl containing the expired certificate will no longer produce a valid certificate. Having an invalid certificate will not disrupt VPN service. The primary issue will occur when a user attempts to import a new profile to the Pritunl Client. Both the Pritunl Client and Pritunl Server need to be updating to the latest releases containing the new root certificates to fix this issue.

The issue can easily be avoided by clicking *Download Profiles* on the profile page then importing the tar file into the Pritunl Client by click *Import Profile*, this is the same profile data that would be imported with a URI. The issue can also be avoided by replacing the domain name in the URI with the IP address of the server. The client will ignore certificate validation for URI's containing an IP address.


# Repositories

Pritunl repositories

Below are all the repositories Pritunl software is published on. Not all Pritunl packages are available on all distributions.

### Repositories

{% tabs %}
{% tab title="AlamLinux 10" %}

```shell
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AlmaLinux 9" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AlmaLinux 8" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/8/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Arch Linux" %}

```sh
sudo tee -a /etc/pacman.conf << EOF
[pritunl]
Server = https://repo.pritunl.com/stable/pacman
EOF

sudo pacman-key --keyserver hkp://keyserver.ubuntu.com -r 7568D9BB55FF9E5287D586017AE645C0CF8E292A
sudo pacman-key --lsign-key 7568D9BB55FF9E5287D586017AE645C0CF8E292A
sudo pacman -Sy
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="AmazonLinux 2023" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/amazonlinux/2023/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AmazonLinux 2" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/amazonlinux/2/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Debian 13" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt trixie main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Debian 12" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt bookworm main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Debian 11" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt bullseye main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Fedora 43" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/fedora/43/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Fedora 42" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/fedora/42/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Fedora 41" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/fedora/41/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Oracle Linux 10" %}

```shell
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 9" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 8" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/8/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 7" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/7/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Ubuntu 25.10" %}

```shell
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt questing main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 25.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt plucky main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 24.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt noble main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 22.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt jammy main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 20.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb http://repo.pritunl.com/stable/apt focal main
EOF

sudo apt --assume-yes install gnupg
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A | sudo tee /etc/apt/trusted.gpg.d/pritunl.asc
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 18.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb https://repo.pritunl.com/stable/apt bionic main
EOF

sudo apt --assume-yes install gnupg
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A | sudo tee /etc/apt/trusted.gpg.d/pritunl.asc
sudo apt update
```

{% endtab %}
{% endtabs %}

Below are the unstable repositories where packages are staged for testing before being transferred to the stable repositories.

### Unstable Repositories

{% tabs %}
{% tab title="AlmaLinux 10" %}

```shell
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/almalinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AlmaLinux 9" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/almalinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AlmaLinux 8" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/almalinux/8/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Arch Linux" %}

```sh
sudo tee -a /etc/pacman.conf << EOF
[pritunl]
Server = https://repo.pritunl.com/unstable/pacman
EOF

sudo pacman-key --keyserver hkp://keyserver.ubuntu.com -r 7568D9BB55FF9E5287D586017AE645C0CF8E292A
sudo pacman-key --lsign-key 7568D9BB55FF9E5287D586017AE645C0CF8E292A
sudo pacman -Sy
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="AmazonLinux 2023" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/amazonlinux/2023/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="AmazonLinux 2" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/amazonlinux/2/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Debian 13" %}

```shell
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt trixie main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Debian 12" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt bookworm main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Debian 11" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt bullseye main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Fedora 43" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/unstable/yum/fedora/43/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Fedora 42" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/unstable/yum/fedora/42/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Fedora 41" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/unstable/yum/fedora/41/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Oracle Linux 10" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/oraclelinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 9" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/oraclelinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 8" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/oraclelinux/8/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}

{% tab title="Oracle Linux 7" %}

```sh
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/unstable/yum/oraclelinux/7/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Ubuntu 25.10" %}

```shell
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt questing main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 25.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt plucky main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 24.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt noble main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 22.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/unstable/apt noble main
EOF

sudo apt --assume-yes install gnupg
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 20.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb http://repo.pritunl.com/unstable/apt focal main
EOF

sudo apt --assume-yes install gnupg
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A | sudo tee /etc/apt/trusted.gpg.d/pritunl.asc
sudo apt update
```

{% endtab %}

{% tab title="Ubuntu 18.04" %}

```sh
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb https://repo.pritunl.com/unstable/apt bionic main
EOF

sudo apt --assume-yes install gnupg
gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A | sudo tee /etc/apt/trusted.gpg.d/pritunl.asc
sudo apt update
```

{% endtab %}
{% endtabs %}


# Outage

Pritunl Server Outage Mode

Pritunl server versions since v1.32.4465.96 have the ability to continue functioning with a full outage of all third party services including the Pritunl application servers and single sign-on services. By default the subscription will remain cached and active for several days. If the server was upgraded to v1.32.4465.96 or later it will retain the subscription even if the host is restarted. Updating the server after the outage has started will require reaching the license server before working.

### Single Sign-On Outage

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FJjzj7YSdfpwweOjP0z3a%2Fpritunl_sso_bypass.png?alt=media&amp;token=6027c98d-5e12-47b4-bbd4-5341dbe1bb6d" alt="" width="221"><figcaption></figcaption></figure>

The *Bypass Single Sign-On* mode in the server settings will allow users to connect without any validation from the single sign-on provider. This can only be enabled if *Device Authentication* is also enabled, this will allow the system to maintain a high level of authorization during the outage.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F0tQKyHewzUqn7WmGpzNI%2Fdevice_auth1.png?alt=media&amp;token=d33ea5cf-8180-4e72-9a86-d1a692aeb379" alt="" width="456"><figcaption></figcaption></figure>

Once this is done users will be shown the prompt above when connecting and will need to provide this code to an administrator. The administrator can then find the device in the Pritunl web console either in the dashboard under *Devices Pending Registration* or if there are a large number of pending devices the user can be searched from the *Users* tab and the pending approval will be shown under the right drop down menu for that user. After the device has been approved they will be able to connect without requiring any third party services.


# Getting Started

Getting started with Pritunl

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FfpgpMUSNUtc2WSBrb8Vn%2Flogo_code.png?alt=media\&token=18e814e6-28f9-4bf2-927f-2e21960bba1e)

Installing Pritunl requires only a MongoDB database and no registration is needed to use the free version of Pritunl. To get started using Pritunl follow the sections in [installation](https://docs.pritunl.com/kb/vpn/getting-started/installation).


# Install Pritunl Server

Install and configure Pritunl

Below are several methods available for installing Pritunl.

### OpenVPN Authentication Errors

Newer OpenVPN clients may send the password in an encoded format. This format will not be recognized by the Pritunl server resulting in authentication errors. This issue has been fixed in an update and can be fixed by updating to the latest Pritunl package.

### SELinux Support

Pritunl includes full SELinux polices which cover both the main `pritunl` process and the isolated `pritunl-web` web server process. Running Pritunl with a Linux distribution that supports SELinux will significantly improve security. It is recommend to only use AlmaLinux, Rocky Linux or Red Hat Enterprise Linux for Pritunl servers. The first log message shown when the Pritunl server is started will indicate the SELinux context. It should look similar to the log message below, if it is none or unconfined the SELinux policy is not functioning.

```shell
[pritunl0][2018-12-16 07:45:03,406][INFO] Starting server
  selinux_context = "system_u:system_r:pritunl_t:s0"
```

### AlmaLinux

All development and testing of Pritunl software is done on Alma Linux and it is the recommended distribution to use for Pritunl software. It will provide the highest level of compatibility, reliability and security. If AlmaLinux isn't available Rocky Linux can be used which will provide good compatibility and full support for the SELinux profiles.

### Enterprise Clusters

If you intend on creating a Pritunl cluster with multiple hosts all the hosts will need to connect to the same MongoDB database. For cluster configurations it is best to have a dedicated server that is not running Pritunl for the MongoDB database. Single host configurations can run MongoDB with Pritunl on the same server.

### Recommended Instance Types

For the MongoDB database instances with high memory should be used. For Pritunl nodes high CPU with high base clock speeds are best, these are typically the AMD (C7a, C6a) instance types. For large deployments several small nodes with fewer connections per node is better then fewer larger nodes with more connections per node. For the best performance it is recommended to spend $0.50-$1.00 per concurrent connection each month on server costs. More information on AWS recommendations can be found in the [**Scaling**](https://docs.pritunl.com/kb/vpn/system/scaling) documentation.

### \[AWS] Amazon Linux Install

**Pritunl has full support and dedicated builds for Amazon Linux but support for the Pritunl SELinux profiles are only available on 1:1 RHEL distributions such as AlmaLinux or Rocky Linux. To install Pritunl with AlmaLinux on AWS refer to the next section.**

The AWS community AMI and marketplace sections contain public images that can be uploaded without any verification. These sections contain several packages with names containing Pritunl. Using these unverified images could compromise the security of the installation. Pritunl does not publish any AMIs or marketplace images.

After creating the EC2 instance SSH to the server with the username `ec2-user` and run the commands below to install Pritunl and MongoDB.

```shell
sudo tee /etc/yum.repos.d/mongodb-org.repo << EOF
[mongodb-org]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2023/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
EOF

sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/amazonlinux/2023/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update

sudo dnf -y install pritunl pritunl-openvpn wireguard-tools mongodb-org
sudo systemctl enable mongod pritunl
sudo systemctl start mongod pritunl
```

### \[AWS] AlmaLinux Install

Using AlmaLinux on AWS provides the benefit of supporting the SELinux profiles packaged with Pritunl. These SELinux policies help isolate the Pritunl web server process and provide better exploit protection. AlmaLinux is available for free in the AWS Marketplace labeled *AlmaLinux OS 9*.

```shell
sudo tee /etc/yum.repos.d/mongodb-org.repo << EOF
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
EOF

sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update

sudo dnf -y remove iptables-services
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service

sudo dnf -y install pritunl pritunl-openvpn wireguard-tools mongodb-org
sudo systemctl enable mongod pritunl
sudo systemctl start mongod pritunl
```

### \[Other Providers] AlmaLinux/Rocky Linux/RHEL

Run the commands below to install Pritunl on any other provider with AlmaLinux 9 or any other RHEL based distribution.

```shell
sudo tee /etc/yum.repos.d/mongodb-org.repo << EOF
[mongodb-org-8.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/9/mongodb-org/8.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://pgp.mongodb.com/server-8.0.asc
EOF

sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/9/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update

sudo dnf -y remove iptables-services
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service

sudo dnf -y install pritunl pritunl-openvpn wireguard-tools mongodb-org
sudo systemctl enable mongod pritunl
sudo systemctl start mongod pritunl
```

### \[Other Providers] Ubuntu 24.04

**Older versions of Ubuntu have encountered issues with outdated OpenVPN builds. The Pritunl repository provides continuous testing and updates only for RHEL distributions to ensure future support. Future support with Ubuntu installations is not tested or guaranteed.**

Run the commands below to install Pritunl on any other provider with Ubuntu 24.04

```shell
sudo tee /etc/apt/sources.list.d/mongodb-org.list << EOF
deb [ signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse
EOF

sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable noble main
EOF

sudo tee /etc/apt/sources.list.d/pritunl.list << EOF
deb [ signed-by=/usr/share/keyrings/pritunl.gpg ] https://repo.pritunl.com/stable/apt noble main
EOF

sudo apt --assume-yes install gnupg

curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg --dearmor --yes
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc | sudo gpg -o /usr/share/keyrings/pritunl.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install pritunl openvpn mongodb-org wireguard wireguard-tools

sudo ufw disable

sudo systemctl start pritunl mongod
sudo systemctl enable pritunl mongod
```

### OpenVPN Update

The Pritunl RHEL repositories provide the `pritunl-openvpn` package that replaces the `openvpn` package from the EPEL. This package provides a newer version of OpenVPN than is available on the EPEL. This package is currently required on RHEL distributions such as AlmaLinux due to the issue explained in [**RHEL Connection Fix**](https://docs.pritunl.com/kb/vpn/system/rhel-connection-fix). The command below will install the `pritunl-openvpn` package and replace the existing `openvpn` package.

```shell
sudo yum swap openvpn pritunl-openvpn
```

```shell
sudo yum --allowerasing install pritunl-openvpn
```

### Linux Repositories

Pritunl is packaged for several Linux distributions. All available distributions can be found on the [**Repositories**](https://docs.pritunl.com/kb/vpn/repositories) page.

### Configuration

[**Continue to Configuration**](https://docs.pritunl.com/kb/vpn/getting-started/configuration)


# Configuration

Initial configuration of Pritunl

### Increase Open File Limit

Run the commands below to increase the open file limit on the server. This will prevent connections issues on servers with high load. This should also be done on the MongoDB server. Use the command ``sudo lsof -p `pgrep pritunl-web` | wc -l`` to check the file count for the Pritunl web server.

```sh
sudo sh -c 'echo "* hard nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "* soft nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "root hard nofile 64000" >> /etc/security/limits.conf'
sudo sh -c 'echo "root soft nofile 64000" >> /etc/security/limits.conf'
```

### Routing on AWS and Google Cloud

Many Pritunl configurations will require the instances to route traffic to different networks. By default this will be blocked by the source/dest check (AWS) or fowarding option (Google) and should be disabled (AWS) or enabled (Google) to avoid issues. This can be done on AWS in the Network Interfaces panel in the EC2 dashboard. For Google Cloud the forwarding option can be found in the network options when creating the instance.

### Database Setup

When Pritunl starts for the first time a database setup prompt will be shown on the web server running on port 443. The database setup will prompt for a setup key and MongoDB URI. To get the setup key ssh on to the server and run the command `sudo pritunl setup-key` this will return the setup key. By default the MongoDB URI will be filled with the URI for the localhost MongoDB server. This should be left as it is when the MongoDB server is running on the same server as the Pritunl instance. For Enterprise clusters refer to the MongoDB documentation for [**Connection String URI Format**](https://docs.mongodb.org/manual/reference/connection-string/). Alternatively this can be set directly in the `/etc/pritunl.conf` file or using the cli command. More information on the cli command can be found in the [**Commands**](https://docs.pritunl.com/kb/vpn/system/commands) sections. Some MongoDB servers authenticate on the admin database and require the option `authSource=admin` to be included in the URI.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FI8XOf7m1dAxWkCqOFApU%2Fdatabase_setup0.png?alt=media\&token=09f0ab77-1066-49b3-98ba-4fd5924e0f4e)

### Database Security

If you are using SSL with MongoDB the ssl option must be added to the database uri. The ssl\_ca\_certs is also available for using a custom CA when connecting to the database. Below are examples using SSL.

```
mongodb://example.com/?ssl=true
mongodb://example.com/?ssl=true&ssl_ca_certs=/path/to/ca.pem
```

### Initial Setup

After the MongoDB database uri has been configured the web console will display the login dialog. The default username is **pritunl**, run `sudo pritunl default-password` to get the default password. After signing in the initial setup dialog will be shown. This will allow changing the username and password. The Pritunl servers public address will be automatically detected and should not need to be changed.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FFsPbdZEbIctGRJKkdpSV%2Fconfiguration1.png?alt=media\&token=554b9fa2-ebe4-4523-b7e3-e4c3441f5184)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FqRszAXJytSVzkWHXoI59%2Fconfiguration2.png?alt=media\&token=d3766ea1-9b8c-4bc2-ada0-8be323508886)

### LetsEncrypt Certificate

LetsEncrypt is a free service that allows getting a valid signed certificate automatically. This is done using port 80 on the Pritunl server to verify the domain ownership. The certificate will then automatically renew every 80 days. Before setting the LetsEncrypt domain the dns settings for the domain must point to the public ip address of the Pritunl server. If a firewall is used port 80 must be publicly open. For the certificate to be able to automatically renew the firewall and dns settings will need to be properly configured. After setting the LetsEncrypt domain the Pritunl server will generate a signed certificate and automatically restart the web server. The certificate will be configured on all the hosts in an Enterprise cluster.

### Changing Web Console Port

The web console server runs on port 443 by default. An additional web server runs on port 80 for LetsEncrypt verification and redirecting HTTP requests to HTTPS. The web console server port can be changed in the Settings inside the web console or by running the command `pritunl set app.server_port 443`. To disable the web server on port 80 run the command `pritunl set app.redirect_server false` this will also prevent the use of LetsEncrypt certificates. The web server that runs during the initial setup for Pritunl also uses port 443 this can be changed by modifying `/etc/pritunl.conf`.

### Security

For environments where high security is needed refer to the [**Securing Pritunl**](https://docs.pritunl.com/kb/vpn/security/securing-pritunl) and [**Securing MongoDB**](https://docs.pritunl.com/kb/vpn/security/securing-mongodb) sections.

### Enterprise Cluster Configuration

If you are creating a Pritunl cluster with multiple hosts first activate the license on the host configured above. Then repeat the database setup step above with each host. When a new host connects to the database all other hosts will automatically be aware of the new host. No additional configuration is needed.

### Connecting

[**Continue to Connecting**](https://docs.pritunl.com/kb/vpn/getting-started/connecting)


# Connecting

Connecting to a Pritunl vpn server

To get connected to a vpn server on Pritunl an organization, user and server must be created.

### Creating Organization and User

To create an organization click *Add Organization* from the *Organization* page in the web console. Then click *Add User* an email address and user pin can optionally be included.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fdbu1m4WTvo8nIZot3Ywl%2Fconnecting0.png?alt=media\&token=580e78f9-6897-4ea3-8c1b-d7680298be91)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FG0EPui3jIOLonPJBUvhD%2Fconnecting1.png?alt=media\&token=6f515ba5-8208-400f-b015-90deaa18a883)

### Creating Server

Once the organization and user have been created go to the *Servers* page and click *Add Server*. By default a random udp port and random vpn network will be selected. The network should not conflict with a local network on your client computer and also be large enough for all users that will be attached to the server. The dns server will automatically be set to Google's public dns server. Once the server is created click *Attach Organization* to and attach the organization created earlier to the server. Then click *Start Server* to start the vpn server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FcF1Zboeb8lXh5NW9n8eE%2Fconnecting2.png?alt=media\&token=c9de4021-3e2b-4c59-b9d3-74720bc3ec44)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F9BFglsPRDBbrGINEhikh%2Fconnecting3.png?alt=media\&token=9e0d6f33-9d7c-4575-90ad-c4d75f64d3d5)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FaNDtREGYqq0pxpnogEjd%2Fconnecting4.png?alt=media\&token=f5946ff5-7564-4b68-842b-fe413bc05a43)

### Configuring Server Routes

Server routes control what traffic will be tunneled over the vpn server. By default a server will include the `0.0.0.0/0` route. This route will tunnel all internet traffic over the vpn server. To only route a local network on the vpn server first remove the `0.0.0.0/0` route and click *Add Route* to add the local network route such as `192.168.0.0/24`.

### Downloading User Profile

After the server has been created the user profile can be downloaded on the *Users* page by clicking the download button or profile links button on the right side of a user. The profile can then be imported into the Pritunl client or any other OpenVPN client.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FSkssd6U8SzutYxAuaA0N%2Fconnecting5.png?alt=media\&token=c655ab61-4ede-48d7-bbc0-6d532382b99c)

### User Profile Links

Profile links allow downloading user profiles in different formats using temporary links. The uri link can be used to import the profile directly from the Pritunl client.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fmj5cJksXmkluaQoCs4q7%2Fconfiguration3.png?alt=media\&token=01865f14-66cd-4af2-ba85-b2d98680673e)

### Reporting Issues

If you are having issues refer to the [**Logging**](https://docs.pritunl.com/kb/vpn/system/logging) section. Issues can be report by emailing <contact@pritunl.com>

### Additional Tutorials

For more tutorials covering additional configurations refer to the [**Tutorials**](https://docs.pritunl.com/kb/vpn/tutorials/replicated-servers) section.


# MongoDB Atlas

Configure MongoDB Atlas for Pritunl

[**MongoDB Atlas**](https://www.mongodb.com/cloud/atlas) is a managed MongoDB database from [**MongoDB**](https://www.mongodb.com). This tutorial will explain configure MongoDB Atlas with VPC peering. This creates a reliable and secure MongoDB cluster with backups. [**The M0, M2 and M5 plans use shared RAM and have low connection limits, these plans should not be used for production systems.**](https://docs.atlas.mongodb.com/reference/free-shared-limitations/)

### MongoDB Atlas Cluster

From the [**MongoDB Cloud Manager**](https://cloud.mongodb.com) click *Build a New Cluster*. Name the cluster and select *MongoDB 3.6 with WiredTiger*. Choose the same provider and region as your Pritunl cluster.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FRDsOLGArqsC6OQ4RA6dt%2Fatlas0.png?alt=media\&token=e3d97b7f-ba52-41ce-9081-9065e6c9c66e)

Next from the *Security* tab click *Add New User*. Set the privileges to *readWrite* and set the database name. Then autogenerate a secure password.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FWLpDqK4KSCoX9TSyihbP%2Fatlas1.png?alt=media\&token=1d2a7644-0053-4edd-95d0-c83ab8e5deed)

From the *Peering* tab click *New Peering Connection*. Fill in the AWS account ID and VPC information.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FPG32FOxAlM7BN6BHSc85%2Fatlas2.png?alt=media\&token=25e63cf6-ced3-4a69-9991-d782180ddb68)

Once done open the AWS VPC dashboard and right click the VPC and select *Edit DNS Resolution*. Then select *Yes* and save.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FKK1boo9wykLBKlN4WfJW%2Fatlas3.png?alt=media\&token=7e50518f-fb0c-4b54-bf43-206088e07315)

Right click the VPC and select *Edit DNS Hostnames*. Then select *Yes* and save.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FDATggLOMOdivHteD63o5%2Fatlas4.png?alt=media\&token=09a4f42d-b676-4758-bbdb-bec01c1c5ec3)

From the VPC dashboard click *Peering Connections* on the right. Then accept the pending peering connection from MongoDB.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FPyMQXkLQeLwnjvj7S62A%2Fatlas5.png?alt=media\&token=f2519b1d-7ab6-49e2-a9eb-13d9888e8f7f)

Once done the VPC peering connection should be established.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FG4wJJud1MpwvgZAsyZc1%2Fatlas6.png?alt=media\&token=0673e41b-425c-4f45-80d8-ca17fa1834f1)

Click *Route Tables* on the right and edit the routing table for the VPC. Add the Atlas CIDR block from the steps above as the *Destination* then select the pcx peering connection as the *Target*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAk3rpAmnm6vA5jsEjQsk%2Fatlas7.png?alt=media\&token=be2d3bfa-08bc-4eb0-81ea-8438118034be)

From the MongoDB Atlas manager select the cluster and get the MongoDB 3.4 URI. Replace the password with the generated password from earlier and copy this URI to the Pritunl settings.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fo5wKx786hmgFMwMUPN8A%2Fatlas8.png?alt=media\&token=deebfffb-b2e8-46ea-87f7-fd6d3fc3cf35)


# WireGuard

Configure WireGuard server

[**WireGuard**](https://www.wireguard.com/) connections have the same features as an [**OpenVPN**](https://openvpn.net/) connection, this includes:

* Client automatic failover (approximately 13 seconds after server failure)
* Replicated servers
* Client to client traffic across replicated servers
* Static client IP addresses
* NAT and non-NAT routing configurations
* All secondary authentication methods
* Client port forwarding
* Client DNS mapping
* Automatic client DNS configuration
* Routed client network links also know as an iroute
* IPv6 support
* Client access to linked servers (site-to-site link connections will continue to use [**OpenVPN**](https://openvpn.net/))

### Authentication

[**WireGuard**](https://www.wireguard.com/) authentication in Pritunl utilizes keys already in the client profile. This allows transitioning to [**WireGuard**](https://www.wireguard.com/) without requiring users to re-import their profile. Many administrators do not configure a valid HTTPS certificate and HTTPS is not relied on or required to provide secure authentication. Authentication is done with three keys providing multiple layers of encryption and authorization.

* **Client SHA512-HMAC Key (Authorization)**\
  The client will use a SHA512-HMAC secret to sign each connection request. The server will also use this secret to sign the response allowing the client to verify the connection response. This is the same authentication system used to authorize the client configuration sync which syncs profile configuration changes such as host addresses and server port changes (private keys are never synced).
* **Client/Server NaCl Asymmetric Key (Authorization + Encryption)**\
  The client utilizes a [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key for the server that is included in the client profile. This provides asymmetric encryption of the connection request from the client to the server. The server will encrypt the response with the clients [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key providing encryption of the response. The client will also verify the server response using the server [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key. This is the same authentication system used to provide the additional layer of encryption and authorization available in [**OpenVPN**](https://openvpn.net/) connections with passwords and two-factor codes.
* **Client RSA-4096 Asymmetric Key (Authorization)**\
  The clients RSA certificate and key is used to sign each connection request. The server will use this verify the client connection request. This is the same certificate used to verify [**OpenVPN**](https://openvpn.net/) connections.

Each [**WireGuard**](https://www.wireguard.com/) connection uses a new [**WireGuard**](https://www.wireguard.com/) key. This is done to provide the highest level of security but it will delay network connectivity when the user returns to a computer that has been asleep. The [**WireGuard**](https://www.wireguard.com/) private key is stored in the memory of the Pritunl client background service and also in the [**WireGuard**](https://www.wireguard.com/) configuration file. [**WireGuard**](https://www.wireguard.com/) uses a connection-less design and this private key could be used by an attacker to hijack the connection even if multi-factor authentication is used. In high security environments it is important to consider that [**OpenVPN**](https://openvpn.net/) connections with multi-factor authentication will not have these weaknesses. For this reason the server will quickly revoke [**WireGuard**](https://www.wireguard.com/) keys of inactive clients to limit the possibility of this occurring. The server will also validate that keys are not reused.

Once the client has connected it will send a ping request to the server every 10 seconds. This request allows the client to quickly detect a down link and failover in approximately 13 seconds. If the server does not receive a ping request in 6 minutes it will disconnect the user and revoke the public key.

### Configuration

To allow [**WireGuard**](https://www.wireguard.com/install/) connections the WireGuard packages must be installed on the server. The [**WireGuard installation documentation**](https://www.wireguard.com/install/) has information on how to install the packages for each Linux distribution.

In the server settings enable [**WireGuard**](https://www.wireguard.com/). Configure the *Virtual WG Network* with a network that has the same CIDR as the *VIrtual Network*. Then configure the *WG Port* to select the UDP port for [**WireGuard**](https://www.wireguard.com/) connections.

Clients will have the same static address from the *Virtual Network* on the *Virtual WG Network*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FEflk9kd7pBuTKwgElSH8%2Fwg_server.png?alt=media\&token=39232a05-3dc0-4939-b4cf-03858ac2bb80)

The clients must also be configured using the [**WireGuard Client**](https://docs.pritunl.com/kb/vpn/client/wireguard) documentation.


# Subscription

Subscribing to Pritunl

Subscriptions can purchased on the homepage or using the link in the web console of a running Pritunl server. Subscriptions are managed by Stripe. A Pritunl server can be upgraded at any time and does not need to be reconfigured when upgrading to a subscription.

### License Key

After creating a subscription a license key will be emailed to the email address used during checkout. The license key does not need to be used on the same host that was used to create the subscription. If the license key is used on multiple hosts the subscription quantity will automatically increase the bill for each additional host.


# Server

Debugging Pritunl server

### Getting Information For Bug Report

Use the commands below to get information needed for debugging an issue. Refer to [**Repair Database**](https://docs.pritunl.com/kb/vpn/debugging/database-repair) for information on repairing the database.

```shell
pritunl version
printf "dh:\n" && sudo df -h
printf "free:\n" && sudo free -l -m
printf "pritunl lsof: " && sudo lsof -p `pgrep -x pritunl` | wc -l
printf "pritunl-web lsof: " && sudo lsof -p `pgrep -x pritunl-web` | wc -l
printf "pritunl-dns lsof: " && sudo lsof -p `pgrep -x pritunl-dns` | wc -l
printf "pritunl limits:\n" && sudo cat /proc/`pgrep -x pritunl`/limits
printf "pritunl-web limits:\n" && sudo cat /proc/`pgrep -x pritunl-web`/limits
printf "pritunl-dns limits:\n" && sudo cat /proc/`pgrep -x pritunl-dns`/limits
printf "limits:\n" && sudo sh -c "ulimit -Hn; ulimit -Sn"
sudo netstat -tulpn | grep pritunl
printf "pritunl-http:\n" && curl -I http://localhost/check
printf "pritunl-internal:\n" && curl -I http://localhost:9756/check
printf "pritunl-https:\n" && curl --insecure https://localhost
```

```shell
sudo strace -p `pgrep -x pritunl`
sudo strace -p `pgrep -x pritunl-web`
sudo strace -p `pgrep -x pritunl-dns`
```

### Server Synchronized Time

Several components of a multi-server Pritunl cluster rely on accurate synchronized time on all the servers. It is important to ensure all servers in a cluster have the same time.

### Connection Reset Error

If you are seeing the macOS/Linux error `connection reset by peer` or the Windows error `An existing connection was forcibly closed by the remote host` in the client logs, this can indicate the Pritunl web server queue is overloaded. Use the commands below to increase this based on the resources available on the system and the requirements for the deployment. Generally, a server should have a thread for each concurrent connection, as the connection requests can take time with some authentication modes and will quickly overload if a server comes online and all clients attempt to reconnect at the same time.

```shell
# Low Capacity (1 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 200
sudo pritunl set app.request_accepted_queue_size 100
sudo pritunl set app.request_thread_count 20
sudo pritunl set app.request_max_thread_count 100

# Standard Capacity (2 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 600
sudo pritunl set app.request_accepted_queue_size 300
sudo pritunl set app.request_thread_count 50
sudo pritunl set app.request_max_thread_count 300

# High Capacity (4 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 1200
sudo pritunl set app.request_accepted_queue_size 600
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 600

# Extreme Capacity (8 CPU, 8GB RAM)
sudo pritunl set app.request_queue_size 4000
sudo pritunl set app.request_accepted_queue_size 2000
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 2000

# Restart Server After Changes
sudo systemctl restart pritunl
```

### Process Inspection

To debug CPU usage of the `pritunl` process [**py-spy**](https://github.com/benfred/py-spy) can be used. Run the command below to install py-spy from PyPI into the Pritunl packaged Python build. If sampling rate error is shown reduce the `--rate 50` option. This will not work for the Golang based `pritunl-web` and `pritunl-dns` processes.

```shell
# Install pySpy from PyPI
sudo /usr/lib/pritunl/usr/bin/pip3 install py-spy

# Find pid for process "/usr/lib/pritunl/usr/bin/python3 /usr/lib/pritunl/usr/bin/pritunl start"
sudo ps ax --format user,pid,%cpu,%mem,tty,stat,start,time,command | grep pritunl

# Get live top view of function CPU usage press 4 to sort by total time spent on function
sudo /usr/lib/pritunl/usr/bin/py-spy top --rate 50 --pid <PID>

# Record CPU usage flamegraph to profile.svg press ctrl+c to stop collection and generate output
sudo /usr/lib/pritunl/usr/bin/py-spy record --rate 50 --output profile.svg --pid <PID>

# Dump list of active threads
sudo /usr/lib/pritunl/usr/bin/py-spy dump --pid <PID>
```


# Client

Debugging Pritunl client

### Connection Issues

The most common causes of connection issues are:

* **Firewall configured incorrectly**\
  Any external firewalls including instance security groups and VPC network firewalls need to be configured to accept traffic to the VPN ports.
* **Unstable internet connections**\
  If users have unstable internet connections the *Ping Timeout* and *Ping Interval* should be increased. For less stable connections a *Ping Interval* of `20` and *Ping Timeout* of `120` can be used.
* **Overloaded server**\
  The memory and CPU usage of the server should be checked if connection issues are occurring. If all internet traffic is being routed through the VPN with the `0.0.0.0/0` route this can quickly consume all the available network bandwidth on that server. Multiple hosts and replicated servers should be used to handle a large number of concurrent VPN connections.
* **MTU issues**\
  Some internet service providers don't provide the standard 1500 MTU connection and some cloud providers have overlay networks that reduce the MTU below the standard 1500. If the client and server cannot detect the correct MTU unexpected problems can occur. The connection may be successful and ping may work but there will still be connectivity issues with certain protocols. Refer to the *Connection MTU* section below for addressing this issue.
* **Country VPN Filters**\
  Some countries will block VPN connections. This is often difficult to reliably determine because these systems will only inspect a fraction of the overall packets due to the performance limitations involved with inspecting every internet packet. Different methods are also used for disrupting a connection after it is detected. Some of the systems will drop only a fraction of the connections packets causing a slow unreliable connection.

### DNS Issues

Some VPN connections will require the DNS server to be routed through the VPN. This will depend on the protocol and client version. If a route for this is not available DNS resolution on the client will fail. Servers are created with the default DNS server 8.8.8.8 and a route 8.8.8.8/32 for this DNS server is also created. If the DNS server is changed or the server was created in an older release that did not create a default route one should be created. This can be done by adding the DNS server IP addresses with a /32 subnet such as 8.8.8.8/32 to the server routes.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FtJkqh3sdevoCG94ZHwUO%2Fpritunl_dns_route.png?alt=media&amp;token=150de23a-42d2-414d-acdd-6759a8614dd9" alt=""><figcaption></figcaption></figure>

### Linux

**Log Locations:**

* Service Log: `/var/log/pritunl-client.log`
* Interface Logs: `~/.config/pritunl/pritunl.log`
* Profile Logs: `~/.config/pritunl/profiles/PROFILE_ID.log`
* Profile Configurations: `~/.config/pritunl/profiles/PROFILE_ID.ovpn`
* System Profile Logs `/var/lib/pritunl-client/profiles/PROFILE_ID.log`
* System Profile Configurations `/var/lib/pritunl-client/profiles/PROFILE_ID.ovpn`

**Manually Restart Service:**

```shell
sudo systemctl restart pritunl-client.service
```

### macOS

**Log Locations:**

* Service Log: `/var/log/pritunl-client.log`
* Interface Log: `~/Library/Application Support/pritunl/pritunl.log`
* Profile Logs: `~/Library/Application Support/pritunl/profiles/PROFILE_ID.log`
* Profile Configurations: `~/Library/Application Support/pritunl/profiles/PROFILE_ID.ovpn`
* System Profile Logs `/var/lib/pritunl-client/profiles/PROFILE_ID.log`
* System Profile Configurations `/var/lib/pritunl-client/profiles/PROFILE_ID.ovpn`

**Manually Restart Service:**

Use the commands below to manually restart the service.

```shell
sudo launchctl unload /Library/LaunchDaemons/com.pritunl.service.plist
sudo launchctl disable system/com.pritunl.service
sudo launchctl enable system/com.pritunl.service
sudo launchctl load /Library/LaunchDaemons/com.pritunl.service.plist
```

**Manually Run Service:**

Use the commands below to stop the background service and manually run it in the foreground to debug issues. After testing use the command above to restore the background service.

```shell
sudo launchctl unload /Library/LaunchDaemons/com.pritunl.service.plist
sudo /Applications/Pritunl.app/Contents/Resources/pritunl-service
```

**Manually Run Client:**

Use the commands below to run the frontend client with debugging output. **First fully exit the existing client using the tray icon menu.**

```shellscript
ELECTRON_ENABLE_LOGGING=1 /Applications/Pritunl.app/Contents/MacOS/Pritunl --dev-tools
```

**Service Status:**

```shell
sudo launchctl print system/com.pritunl.service
```

**Manually Uninstall:**

```shell
# Service
kill -2 $(ps aux | grep Pritunl.app | awk '{print $2}') &> /dev/null || true
sudo launchctl unload /Library/LaunchAgents/com.pritunl.client.plist &> /dev/null || true
sudo launchctl unload /Library/LaunchDaemons/com.pritunl.service.plist &> /dev/null || true

# Pritunl
sudo rm -rf /Applications/Pritunl.app
sudo rm -f /Library/LaunchAgents/com.pritunl.client.plist
sudo rm -f /Library/LaunchDaemons/com.pritunl.service.plist
sudo rm -f /private/var/db/receipts/com.pritunl.pkg.Pritunl.bom
sudo rm -f /private/var/db/receipts/com.pritunl.pkg.Pritunl.plist

# Profiles
rm -rf ~/Library/Application\ Support/pritunl
sudo rm -rf /Library/Application\ Support/Pritunl
rm -rf ~/Library/Caches/pritunl
rm -rf ~/Library/Preferences/com.electron.pritunl.plist

# Files
sudo rm -f /var/run/pritunl_auth
sudo rm -f /var/run/pritunl.sock
sudo rm -f /var/log/pritunl.log
sudo rm -f /var/log/pritunl.log.1
sudo rm -f /var/log/pritunl-client.log
sudo rm -f /var/log/pritunl-client.log.1
sudo rm -rf /var/lib/pritunl-client
```

**Check keychain:**

```shell
security add-generic-password -U -s pritunl -a test -w password login-keychain
security find-generic-password -w -s pritunl -a test
security delete-generic-password -s pritunl -a test
```

**Check DNS:**

```shell
sudo scutil --dns
sudo scutil
> open
> show State:/Network/Service/Pritunl/DNS
> show Setup:/Network/Service/Pritunl/DNS
list State:/Network/Pritunl/Connection
> show State:/Network/Global/DNS
> show State:/Network/Pritunl/DNS
> show State:/Network/Pritunl/Restore
> quit
```

### Connection MTU

Some connections may have MTU issues this can be fixed by entering a lower MSS Fix value in the server settings. First test 1200 or lower to confirm that it is an MTU issue. If this fixes the connection increase the MTU in a range of 1200-1400 to find a working MTU.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fa4nFjkypEmfzJP9xOdHM%2Fmss_fix.png?alt=media\&token=25b265dc-d839-4fcb-a841-5ed3bd9e96fd)

To test for MTU issues first ping a over sized packet using the commands below. This should report an over size packet error. On Linux the discovered MTU will be shown. Take the expected MTU and subtract 28 then test that the ping functions. Replace `192.168.123.1` with the virtual IP address of the Pritunl server to test both the internet and VPN connection for MTU issues. When pinging the VPN address the MTU will be lower then the MTU for non-VPN traffic.

Once a successful ping is completed increment the size until the ping returns an over sized packet error to verify there are no sizes that time out. All packet sizes should either return an over sized packet error or a successful ping. If a specific packet size times out this indicates an MTU issue.

{% tabs %}
{% tab title="Linux MTU Test" %}

```sh
ping -M do -s 2000 app.pritunl.com
Frag needed and DF set (mtu = 1500)
ping -M do -s 1472 app.pritunl.com

ping -M do -s 2000 192.168.123.1
Frag needed and DF set (mtu = 1500)
ping -M do -s 1392 192.168.123.1
```

{% endtab %}

{% tab title="macOS MTU Test" %}

```sh
ping -D -s 2000 app.pritunl.com
Message too long
ping -D -s 1472 app.pritunl.com

ping -D -s 2000 192.168.123.1
Message too long
ping -D -s 1392 192.168.123.1
```

{% endtab %}

{% tab title="Windows MTU Test" %}

```sh
ping -f -l 2000 app.pritunl.com
Package needs to be fragmented but DF set.
ping -f -l 1472 app.pritunl.com

ping -f -l 2000 192.168.123.1
Package needs to be fragmented but DF set.
ping -f -l 1392 192.168.123.1
```

{% endtab %}
{% endtabs %}

### Asymmetric Routing

Asymmetric routing will occur in some routing configurations, specifically with non-NAT configurations. This can cause issues with firewalls and connections. If the endpoint on either side does not accept redirects the asymmetric routing will persist and cause routing problems. This will be visible when running ping to the other endpoint and the `Redirect Host(New nexthop: )` message will be shown repeatedly indicating the host is not accepting the routing path. This can cause firewalls or VPNs to filter the traffic and can result in stalled connections. Run `sudo sysctl net.ipv4.conf.all.accept_redirects` to check if redirects are disabled, this would also need to be checked on the specific interface to verify the interface specific setting. Firewalls may also need to be configured bypass firewall rules for traffic on same interface.

### Windows

**Log Locations:**

* Service Log: `C:\ProgramData\Pritunl\pritunl-client.log`
* Interface Log: `C:\Users\USERNAME\AppData\Roaming\pritunl\pritunl-client.log`
* Profile Logs: `C:\Users\USERNAME\AppData\Roaming\pritunl\profiles\PROFILE_ID.log`
* Profile Configurations: `C:\Users\USERNAME\AppData\Roaming\pritunl\profiles\PROFILE_ID.ovpn`
* System Profile Logs `C:\ProgramData\Pritunl\profiles\PROFILE_ID.log`
* System Profile Configurations `C:\ProgramData\Pritunl\profiles\PROFILE_ID.ovpn`

### Chrome OS

Press `ctrl+alt+t` in terminal run commands `route -4` and `route -6`. Open `chrome://net-internals` select *ChromeOS* on the left then click *Store Debug Logs*. In the *Downloads* directory drag the log archive to Google Drive. Download the log archive and open the file `var/log/messages`.

### Windows Connection Error

If profiles on Windows fail to start and a network adapter error is shown use follow the [**Microsoft Visual C++ 2015 Redistributable**](https://www.microsoft.com/en-us/download/details.aspx?id=52685) instructions to manually install the required Windows libraries.

### Chrome or Browser DNS Issues

If DNS is only working outside the browser some web browsers route DNS queries to a custom encrypted DN S server. In Chrome the option is in Settings -> Privacy and security -> Secure DNS. Some addons may also reroute DNS queries.

### Ubuntu AppArmor DNS Issues

The Ubuntu AppArmor profile will block OpenVPN DNS scripts from running. To allow Pritunl to configure DNS for OpenVPN connections the command below must be run to disable the OpenVPN AppArmor profile.

```shellscript
sudo apparmor_parser -R /etc/apparmor.d/openvpn
```

This can be reverted by running the command below.

```shellscript
sudo apparmor_parser -a /etc/apparmor.d/openvpn
```

### macOS WPAD DNS Issues

Some ISPs will use Web-Proxy Auto Discovery to interfere with DNS settings. This can cause issues for some VPN connections. If issues are occurring this feature should be disabled. To disable WPAD on macOS ensure all protocols are disabled in the advanced network interface settings.

![](https://files.readme.io/9ccc359-macos_proxy.png)

### Windows WPAD DNS Issues

Some ISPs will use Web-Proxy Auto Discovery to interfere with DNS settings. This can cause issues for some VPN connections. If issues are occurring this feature should be disabled. To disable WPAD on Windows uncheck *Automatically detect settings* in the network *Proxy* settings.

![](https://files.readme.io/c8aee98-windows_proxy.png)

### macOS DNS Issues

Running `sudo pritunl set vpn.dns_mapping_push_all false` on the Pritunl server when using client DNS mapping may fix issues with the macOS DNS configuration. This will push only the Pritunl DNS server to the client to avoid issues with macOS DNS server priority.

A macOS device policy can block DNS configuration changes. Open Settings -> Network -> VPN & Filters and verify filtering for DNS Settings is Disabled. If the VPN & Filters menu is not shown the policy is not configured.

### macOS iCloud Private Relay

If the iCloud Private Relay is enabled on macOS this can interfere with the DNS and routing configuration provided by the VPN. This should be disabled while connected to a VPN.

### iOS DNS Issue

There are currently three fixes for the DNS issue on iOS.

Add the DNS server to the server routes. The default DNS server used is `8.8.8.8` add the route `8.8.8.8/32` to the server routes for this configuration.

Remove the DNS server from the settings. This will instruct the client to use their current DNS configuration. This could cause problems with some clients if that DNS configuration becomes unroutable due to the VPN routes.

Enable *VPN Client DNS Mapping* in the advanced server settings. This will start a DNS server on the Pritunl server that will proxy all DNS requests and will always be available to the client.

### WireGuard

Some network connections will not support OpenVPN for these connections [**WireGuard**](https://docs.pritunl.com/kb/vpn/client/wireguard) should be configured to avoid connection issues.

### macOS Installation Failed

If the error `The installer encountered an error that caused the installation to fail.` open settings and select *Privacy & Security* then *Files and Folders*. Click the icon to expand the *Installer* application and verify the *Downloads Folder* is enabled.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAocMDD3MhY08mwamtbT1%2Finstaller_fix1.png?alt=media\&token=e14b63f9-1281-4757-a9d6-05867265b4f6)

If this does not work open *Full Disk Access* and enable the *Installer* application.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FLFZxNtxqh35ZVYSu8KnR%2Finstaller_fix2.png?alt=media\&token=e720cf24-f559-498d-931f-222d23d3e9e1)

Selecting the *Installer* application and clicking the - icon to remove the application in both the *Files and Folders* and *Full Disk Access* section can also be done to reset the options. Moving the installer out of the Downloads folder may also fix the issue.

### Developer Tools

The Pritunl Client is an Electron app, the commands below can be used to start the client with the developer tools open for debugging. After the developer tools is shown open the top right menu in the tools and undock the window.

```shell
# macOS
/Applications/Pritunl.app/Contents/MacOS/Pritunl --dev-tools
# Windows
& 'C:\Program Files (x86)\Pritunl\pritunl.exe' --dev-tools
# Linux
pritunl-client-electron --dev-tools
```

### Reset macOS Secure Enclave Configuration

If device authentication has stopped working on macOS the Pritunl Secure Enclave key can be reset by removing the configuration file below. Then restart the client service.

```shell
sudo launchctl disable system/com.pritunl.service
sudo rm /Library/Application\ Support/Pritunl/pritunl-client.json
sudo launchctl enable system/com.pritunl.service
```

### Test Connection Request

Run the command below to simulate a connection request with curl. This should always return HTTP status 401. The command should be tested on the client when the Pritunl Client service logs show errors indicating connection requests failing. Replace `demo.pritunl.com` with the IP address or domain of the Pritunl server.

```shell
curl -v --insecure -L -X POST -H "User-Agent: pritunl-client" -H "Content-Type: application/json" -H "Auth-Token: aaLH7MIKvb9AHqZ7aJ43nQrHLa57uwnQ" -H "Auth-Timestamp: 1759171343" -H "Auth-Nonce: 2XCGnJDPhwPF5QSGFbvX7c9ekVVAQRKR" -H "Auth-Signature: M64chaz5dgbVg1kcj2n/r9Mqq+y9+YGBQ8i=" -d '{"data": "9ajBLpxtmhGVkYXc3p1sn392vA8Kc6YDA25Qd52R8qMGU9nFD78LlFHG4d6rOeF3nLY9R","nonce": "2XCGnJDPhwPF5QSGFbvX7c9ekVVAQRKR","public_key": "tR9PlDsUzh8pmgAc2GG9YtumAGqrdDy+IunMjGJNb39=","signature": "M64chaz5dgbVg1kcj2n/r9Mqq+y9+YGBQ8i="}' -k https://demo.pritunl.com/key/ovpn/59875e033eff21276da0f0b9/626ac6c561710e5363adb35a/599b814b3eff210b30813f65
```

### Connection Reset Error

If you are seeing the macOS/Linux error `connection reset by peer` or the Windows error `An existing connection was forcibly closed by the remote host` in the client logs, this can indicate the Pritunl web server queue is overloaded. Use the commands below to increase this based on the resources available on the system and the requirements for the deployment. Generally, a server should have a thread for each concurrent connection, as the connection requests can take time with some authentication modes and will quickly overload if a server comes online and all clients attempt to reconnect at the same time.

```shell
# Low Capacity (1 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 200
sudo pritunl set app.request_accepted_queue_size 100
sudo pritunl set app.request_thread_count 20
sudo pritunl set app.request_max_thread_count 100

# Standard Capacity (2 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 600
sudo pritunl set app.request_accepted_queue_size 300
sudo pritunl set app.request_thread_count 50
sudo pritunl set app.request_max_thread_count 300

# High Capacity (4 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 1200
sudo pritunl set app.request_accepted_queue_size 600
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 600

# Extreme Capacity (8 CPU, 8GB RAM)
sudo pritunl set app.request_queue_size 4000
sudo pritunl set app.request_accepted_queue_size 2000
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 2000

# Restart Server After Changes
sudo systemctl restart pritunl
```

### Reset Configuration

If the configuration becomes corrupted and the client will not start it can be reset by removing the directories below.

```sh
# macOS
rm -rf ~/Library/Application\ Support/pritunl
sudo rm -rf /Library/Application\ Support/Pritunl
# Windows
C:\Users\USERNAME\AppData\Roaming\pritunl
C:\Program Data\Pritunl
# Linux
rm -rf ~/.config/pritunl
sudo rm -rf /var/lib/pritunl
```


# Server Tuning

Tuning server configuration for high capacity configurations

Below are the commands that control the web server queue and thread options. These often need to be adjusted for high capacity deployments. The Systemd web server provides security benefits and also allows better monitoring of the `pritunl-web` server process in the `pritunl-web.service` unit.

```shell
# Enable Web Server Systemd
sudo pritunl set app.web_systemd true

# Low Capacity (1 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 200
sudo pritunl set app.request_accepted_queue_size 100
sudo pritunl set app.request_thread_count 20
sudo pritunl set app.request_max_thread_count 100

# Standard Capacity (2 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 600
sudo pritunl set app.request_accepted_queue_size 300
sudo pritunl set app.request_thread_count 50
sudo pritunl set app.request_max_thread_count 300

# High Capacity (4 CPU, 4GB RAM)
sudo pritunl set app.request_queue_size 1200
sudo pritunl set app.request_accepted_queue_size 600
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 600

# Extreme Capacity (8 CPU, 8GB RAM)
sudo pritunl set app.request_queue_size 4000
sudo pritunl set app.request_accepted_queue_size 2000
sudo pritunl set app.request_thread_count 100
sudo pritunl set app.request_max_thread_count 2000

# Restart Server After Changes
sudo systemctl restart pritunl
```


# Database Repair

Correct issues with database

The commands listed below from least to most destructive will fix issues that can occur if the database is corrupted.

### Clear Message Cache

Clearing the message cache removes and recreates the database collection used for internal communication between hosts. When the internal host communication isn't working servers may fail to start and connections my become unstable. Clearing this collection should not require stopping hosts. This can be run without impacting server availability. Hosts will automatically reset the messaging cursor shortly after running the command and resume internal messaging.

```sh
sudo pritunl clear-message-cache
```

### Clear All Cache Data

When there is additional corruption in the database all cached data can be removed. This removes all temporary data like connection states and records for recently used authentication nonces. This data is referred to as secondary data and can be cleared with the commands below. The message cache will also be cleared when running this command. All hosts should be stopped before running this command.

```sh
sudo systemctl stop pritunl
sudo pritunl destroy-secondary
sudo systemctl start pritunl
```

### Full Database Repair

The full database repair is the most extensive repair command and the only command that will result in configuration changes. This command will clear the client IP pools resulting in client static IP addresses being reassigned. If specific client IP addresses were relied on for networking those configurations will need to be updated. Additionally the system logs will be removed from the database, auditing history will not be removed. This command will also clear the message cache and remove all secondary cache data. All hosts should be stopped before running this command.

```sh
sudo systemctl stop pritunl
sudo pritunl repair-database
sudo systemctl start pritunl
```


# CentOS Support

CentOS Discontinued

CentOS was discontinued and the operating system will no longer be updated. The Pritunl repositories for CentOS were also discontinued. The [**Oracle Linux Repositories**](https://docs.pritunl.com/kb/vpn/repositories) are fully compatible with CentOS. These can be used to recieve updates for Pritunl. To continue getting system updates the system must be switched to Oracle Linux. Oracle providers a script to [**upgrade CentOS to Oracle Linux**](https://linux.oracle.com/switch/centos/) that will convert an existing CentOS system to Oracle Linux.


# Security Features

Security Features

### Dynamic Firewall

![](https://files.readme.io/42850cf-dynamic_firewall.png)

The dynamic firewall provides the highest level of security available in Pritunl. When a server is run with the dynamic firewall enabled the VPN port will not be open to the internet. The Pritunl server will block access to the port with iptables. When configured the only port open to the internet on a Pritunl server will be the web server. This design in combination with the high level of security provided from the dual web server can make a Pritunl server nearly impossible to attack from unauthenticated attackers. When using the dynamic firewall only the Pritunl Client that is updated to a supported version will be able to connect. Other OpenVPN clients are not supported. **Currently server linking is not supported with the dynamic firewall.**

This server option can be used along side existing VPN servers on the same host to support other OpenVPN clients or to allow transitioning to the dynamic firewall from servers that do not have the feature enabled.

For a client to connect the Pritunl client will first authenticate with the Pritunl web server. A Pritunl client profile includes multiple keys that allow for multiple layers of encryption. This connection approval request will utilize these keys to create three layers of authorization for the request. The components of this are explained below. Many administrators do not configure a valid HTTPS certificate and HTTPS is not relied on or required to provide secure authentication.

* **Client SHA512-HMAC Key (Authorization)**\
  The client will use a SHA512-HMAC secret to sign each connection request. The server will also use this secret to sign the response allowing the client to verify the connection response. This is the same authentication system used to authorize the client configuration sync which syncs profile configuration changes such as host addresses and server port changes (private keys are never synced).
* **Client/Server NaCl Asymmetric Key (Authorization + Encryption)**\
  The client utilizes a [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key for the server that is included in the client profile. This provides asymmetric encryption of the connection request from the client to the server. The server will encrypt the response with the clients [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key providing encryption of the response. The client will also verify the server response using the server [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key. This is the same authentication system used to provide the additional layer of encryption and authorization available in [**OpenVPN**](https://openvpn.net/) connections with passwords and two-factor codes.
* **Client RSA-4096 Asymmetric Key (Authorization)**\
  The clients RSA certificate and key is used to sign each connection request. The server will use this verify the client connection request. This is the same certificate used to verify [**OpenVPN**](https://openvpn.net/) connections.

Once the Pritunl server validates the connection approval request the server will open the VPN port for the requested server to the client IP addresses. Three sources are used to determine the client IP address, the client provided IPv4 and IPv6 address discovered from the Pritunl app servers and the remote address of the incoming web request on the Pritunl server.

Pritunl web servers are often run behind load balancers, by utilizing the Pritunl app servers even if the web request returns the load balancer IP address the server will still have the correct address. Additionally the Pritunl server will return the IP address of the Pritunl host that received the connection approval. This ensures the client will connect to the correct Pritunl VPN server when sending a request to multiple Pritunl web servers behind a load balancer. It is not recommended to ever configure Pritunl VPN servers behind a network load balancer as the client will already choose a server at random. When using the dynamic firewall a network load balancer cannot be used.

**An external firewall or security group will still need to be configured when using the dynamic firewall. The dynamic firewall only controls access to the VPN ports of the VPN servers that have the dynamic firewall enabled. Servers will still have other open ports such as SSH that need to be controlled externally.**

![](https://files.readme.io/3e857e0-dynamic_firewall_option.png)

To enable the option an enterprise subscription is required. In the advanced server settings enable the *Dynamic Client Firewall* option.

### Dual Web Server

![](https://files.readme.io/dc1af09-dual_web_server.png)

The Pritunl web console uses an internal and external web server. This was done to protect the internal Python process.

The `pritunl-web` process is a Golang web server that will handle SSL and validate the incoming data. The Golang web server has a very good history of security and this isolation provides a high level of protection from RCE attacks. Additionally on RHEL distributions SELinux policies are included with the `pritunl` package that will significantly limit the capabilities of the `pritunl-web` process providing additional protection from RCE attacks. Every web handler and the JSON data structure for that handler is statically defined in `pritunl-web`. This prevents unexpected types or data structures from reaching the internal Python process.

Each request is also recreated with only known headers and valid JSON data. The validated JSON data is parsed then serialized again to ensure only the valid parsed data is transferred to the new request. The new request is then sent to the internal `pritunl` process and the response is returned to the client. There have been several header and parsing related CVE's with the Golang web server and reverse proxy. The `pritunl-web` server has not been affected by these issues and does not utilize the Golang reverse proxy. By creating new requests that are known to be clean vulnerabilities with request smuggling and corrupted HTTP data are extremely unlikely.

The web server in the internal `pritunl` process is bound only to `127.0.0.1` to accept requests from the `pritunl-web` process. This process also contains additional input data validation and has SELinux policies.

### Web Server Strict Authentication

The session cookie includes an additional NaCl signature based token that can be validated by the external pritunl-web process. This allows the pritunl-web process to pre-authenticate any request going to an admin API path without ever sending the request to the internal web server. This significantly reduces the attack surface of the session management in the root Python web process by blocking any requests to these API paths that don’t have a valid NaCl signature.

If there are no API keys configured as indicated by `web_auth_strict = true` being shown in the `starting server` log message the external web server will only pass through requests to admin API paths that have a valid NaCl signature. If admin API keys are configured `web_auth_strict = false` will be shown on startup and the request will get sent through although it will still validate the signature for non-API based requests. If you are not using the Pritunl API and API keys were previously configured use the command `sudo pritunl disable-admin-api` to remove any existing API keys and configure the server to run with `web_auth_strict`.

### Self Shutdown Notification System

Every hour the Pritunl server sends a request to `https://app.pritunl.com/notification` with the version of the Pritunl server. If a vulnerability with a past version of Pritunl is found the notification server can send back the state for three categories `www`, `web` and `vpn`. A shutdown state for `www` will block all incoming web requests to the web server and instead return a message indicating the reason. A shutdown state for `web` will stop the `pritunl-web` external web server process and disable the internal `pritunl` web server. A shutdown state for `vpn` will stop and disable all running VPN servers.

With this system there is no need to monitor and wait for emails indicating updates are required for urgent security issues. Within an hour of discovering an issue all running Pritunl servers will be protected with a self shutdown.

### OpenVPN Process Permissions

By default the OpenVPN process runs as root. This can be changed by enabling **Drop OpenVPN Permissions** in the top right settings from the Pritunl web console. Once enabled OpenVPN servers will drop to a non-root user after starting. This may not work with all Linux distributions, test starting a non-production server first.


# Update Notifications

Get notifications for software updates

All software updates are published to the [**forums release category**](https://forum.pritunl.com/c/releases/12) once an account is created the *Watching First Post* notification option can be enabled for the category to receive notifications for all updates.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fgit-blob-e90ae8421adc57b6481b8b1c269abe863f032e6c%2Frelease_notification.png?alt=media)

### Pritunl Status Page

The [**Pritunl Status Page**](https://status.pritunl.com) also has an email subscription option to get notifications for service availability events.


# Securing Pritunl

Securing Pritunl

This documentation will describe the full recommended configuration for environments requiring the highest level of security.

### Always use an external firewall

Avoid using software firewalls that may exist on the Pritunl server itself, such as iptables, firewalld or ufw. Pritunl will modify iptables rules on the server and these firewalls will break the Pritunl configuration.

Instead, always use a firewall that is external to the server such as a hardware firewall or virtual instance security rules.

### Avoid routing 0.0.0.0/0

Routing all internet traffic through the VPN server on a cloud or enterprise network will almost always produce unintended results. This configuration is intended for simple VPN servers running on one isolated host. It should never be used in a cloud or enterprise environment. Cloud and enterprise networks often have a lot of network resources that may not be considered when providing VPN users with full network access. One example is unintentionally providing VPN users with access to the AWS metadata service. With all network traffic routed and NATed through the VPN server a simple HTTP query from the VPN client to the metadata service `curl http://169.254.169.254` will return potentially sensitive information. This can be a significant issue if IAM roles are used on the Pritunl instance. Another example is unintentionally providing VPN users with access to the MongoDB database that is used by Pritunl. If the MongoDB database is not sufficiently protected the user could modify the database to gain additional access to VPN servers.

## Installation

Oracle Linux 8 should be used as the host operating system. If available automatic Ksplice kernel updates should be enabled. This is included for free with Oracle Cloud instances, other installations would require a Oracle Linux support subscription.

```shell
sudo sed -i 's/^autoinstall =.*/autoinstall = yes/g' /etc/uptrack/uptrack.conf
```

Automatic system updates should be enabled. This will not disrupt Pritunl VPN connections. The Pritunl service will need to be manually restarted to complete updates. The Pritunl web server will restart automatically on updates without impacting the availability of the server.

```shell
sudo dnf -y update
sudo dnf -y install dnf-automatic
sudo sed -i 's/^upgrade_type =.*/upgrade_type = default/g' /etc/dnf/automatic.conf
sudo sed -i 's/^download_updates =.*/download_updates = yes/g' /etc/dnf/automatic.conf
sudo sed -i 's/^apply_updates =.*/apply_updates = yes/g' /etc/dnf/automatic.conf
sudo systemctl enable --now dnf-automatic.timer
```

The OpenVPN package from the EPEL repository should be replaced with the newer Pritunl build using the command below.

```shell
sudo yum --allowerasing install pritunl-openvpn
```

## MongoDB

The latest version of MongoDB should be used. For both single and multi-host configurations password authentication should be enabled on the database. For mutli-host configurations where the database connection is going over untrusted networks SSL should be enabled. It is not recommended to configure SSL if the local network is secure, expiring SSL certificates can cause service disruptions. The [**Securing MongoDB**](https://docs.pritunl.com/kb/vpn/security/securing-mongodb) documentation has information on configuring these options.

## Systemd Web Server Process

The Pritunl web server process by default runs as a root user to ensure compatibility with different Linux hosts. The web server can run in a separate systemd service to significantly improve the isolation of the process. This will run the web server under the `pritunl-web` non-root user and also utilizes several systemd options including `ProtectSystem=full` to further isolate the web server process. Run the command below on one of the Pritunl hosts then restart the service to enable this option.

```shell
sudo pritunl set app.web_systemd true
sudo systemctl restart pritunl
```

After the service has completed startup run the command below to verify the systemd service is active.

```shell
sudo systemctl status pritunl-web
```

## Insecure Single Sign-On Modes

The Radius, SAML (not including listed SAML providers) and Duo Security (not including modes using Duo as secondary authentication) single sign-on modes should be avoided if possible.

Radius is vulnerable to phishing attacks and uses outdated security mechanisms.

When using an unsupported SAML provider without API support additional user checks cannot be done. The supported SAML providers use the providers API to verify the user is active on each connection and every hour while connected. With this API support if a user is disabled or deleted from the SAML provider new VPN connections will fail and existing VPN connections will be stopped within an hour.

The Duo only single sign-on mode relies on the Duo authenticator alone to provide authentication.

## Secure Single Sign-On Modes

The recommended single sign-on configurations are listed below. These modes provide multi-factor authentication from two separate sources.

* Azure + Device Authentication
* Google + Device Authentication
* JumpCloud + Device Authentication
* Okta + Device Authentication
* OneLogin + Device Authentication
* Azure + Duo Security
* Google + Duo Security
* JumpCloud + Duo Security
* Okta + Duo Security
* OneLogin + Duo Security
* Azure + Yubico
* Google + Yubico
* JumpCloud + Yubico
* Okta + Yubico
* OneLogin + Yubico

## OneLogin and Okta Multi-Factor

Both OneLogin and Okta have multi-factor authenticators. Pritunl can be configured to use these but it is not recommended. This will require a broadly scoped API key that has almost full access to the single sign-on provider. A read-only API key can otherwise be used when not using the multi-factor authenticators.

## Authentication Cache

In the top right settings the *Pritunl Authentication Cache* should be enabled and the *OpenVPN Authentication Cache* should be disabled. The Pritunl authentication cache is only compatible with the Pritunl VPN client, the OpenVPN authentication cache is compatible with all VPN clients.

The Pritunl authentication cache uses a token that is stored only in the memory of the clients background service running as root. If the computer is turned off this key will no longer be available. This system is very secure and attempting to use several layers of multi-factor authentication without authentication cache will result in an almost unusable user experience.

The OpenVPN authentication cache is limited to only specific secondary authentication modes and relies primarily on the users IP address, this option should not be used.

## Drop OpenVPN Permissions

The *Drop OpenVPN Permissions* option should be enabled in the top right settings. This will run the OpenVPN server process as a non-root user.

## Restrict Profile Import

The *Restrict Profile Import* option in the top right settings will prevent the user from easily downloading the VPN profile outside of the Pritunl Client. When enabled the user will only be provided with a import URI for the Pritunl Client, options to directly download the VPN profile as a file or archive will be removed. This option will only work when the user is using the Pritunl Client.

## Auditing

The *Auditing Mode* should be set to *All* in the top right settings. This will log important security related events. The *Monitoring Mode* is intended for monitoring the server resources and is not relevant to security.

## Administrators

All administrator users should have a YubiKey configured. This will require setting the Yubico API key in the top right settings. Configuring administrators with YubiKeys does not require users to also have YubiKeys. This system uses Yubico OTP, the FIDO only Security Key series YubiKeys will not work. The YubiKey 4, 5 and Bio series keys are supported.

## Device Authentication

[**Device Authentication**](https://docs.pritunl.com/kb/vpn/security/device-authentication) provides the highest level of assurance that each physical client device connecting to the VPN has been authorized. This system provides a high level of protection against authentication and phishing attacks. Even if an attacker is able to obtain a user VPN profile and fully compromises the users account and two-factor authentication the device making the connection would be prompted for approval when attempting to connect. This can be enabled in the server settings. Refer to the [**Device Authentication**](https://docs.pritunl.com/kb/vpn/security/device-authentication) documentation for more information.

## Dynamic Firewall

The [**Dynamic Firewall**](https://docs.pritunl.com/kb/vpn/security/dynamic-firewall) provides the highest level of server security available in Pritunl. When a server is run with the dynamic firewall enabled the VPN port will not be open to the internet. The Pritunl server will block access to the port with iptables. When configured the only port open to the internet on a Pritunl server will be the web server. This design in combination with the high level of security provided from the dual web server can make a Pritunl server nearly impossible to attack from unauthenticated attackers. When using the dynamic firewall only the Pritunl Client that is updated to a supported version will be able to connect. Other OpenVPN clients are not supported. **Currently server linking is not supported with the dynamic firewall.**

To enable the option an enterprise subscription is required. In the advanced server settings enable the *Dynamic Client Firewall* option.

## Single Sign-On Connection Authentication

[**Single Sign-On Connection Authentication**](https://docs.pritunl.com/kb/vpn/sso/connection-authentication) provides an additional layer of authentication for single sign-on connections. By default when single sign-on is used in Pritunl the user will authenticate with the single sign-on provider from the Pritunl web console then import a VPN profile into a client. The VPN profile will contain a certificate and private key that will be used to authenticate the user to the VPN server. Instead of requiring the user to re-authenticate with single sign-on for each connection the Pritunl server will utilize the API from the single sign-on provider to verify the status of the user. This check will verify that the user exists and is not disabled. Most providers also support defining a single sign-on application, the API will also be used to verify the user has access to the defined application. These checks will occur for every connection even when authentication cache is enabled. If a single sign-on user were to fail the check the VPN connection would be blocked. This can be enabled in the server settings.

## Server Settings

In the server settings *DH Param Bits* should be set to either 2048 or 4096. The *Encryption Cipher* should be set to *AES 128bit GCM*. Using *AES 256bit GCM* will result in significantly slower connection speeds and reduced capacity for concurrent client connections. The *Hash Algorithm* should be set to *SHA-256*. The *Restrict Routing* option should be enabled.


# Securing MongoDB

Securing MongoDB

**Note: This is not necessary for single Pritunl servers. MongoDB by default will only allow the localhost to connect. This applies to multi-server Pritunl clusters.**

The first **MongoDB User Authentication** section will explain configuring MongoDB with password authentication. The next sections will explain configuring authentication with SSL. **It is not necessary to configure SSL on private networks or cloud VPC networks.**

### MongoDB User Authentication

Create a `admin` and `pritunl` user for the `prituinl` database in the `admin` database. First connect with the mongo cli then switch to the `admin` database. Change the `PASSWORD` below to a secure random password. When authenticating from mongo cli tools use `--authenticationDatabase admin`.

```javascript
mongo --ssl --host subnet.domain.com -u admin --authenticationDatabase admin

use admin;
db.createUser({
  user: "admin",
  pwd: "PASSWORD",
  roles: [{role: "root"}]
});
db.createUser({
  user: "pritunl",
  pwd: "PASSWORD",
  roles: [{role: "dbOwner", db: "pritunl"}]
});
```

Edit the `/etc/mongod.conf` configuration file and add the security section with authorization enabled. Then restart the mongodb service.

```shell
sudo nano /etc/mongod.conf
security:
  authorization: enabled

sudo systemctl restart mongod
```

To connect to the mongo cli with the admin account use the command below.

```shell
mongo --ssl --host 127.0.0.1 -u admin --authenticationDatabase admin
```

Test the pritunl user using the command below.

```shell
mongo --ssl --host 127.0.0.1 -u pritunl --authenticationDatabase admin pritunl
```

When configuring Pritunl the username and password option must be added to the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@127.0.0.1:27017/pritunl?authSource=admin`

### MongoDB User Authentication with SSL (Optional)

These instructions are for Oracle Linux 8. The commands for other distributions will be different. First install and start MongoDB.

```shell
sudo tee /etc/yum.repos.d/mongodb-org-5.0.repo << EOF
[mongodb-org-5.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/8/mongodb-org/5.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-5.0.asc
EOF

sudo yum -y install mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod
```

Then create an `admin` user by first connecting with the mongo cli. Once connected switch to the `admin` database and run the create user command. Change the `PASSWORD` below to a secure random password.

```javascript
mongo
use admin;
db.createUser({
  user: "admin",
  pwd: "PASSWORD",
  roles: ["root"]
});
```

After the user has been created edit the MongoDB configuration to enable ssl and authorization. The net section should be replaced with the section below. The tls section can be excluded if only password authentication is needed. Then restart the mongodb service.

```shell
sudo nano /etc/mongod.conf
net:
  port: 27017
  bindIp: 0.0.0.0
  tls:
    mode: requireTLS
    certificateKeyFile: /etc/ssl/mongodb.pem

security:
  authorization: enabled

sudo systemctl restart mongod
```

Then install certbot to get a signed ssl certificate for the server.

```shell
sudo yum -y install oracle-epel-release-el8
sudo yum-config-manager --enable ol8_developer_EPEL
sudo yum -y install certbot
```

### Route53 DNS Lets Encrypt Method

The Route53 DNS verification with certbot will make it easier to assign the DNS records for the MongoDB servers to private IP addresses. It will also allow running the MongoDB servers behind a NAT or without opening port 80.

First open the *IAM* section in the AWS management console and select *Roles*. Then click *Create Role*. Select *EC2* and click *Next: Permissions*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F3ktvJcSLdNvnKG95oSIS%2Froute53_iam0.png?alt=media\&token=613ffe6a-2139-4312-b7ee-28dcb1dc1356)

Search for `route53` and select *AmazonRoute53FullAccess*. Then name the role and finish creating it.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F4AcNXwNAFPRARmhXIlma%2Froute53_iam1.png?alt=media\&token=2e643d99-0219-4374-b3bb-87b5e7ca5360)

Once done assign this role to the MongoDB instances. Then create Route53 records for the MongoDB servers pointing to the private IP of the instance.

Alternatively an AWS access key can be created and placed in `/root/.aws/config`.

```sh
sudo mkdir -p /root/.aws
sudo tee /root/.aws/config << EOF
[default]
aws_access_key_id=KEY_ID
aws_secret_access_key=KEY_SECRET
EOF
```

Create the cron script below to automatically renew the ssl certificate and restart the MongoDB service when the certificate is renewed. Set the `EMAIL` and `DOMAIN` fields below. The certificate will only be renewed when it is close to expiring.

```shell
sudo yum -y install --setopt=obsoletes=0 python2-certbot-dns-route53

sudo tee /etc/cron.daily/certbot << EOF
#!/bin/sh
EMAIL=email@domain.com
DOMAIN=subnet.domain.com
CUR_HASH=\`md5sum /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem | cut -d ' ' -f 1\`
/usr/bin/certbot-2 --text --agree-tos --non-interactive --email "\${EMAIL}" -d "\${DOMAIN}" --dns-route53 --dns-route53-propagation-seconds 30 --preferred-challenges dns --expand --manual-public-ip-logging-ok certonly
NEW_HASH=\`md5sum /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem | cut -d ' ' -f 1\`
if [ "\${CUR_HASH}" = "\${NEW_HASH}" ]; then
    exit 0
fi

cat /etc/letsencrypt/live/"\${DOMAIN}"/privkey.pem /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem > /etc/ssl/mongodb.pem
chown mongod:mongod /etc/ssl/mongodb.pem
chmod 600 /etc/ssl/mongodb.pem
systemctl restart mongod
EOF
```

Once done enable the script and run it.

```shell
sudo chmod +x /etc/cron.daily/certbot
sudo sh /etc/cron.daily/certbot
```

### Public HTTP Lets Encrypt Method

First create a DNS record for the MongoDB servers public IP address. If a replica set is being created each replica member must have a DNS record. Create a private hosted zone in Route 53 to allow Lets Encrypt to validate the DNS record with a public IP address while still accessing the MongoDB servers with private IP addresses. This private hosted zone will override the public zone with private IP addresses.

Create the cron script below to automatically renew the ssl certificate and restart the MongoDB service when the certificate is renewed. Set the `EMAIL` and `DOMAIN` fields below. The certificate will only be renewed when it is close to expiring.

```shell
sudo tee /etc/cron.daily/certbot << EOF
#!/bin/sh
EMAIL=email@domain.com
DOMAIN=subnet.domain.com
CUR_HASH=\`md5sum /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem | cut -d ' ' -f 1\`
/usr/bin/certbot-2 --text --agree-tos --non-interactive --standalone --email "\${EMAIL}" -d "\${DOMAIN}" --preferred-challenges http --expand --manual-public-ip-logging-ok certonly
NEW_HASH=\`md5sum /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem | cut -d ' ' -f 1\`
if [ "\${CUR_HASH}" = "\${NEW_HASH}" ]; then
    exit 0
fi

cat /etc/letsencrypt/live/"\${DOMAIN}"/privkey.pem /etc/letsencrypt/live/"\${DOMAIN}"/fullchain.pem > /etc/ssl/mongodb.pem
chown mongod:mongod /etc/ssl/mongodb.pem
chmod 600 /etc/ssl/mongodb.pem
systemctl restart mongod
EOF
```

Before running the script the domain used above must point to the MongoDB servers public address and port 80 must be opened on the firewall. After the script is created change the file mode to allow execution and run the script. The first time the script is run a new certificate will be created. Running the script additional times will check if the certificate is close to expiring and renew the certificate when needed. The domain is verified by temporarily creating an http server on port 443 to allow the letsencrypt verification servers to connect and verify the domain points to the correct server.

```shell
sudo chmod +x /etc/cron.daily/certbot
sudo sh /etc/cron.daily/certbot
```

### Create Pritunl User

Then create a `pritunl` user for the `prituinl` database in the `admin` database. First connect with the mongo cli using the admin account then switch to the `admin` database. Change the `PASSWORD` below to a secure random password. When authenticating from mongo cli tools use `--authenticationDatabase admin`.

```shell
mongo --ssl --host subnet.domain.com -u admin --authenticationDatabase admin

use admin;
db.createUser({
  user: "pritunl",
  pwd: "PASSWORD",
  roles: [{role: "dbOwner", db: "pritunl"}]
});
```

Test the new use with the command below.

```sh
mongo --ssl --host subnet.domain.com -u pritunl --authenticationDatabase admin pritunl
```

### Replica Set Keyfile

A keyfile can be used to increase the security of replica sets. First generate a key on one replica member then copy this file to all other replica members.

```shell
sudo sh -c "openssl rand -base64 756 > /etc/mongod.key"
cat /etc/mongod.key
sudo chown mongod:mongod /etc/mongod.key
sudo chmod 600 /etc/mongod.key
```

Once the keyfile is on all replica members update the configuration file on each replica member.

```shell
sudo nano /etc/mongod.conf
security:
  authorization: enabled
  clusterAuthMode: keyFile
  keyFile: /etc/mongod.key

replication:
  replSetName: rs0
```

### Connecting to MongoDB

When configuring Pritunl the username, password and ssl option must be added to the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@subnet.domain.com:27017/pritunl?authSource=admin&ssl=true`

### Authentication Database

If the authentication user is on a different database the `authSource` parameter must be included in the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@subnet.domain.com:27017/pritunl?ssl=true&authSource=admin`

### Custom CA Certificate

When using a custom CA certificate with MongoDB the `ssl_ca_certs` parameter must be included in the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@subnet.domain.com:27017/pritunl?ssl=true&ssl_ca_certs=/path/to/ca.pem`


# Device Authentication

Device Authentication

Device authentication provides the highest level of assurance that each physical client device connecting to the VPN has been authorized. This system provides a high level of protection against authentication and phishing attacks. Even if an attacker is able to obtain a user VPN profile and fully compromises the users account and two-factor authentication the device making the connection would be prompted for approval when attempting to connect.

This system requires an enterprise subscription and clients running the Pritunl client on a macOS, Windows or Linux device with TPM or Secure Enclave support. The system will work with both the GUI and CLI Pritunl Client.

### TPM & Secure Enclave

The TPM is a physical chip included on the majority of laptops and desktops. The chip contains functionality to sign and encrypt information without exposing the private keys stored inside the isolated chip. Neither the client software or operating system is able to obtain the private key from the chip. This chip provides a way for the Pritunl server to validate that an incoming connection is coming from a physical device that has been approved to connect to the server.

The Apple Secure Enclave is a proprietary system that provides similar functionality. This is included on all MacBooks starting with the introduction of the touch bar and most Apple desktops starting around 2018. On Intel based Apple computers it is known as the Apple T Security Chip. On Apple Silicon computers the chip is built into the Apple processor.

### Enable Device Authentication

Device authentication does not require any API keys or third party services. After it is enabled the client will sign a connection request that is sent to the Pritunl web server prior to initiating the VPN connection. The server will then check if the device public key is approved for that user. If it is not the connection will be refused and the user will be prompted to contact an administrator to approve the device. If the public key is approved the signature for that connection request is validated using the approved public key and the connection continues to the next stages of authentication.

The option labeled *Device Authentication* is configured for each individual server. All connections to a server with the option enabled will require device authentication.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F53MN3Y0MoMgGqQ8TRH7R%2Fdevice_auth0.png?alt=media\&token=45ce7f73-a2bb-4f87-8a6f-37e002e75307)

### Approve Client Device

After this option has been enabled when a client attempts to connect the prompt below will be shown.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F0tQKyHewzUqn7WmGpzNI%2Fdevice_auth1.png?alt=media\&token=d33ea5cf-8180-4e72-9a86-d1a692aeb379)

This prompt shows the device name and a four digit PIN. The PIN is added to prevent administrators from accidentally approving the wrong device or blindly approving pending devices. It isn't relevant to the encryption process.

**The command `sudo pritunl override-device-key` allows devices to be approved without the confirmation pin for 8 hours or until `sudo pritunl require-device-key` is run. This can be used for configuring large deployments of devices when an administrator is confident all incoming device registrations are valid.**

Once a device has requested registration the pending device will be shown on both the dashboard and listed under the drop down menu for the user. Each user can only have 3 devices pending registration, attempting to register additional devices will result in a pending device being removed. There is no limit on how many approved devices can be added.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FTsvrmpJDNoBLt5XzwmsV%2Fdevice_auth2.png?alt=media\&token=10c3dc03-58be-4b69-8d94-b29b492f0d20)

The administrator will see the pending device from the dashboard and can either click *Register Device* enter the PIN and approve the device or click *Remove Device* to remove the pending registration. After the device has been approved it will be removed from the pending list and be shown in the users tab using the drop down menu under the users name. When the user connects again the connection will succeed and the device registration prompt will be removed.

### Client Key Storage

Neither the TPM or Secure Enclave store the full private key on the chip. Instead a procedurally generated key method is used to generate a key inside the chip.

For the TPM the Pritunl Client provides the TPM with a set of options such as the encryption algorithm and key sizes. The TPM takes this configuration and generates the private key internally. Even if the operating system is reinstalled or changes are made the TPM will always generate the same key.

For the Secure Enclave a long string is returned on the first use. When the Secure Enclave is provided with this string in the future it will generate the same private key. This string is used as the input to generate a private key, it is not a private key and the private key can't be compiled with this string alone. The Secure Enclave input string is not sensitive and obtaining it will not compromise the security of device authentication. The Pritunl Client stores this string in the `/var/lib/pritunl-client/pritunl-client.json` file. If this file is removed a new key will be generated on the Secure Enclave and the device registration will need to be repeated. If the client is being uninstalled and reinstalled this file should be preserved. Updating the client with the installer will not remove the file.


# Dynamic Firewall

Dynamic Firewall

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FG4ZcGbHirBiwdZAwepxy%2Fdynamic_firewall.png?alt=media\&token=8b1f7489-5fde-4a46-ae07-6031d6e984b1)

The dynamic firewall provides the highest level of security available in Pritunl. When a server is run with the dynamic firewall enabled the VPN port will not be open to the internet. The Pritunl server will block access to the port with iptables. When configured the only port open to the internet on a Pritunl server will be the web server. This design in combination with the high level of security provided from the dual web server can make a Pritunl server nearly impossible to attack from unauthenticated attackers. When using the dynamic firewall only the Pritunl Client that is updated to a supported version will be able to connect. Other OpenVPN clients are not supported. **Currently server linking is not supported with the dynamic firewall.**

This server option can be used along side existing VPN servers on the same host to support other OpenVPN clients or to allow transitioning to the dynamic firewall from servers that do not have the feature enabled.

For a client to connect the Pritunl client will first authenticate with the Pritunl web server. A Pritunl client profile includes multiple keys that allow for multiple layers of encryption. This connection approval request will utilize these keys to create three layers of authorization for the request. The components of this are explained below. Many administrators do not configure a valid HTTPS certificate and HTTPS is not relied on or required to provide secure authentication.

* **Client SHA512-HMAC Key (Authorization)**\
  The client will use a SHA512-HMAC secret to sign each connection request. The server will also use this secret to sign the response allowing the client to verify the connection response. This is the same authentication system used to authorize the client configuration sync which syncs profile configuration changes such as host addresses and server port changes (private keys are never synced).
* **Client/Server NaCl Asymmetric Key (Authorization + Encryption)**\
  The client utilizes a [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key for the server that is included in the client profile. This provides asymmetric encryption of the connection request from the client to the server. The server will encrypt the response with the clients [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key providing encryption of the response. The client will also verify the server response using the server [**NaCl**](https://en.wikipedia.org/wiki/NaCl_\(software\)) public key. This is the same authentication system used to provide the additional layer of encryption and authorization available in [**OpenVPN**](https://openvpn.net/) connections with passwords and two-factor codes.
* **Client RSA-4096 Asymmetric Key (Authorization)**\
  The clients RSA certificate and key is used to sign each connection request. The server will use this verify the client connection request. This is the same certificate used to verify [**OpenVPN**](https://openvpn.net/) connections.

Once the Pritunl server validates the connection approval request the server will open the VPN port for the requested server to the client IP addresses. Three sources are used to determine the client IP address, the client provided IPv4 and IPv6 address discovered from the Pritunl app servers and the remote address of the incoming web request on the Pritunl server.

Pritunl web servers are often run behind load balancers, by utilizing the Pritunl app servers even if the web request returns the load balancer IP address the server will still have the correct address. Additionally the Pritunl server will return the IP address of the Pritunl host that received the connection approval. This ensures the client will connect to the correct Pritunl VPN server when sending a request to multiple Pritunl web servers behind a load balancer. It is not recommended to ever configure Pritunl VPN servers behind a network load balancer as the client will already choose a server at random. When using the dynamic firewall a network load balancer cannot be used.

**An external firewall or security group will still need to be configured when using the dynamic firewall. The dynamic firewall only controls access to the VPN ports of the VPN servers that have the dynamic firewall enabled. Servers will still have other open ports such as SSH that need to be controlled externally.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F9EFRR21I4nJIq5tJ4YRh%2Fdynamic_firewall_option.png?alt=media\&token=0129fdbe-6f10-434b-a260-ed0e3e3a10db)

To enable the option an enterprise subscription is required. In the advanced server settings enable the *Dynamic Client Firewall* option.


# Authentication Cache

Client authentication cache options

Two cache modes are supported, the OpenVPN cache and Pritunl Client cache. The OpenVPN mode will cache secondary authentication on all OpenVPN clients including the Pritunl Client. This allows clients to reconnect to the server without two-step authentication when a connection is lost. The cache uses several variables to determine the client is the same. These include the clients public IP address, MAC address, random device ID, random device name and the two-factor passcode.

The Pritunl Client mode is a two day authentication cache that only supports the Pritunl Client. This uses an in memory only authentication token that is stored in the client background service process. If the client background service is closed or the computer is rebooted this token will not exist on the computers disk. This allows reconnecting without secondary authentication for two days.

### Disable Cache

The commands below will disable all authentication cache.

```sh
pritunl set app.sso_cache false
pritunl set app.sso_client_cache false
```

### Timeouts

The timeout for the two-step authentication can be set in seconds using the commands below.

```sh
pritunl set app.sso_cache_timeout 28800
pritunl set app.sso_client_cache_timeout 172800
```


# Installation

Installing Pritunl Client

### Linux

A Linux repository is available for several distributions. The instructions for installing the client from the repository can be found on the homepage [**homepage**](https://client.pritunl.com/#install). Install the `pritunl-client-electron` package for desktops and the `pritunl-client` for servers.

When adding profiles copy the *URI Link* from the profile page and paste it into the *Import Profile URI*.

### Linux Flatpak

A Flatpak is available for the Pritunl Client directly from the Pritunl repository. This can be installed with the commands below.

```shellscript
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user --if-not-exists pritunl https://repo.pritunl.com/stable/flatpak/pritunl.flatpakrepo
flatpak install --user pritunl com.pritunl.client
```

### macOS

The macOS package can be downloaded from the [**homepage**](https://client.pritunl.com/#install). After downloading extract the package from the zip file and open the package.

When adding profiles copy the *URI Link* from the profile page and paste it into the *Import Profile URI*.

### Windows

The Windows package can be downloaded from the [**homepage**](https://client.pritunl.com/#install). After downloading open the package.

When adding profiles copy the *URI Link* from the profile page and paste it into the *Import Profile URI*.

### Mobile Devices

An official Pritunl client is not available on mobile devices but any OpenVPN client can be used to connect to Pritunl.

When adding profiles on a mobile device use the blue individual profile links such as *Download Profile (Server Name)*. These are the only links on the profile download page that will work on a mobile device.

### Verify Signature

The installer files can be checked against the hashes published in the [**Pritunl Client GitHUb Repository**](https://github.com/pritunl/pritunl-client-electron/blob/master/SHA256). Additionally GPG signatures of the installers are available. All Linux packages in the repository are signed and automatically checked by the GPG key included in the repository configuration.

To verify the macOS and Windows installers signature download the `.sig` signature files from the [**Pritunl Client Releases**](https://github.com/pritunl/pritunl-client-electron/releases). Verify the signature is valid for the [**Pritunl Client GPG Key**](https://raw.githubusercontent.com/pritunl/pritunl-client-electron/master/pritunl_pub.asc) using the commands below.

`contact@pritunl.com: CB55 1723 4EC6 B1F9 7A27 4969 0ADB 523E 055C 08A4`

```shell
curl https://raw.githubusercontent.com/pritunl/pritunl-client-electron/master/pritunl_pub.asc | gpg --import
gpg --verify Pritunl.exe.sig Pritunl.exe
gpg --verify Pritunl.pkg.zip.sig Pritunl.pkg.zip
```


# Flatpak

Pritunl Client Flatpak installation instructions

A Flatpak is available for the Pritunl Client directly from the Pritunl repository. This can be installed with the commands below.

```shellscript
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --user --if-not-exists pritunl https://repo.pritunl.com/stable/flatpak/pritunl.flatpakrepo
flatpak install --user pritunl com.pritunl.client
```

To start the Flatpak client use the icon from the applications menu or run the command below.

```shellscript
flatpak run com.pritunl.client
```

### Device Authentication

To enable device authentication use the commands below to provide TPM access to the Flatpak.

```shellscript
flatpak override --user --device=all com.pritunl.client
sudo tee /etc/udev/rules.d/70-pritunl-tpm.rules << 'EOF'
KERNEL=="tpmrm[0-9]*", SUBSYSTEM=="tpmrm", TAG+="uaccess"
EOF
sudo udevadm control --reload
sudo udevadm trigger --subsystem-match=tpmrm
flatpak kill com.pritunl.client
```

This can be removed with the commands below.

```shellscript
flatpak override --user --nodevice=all com.pritunl.client
sudo rm /etc/udev/rules.d/70-pritunl-tpm.rules
sudo udevadm control --reload
sudo setfacl -b /dev/tpmrm0
```

### Terminal Interface

The terminal interface can be run from the Flatpak using the command below.

```shellscript
flatpak run --command=pritunl-client com.pritunl.client
```


# Gnome

Using Gnome OpenVPN client with Pritunl

Linux distributions using Gnome with NetworkManager (Fedora, RedHat, Ubuntu) have good OpenVPN support and will be able to import Pritunl profiles. This is also currently the only way to get NetworkManager to use the DNS configuration from the Pritunl server. Profile sync isn't supported and some authentication modes may not work as well. To import the profile click *Download Profiles* on the profile view page, this may require clicking *Show More* at the bottom. Then extract the profile from the archive and run the command below to import the profile, update the paths and names to match the downloaded profile. Currently NetworkManager will always forward all internet traffic over the VPN this will break the internet connection if the Pritunl server isn't configured to route all traffic. If the Pritunl server isn't configured to route all traffic the commands at the bottom must also be run to disable the default route. Once done the OpenVPN profile will be shown in the top right menu.

```shell
nmcli connection import type openvpn file Downloads/org_linux_dev.ovpn

nmcli connection
NAME           UUID                                  TYPE      DEVICE 
eno1           f743c99d-3d96-4cfd-bb1c-60579b35f96f  ethernet  eno1   
virbr0         be40c4da-4a92-499e-abfe-c54c93d717f4  bridge    virbr0 
org_linux_dev  fa27689f-a323-41d7-a0fe-595e4486e883  vpn       --     

# If all internet traffic is not being routed over VPN run this
nmcli connection modify org_linux_dev ipv4.never-default true
nmcli connection modify org_linux_dev ipv6.never-default true
```


# WireGuard Client

Configure WireGuard client

For clients to use [**WireGuard**](https://www.wireguard.com/) it must first be enabled and configured on the server. Once the server has [**WireGuard**](https://www.wireguard.com/) configured an *OpenVPN* and *WireGuard* button will be shown in the client to allow selecting a protocol when connecting. The server must allow the client to access the HTTPS port to allow [**WireGuard**](https://www.wireguard.com/) connections to be authenticated.

After  [**WireGuard**](https://www.wireguard.com/) is enabled on the server the client configuration must be updated. If the server has a subscription the configuration sync feature will automatically update the configuration on the connection. Otherwise the profile will need to be reimported into the client.

### Linux Client

[**WireGuard**](https://www.wireguard.com/install/) must be separately installed on the client. Below is instructions for Fedora.

```shell
sudo dnf install wireguard-tools
```

The client will determine if WireGuard is installed by checking for the exec `wg` and `wg-quick` in the `$PATH`.

### Windows Client

The Windows client comes bundled with [**WireGuard**](https://www.wireguard.com/install/) and requires no changes on the client.

### macOS Client

The macOS client comes bundled with [**WireGuard**](https://www.wireguard.com/install/) and requires no changes on the client.


# Command Line Interface

Pritunl command line interface usage

The `pritunl-client` package is available on Linux for installing the Pritunl Client on servers without the GUI interface.

### Configuring a Profile

To add a profile run the command below with a URI link from the Pritunl server web console.

```shell
# Import Pritunl URI profile
pritunl-client add pritunl://demo.pritunl.com/ku/rBCDSgw5

# Import Pritunl tar profile
pritunl-client add pritunl_user_profile.tar
```

When the profile is first added it must be manually started. First run `pritunl-client list` to get the ID of the profile. Then start the profile, partial IDs can be used. To start the profile with OpenVPN add the argument `--mode=ovpn` for WireGuard use `--mode=wg`.

```shell
pritunl-client list
pritunl-client start 5ac --mode=ovpn
```

All profiles will start on startup and a configuration sync will be done before connecting. If the client disconnects a profile sync will run before reconnecting. This allows making modifications to the Pritunl server without needing to make changes on the client. It is not recommended to configure auto starting profiles that require two-factor authentication.

### macOS

The macOS CLI client is available at `/Applications/Pritunl.app/Contents/Resources/pritunl-client`.

### Windows

The Windows CLI client is available at `C:\Program Files (x86)\Pritunl\pritunl-client.exe`.


# Terminal User Interface

Using Pritunl Client terminal user interface

The Pritunl Client includes a terminal user interface available on Linux, macOS and Windows. This allows managing profiles without running the GUI application.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FRWWixHGNrE49o2VN0Wrx%2Fclient_tui.png?alt=media&amp;token=edd626bd-cb82-43e9-bea1-9c1490d674d6" alt=""><figcaption></figcaption></figure>

### Linux

For linux the package `pritunl-client` will install only the terminal interface. The `pritunl-client-electron` package will install the terminal interface and GUI. Once installed the terminal interface can be started with the commands below.

```shellscript
pritunl-client
```

For Flatpak installations use the command below.

```shellscript
flatpak run --command=pritunl-client com.pritunl.Client
```

### macOS

The terminal interface is included with the macOS installer. Run the command below to use the terminal interface.

```shellscript
/Applications/Pritunl.app/Contents/Resources/pritunl-client
```

### Windows

The terminal interface is included with the Windows installer. Run the command below to use the terminal interface.

```shellscript
C:\PROGRA~2\Pritunl\pritunl-client.exe
```


# DNS Issues

Fix DNS issues

### DNS Proxy

When the *VPN Client DNS Mapping* option is enabled in the server settings, the Pritunl server will run a DNS server using the `pritunl-dns` process. This DNS server proxies all DNS requests from the client, which can resolve many issues related to DNS servers—particularly those with access control configurations.

### Systemd Resolve

If the Pritunl server is using systemd-resolve this can bind to port 53 which will prevent client DNS mapping from working. Run the commands below to check if port 53 is in use and to disable the DNS stub listener if the system is using systemd-resolve. This should not be done if the server does not use systemd-resolve.

```sh
sudo netstat -tulpn

sudo systemctl status systemd-resolved

sudo nano /etc/systemd/resolved.conf
[Resolve]
DNSStubListener=no

sudo systemctl restart systemd-resolved
```

### AWS DNS

The internal AWS DNS server will require the *VPN Client DNS Mapping* option to be enabled in the server settings.

### Routing DNS Server

In some cases the DNS server needs to be added to the server routes.

### Disable DNS Server

Clearing the *DNS Server* option in the server settings will leave the clients DNS servers unmodified.

### Web-Proxy Auto Discovery

Some ISPs will use Web-Proxy Auto Discovery to interfere with DNS settings. This can cause issues for some VPN connections. If issues are occurring this feature should be disabled.

### Ubuntu AppArmor

The Ubuntu AppArmor profile will block OpenVPN DNS scripts from running. To allow Pritunl to configure DNS for OpenVPN connections the command below must be run to disable the OpenVPN AppArmor profile.

```shellscript
sudo apparmor_parser -R /etc/apparmor.d/openvpn
```

This can be reverted by running the command below.

```shellscript
sudo apparmor_parser -a /etc/apparmor.d/openvpn
```

### macOS

To disable WPAD on macOS ensure all protocols are disabled in the advanced network interface settings.

![](https://files.readme.io/9ccc359-macos_proxy.png)

### Windows

To disable WPAD on Windows uncheck *Automatically detect settings* in the network *Proxy* settings.

![](https://files.readme.io/c8aee98-windows_proxy.png)

### iOS

There are currently three fixes for the DNS issue on iOS.

Add the DNS server to the server routes. The default DNS server used is `8.8.8.8` add the route `8.8.8.8/32` to the server routes for this configuration.

Remove the DNS server from the settings. This will instruct the client to use their current DNS configuration. This could cause problems with some clients if that DNS configuration becomes unroutable due to the VPN routes.

Enable *VPN Client DNS Mapping* in the advanced server settings. This will start a DNS server on the Pritunl server that will proxy all DNS requests and will always be available to the client.


# Silent Automated Install

Automate Windows client installation

The Windows client can be run with the options `/SILENT` or `/VERYSILENT`. These options can be used to automate installs and run unattended installations with deployment systems. The silent option will run the installer with the dialog shown and confirm all prompts. The very silent option will run the installer in the background without any visible windows or prompts.

**Currently the installer kills all processes named Pritunl.exe to close the GUI application before updating it. This has the effect of also causing the installer to fork to a new process if the installer has the same Pritunl.exe name. When doing automated installs the installer filename should be renamed to avoid this issue.**


# Google

Single sign-on with Google

Pritunl supports single sign-on with Google Workspace. This allows users to use their Google employee account to authenticate with Pritunl. Oauth is used to authenticate users, re-authentication is also done on each connection. When a Google user is removed or disabled they will no longer be able to connect to a Pritunl server. To start set the *Single Sign-On* to *Google* and set the *Google Apps Domain*. The domain should be the domain used for the business Gmail such as `pritunl.com`. Multiple domains can be separated by a comma. The single sign-on organization will control which organization Google users are added to.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FvfLoVZQ59Az0JqcTcTuG%2Fgoogle_org6.png?alt=media\&token=74506c28-de7e-45a1-99cf-dd5409c378c3)

Once configured a *Sign in with Google* button will appear on the login page.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FeBcfXEzUs6EVfZUOpEaS%2Fgoogle1.png?alt=media\&token=18e19a43-2226-48ae-8e30-cbed9f52fe69)

After a user clicks *Sign in with Google* they will be prompted to approve the Oauth login. Then they will be directed to their VPN profiles.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FaaMtt30Iq9RWsFqiRREM%2Fgoogle2.png?alt=media\&token=4557569a-fd9e-4c7b-8b81-7acd97ce08d1)

### Match Groups to Organizations

By default Google Workspace allows all employees to create groups. Before using organization group matching update the Google Workspace settings to prevent users from creating groups.

For Google Workspaces open Apps -> Google Workspace -> Settings for Groups for Business -> Sharing Settings. Then select *Only organization admins can create groups*.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FCLsvn1T354vgamkbSbjF%2Fgoogle_groups_permissions.png?alt=media&amp;token=5322d4eb-5da2-42bb-be82-27b25bf0988f" alt=""><figcaption></figcaption></figure>

From the [**Google Workspace Admin Console**](https://admin.google.com/) search for `Google Cloud Platform` and select *Settings for Google Cloud Platform*. Then enable the service.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FaV7Fg9bbi9HCe3YTLcHE%2Fsso_google0.png?alt=media\&token=78f03faf-1532-4d9f-9f9f-feceab5dcd1b)

Open the [**Google Cloud Console**](https://console.cloud.google.com/) and create a project if one does not already exist.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fc9KENHQAA0kBqagzayqo%2Fsso_google1.png?alt=media\&token=731a37dc-6333-45e2-9a27-4a17abf1ced6)

Either open the [**Admin SDK API Settings**](https://console.cloud.google.com/apis/library/admin.googleapis.com) or use the search from the cloud platform console to search for `Admin SDK API`. Then click *Enable*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FrxTb7Iy3uMRbHDZmag0N%2Fsso_google11.png?alt=media\&token=a950fee1-6f77-4a0e-9c33-1f1c54c52f55)

From the navigation menu select *IAM & Admin* then *IAM*. From the *IAM* page open *Service Accounts*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fe1qZBCH28aCP0NYobeSn%2Fsso_google2.png?alt=media\&token=0670748f-ed63-430e-af5c-791aa78ca57f)

Click *Create Service Account* and name the service account `pritunl`. Then click *Create and Continue*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FGE0y8qSZC97fDR7wHWD9%2Fsso_google3.png?alt=media\&token=3047b0bc-08fc-4aaf-a4e9-94a4713f7be9)

Click *Add role* and select *Service Accounts* then select *Service Account User*. Click *Continue* then click *Done* to create the service account.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F0qzKOydqrbc8NemazJcx%2Fsso_google4.png?alt=media\&token=70d0d629-e3c2-420b-aeb5-0ad27f227276)

Click the menu button for the user under *Actions* then click *Manage keys*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FH2Fa8tFedzXRv4rYOuZr%2Fsso_google7.png?alt=media\&token=53dc4551-9456-47c9-8af2-2fefb3292ec7)

Click *Add Key* and *Create new key*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAkR7r0FNqlK01ykU82yp%2Fsso_google5.png?alt=media\&token=d09f1d7b-975e-40c3-a5bb-4403d7559723)

Set the *Key type* to *JSON* and click *Create*. The key will be downloaded in json format.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fv2swPcT2Yw9sLrY0HnNZ%2Fsso_google6.png?alt=media\&token=0ade4169-4807-4165-bd90-55f6ba0c18f2)

Either open the *Details* tab from the keys page or click *Manage details* from the user actions menu.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FT9twnyN4ZkhCabJ8aqud%2Fsso_google8.png?alt=media\&token=4bc986bc-84c1-4012-9235-fbd478b49d42)

Copy the *Unique ID* shown for the next steps.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fc3spMUJoa9eVIGZ8aFpj%2Fsso_google12.png?alt=media\&token=67ec0d80-0ff9-4b03-983c-dc1a59670370)

Go to the [**Google Workspace Admin Console**](https://admin.google.com/) and select *Security* then *Access and data control* then *API controls* from the menu. Enable *Trust internal, domain-owned apps*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FLHkSYJqxiKAEqGXhOQSw%2Fsso_google15.png?alt=media\&token=59ea82e8-eae7-4f34-87e1-5117f95a4fa1)

Once done click *Manage Domain Wide Delegation*. Then click *Add new* then enter the *Client ID* from the previous steps. Set the *OAuth scopes* to `https://www.googleapis.com/auth/admin.directory.user.readonly, https://www.googleapis.com/auth/admin.directory.group.readonly` and click *Authorize*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FC4WrUUPreJtXmlexYvx9%2Fsso_google14.png?alt=media\&token=e0ba8b33-0dc4-4a6d-98e3-30a9d2c9d545)

Open the settings from the Pritunl web console and verify the *Google Apps Domain* is set to the correct company domain. Then set the *Google Admin Email* to any Google Workspace administrators email, this is used by the Google Cloud API to discover the Google Workspace Domain. Open the json file that was downloaded from the previous steps and copy the key to *Google JSON Private Key*. Then click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F09aB4YwuxoesWQf5zE1j%2Fsso_google10.png?alt=media\&token=71250fbc-246f-42c3-a8a2-e220c76e9ba2)

Once done the Pritunl user will be created in the matching organization when authenticating with Google. The logs will display what names are discovered when a user authenticates.

### Configure Pritunl Zero

For Pritunl Zero these same options can be found in the *Settings* tab.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAtBUbVSCwCOrlbZVQQjv%2Fgoogle_sso_zero.png?alt=media\&token=f9aa5a09-001b-4f20-9e56-523cf3642bf0)


# Okta

Single sign-on with Okta

This tutorial will explain configuring Okta for single sign-on to Pritunl. Users will authenticate through Okta when downloading VPN profiles. After a user has downloaded a VPN profile the Pritunl server will use the Okta API to verify that the user still exists and is enabled before each VPN connection.

### Okta Push

Okta Push can be enabled for each VPN connection if it is available. If you are using Okta Push but do not want it used for VPN connections uncheck *Enable Okta Push* in the settings. This configuration option is stored in the database and will only need to be run on one host. The change will be immediately applied to all hosts and will not require restarting any hosts.

### Create Pritunl App on Okta

In the *Applications* section of the admin interface click *Add Application*. Then click *Create New App* and select *SAML 2.0*

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FnOdIRSjkH4AxHs9bTvXg%2Fokta0.png?alt=media\&token=ea87b381-0bc3-4580-b98c-54925e6ddb01)

Next name the app `Pritunl` and download the Okta Pritunl logo [github.com/pritunl/pritunl-artwork/sso/pritunl\_okta.png](https://raw.githubusercontent.com/pritunl/pritunl-artwork/refs/heads/master/sso/pritunl_okta.png) and click *Upload Logo* then click *Next*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FgM9kyhDa3fopIUEH3OhG%2Fokta1.png?alt=media\&token=bf631ff8-d100-4143-9933-4ac8e8498560)

On the next page enter `https://auth.pritunl.com/v1/callback/saml` as the *Single sign on URL* and `pritunl` as the *Audience URI*. Set the *Default RelayState* to the address your users would use to access the Pritunl server such as `https://vpn.pritunl.com`. Then add the two attributes `username` with a value of `user.login` and `email` with a value of `user.email`. Once done click *Next* then *Finish*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FFedTLIOKhUnt9kGkTZsv%2Fokta3.png?alt=media\&token=be39e901-922a-4d57-bbd1-828415e6c73e)

### Setting User Organization

By default all Okta users will be added to the default organization set in the Pritunl settings. Users can be added to a specific organization using the `org` attribute. This attribute can be mapped to a value such as `user.department`. The value of the attribute must exactly match the name of an existing organization on the Pritunl server. If a value is given for an organization that does not exist the user will be added to the default organization. Okta provides several mapped values for attributes. Refer to the Okta documentation for setting the value of the `org` attribute to best match Pritunl organizations.

More information on these values is available in the [**Okta Expression Language documentation**](https://developer.okta.com/docs/reference/okta-expression-language/).

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FQGIpBfG4XWnf2jcRpcyd%2Fokta4.png?alt=media\&token=48d0d942-2ae1-4acd-aa59-20f5d02de326)

### Create API Token

Pritunl will require an API token to validate if a user exists and is enabled before allowing a VPN connection. To create a token click *Security* then *API* and *Create Token*. Name the token `Pritunl` and save the token for later.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FbpS9VAp14yHfifNjYgmH%2Fokta5.png?alt=media\&token=ef7bbba7-8f4b-441d-a0dd-a83320e544be)

### Add Users to Pritunl App

After the Okta app has been created you will need to add users to the Pritunl app before they are able to use it. This can be done in the *People* tab on the Pritunl app settings on Okta.

### Okta App ID

Next get the Okta app ID from the url in the Okta application settings. The ID is the last component of the URL. For example the ID for this url `https://pritunl-dev-admin.okta.com/admin/app/pritunlorg473326_pritunl_1/instance/0oarolrfv30ouSTcm2p6/#tab-signon` is `0oarolrfv30ouSTcm2p6`. This ID will be needed in the next step.

### Configure Pritunl

Once the Okta app has been configured click on the app then click *Sign On* and *View SAML setup instructions* on the right side. Then open the Pritunl settings and set *Single Sign-On* to *Okta* and set the *Single Sign-On Organization*. This organization will be the default organization Okta users are added to. Set the *Okta App ID* to the ID from the previous step. Then copy the *Identity Provider Single Sign-On URL* to *SAML Sign-On URL*. Then *Identity Provider Issuer* to *SAML Issuer URL*. Then *X.509 Certificate* to *SAML Certificate*. Use the API token from earlier to fill in *Okta API Token*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FnOpqWLwdfE2moGovU35w%2Fokta6.png?alt=media\&token=ecc0d7e3-70e4-41d7-a087-ea7328c5c3d7)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FlSCGeoeew696ZymFOoyb%2Fokta7.png?alt=media\&token=07799913-c040-41e4-b328-084519a8eb57)


# OneLogin

Single sign-on with OneLogin

This tutorial will explain configuring OneLogin for single sign-on to Pritunl. Users will authenticate through OneLogin when downloading VPN profiles. After a user has downloaded a VPN profile the Pritunl server will use the OneLogin API to verify that the user still exists and is enabled before each VPN connection.

### Create Pritunl App on OneLogin

In the OneLogin admin interface select *New App* and search for *SAML Custom Connector (Advanced)*. Then change the name to `Pritunl` and download the OneLogin Pritunl logos [github.com/pritunl/pritunl-artwork/sso/pritunl\_onelogin.png](https://raw.githubusercontent.com/pritunl/pritunl-artwork/refs/heads/master/sso/pritunl_onelogin.png) and [github.com/pritunl/pritunl-artwork/sso/pritunl\_onelogin\_square.png](https://raw.githubusercontent.com/pritunl/pritunl-artwork/refs/heads/master/sso/pritunl_onelogin_square.png). Then upload both logos and click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fnx88bstVB4XHRwh7TARV%2Fonelogin0.png?alt=media\&token=1c1e5ad3-1d45-472f-b220-a902491d6ebc)

On the next page open *Configuration* and set the *RelayState* to the address your users would use to access the Pritunl server such as `https://vpn.pritunl.com`. Set the *Audience* to `pritunl`. Then enter `https://auth.pritunl.com/v1/callback/saml` as the *Recipient*, *ACS (Consumer) URL Validator* and *ACS (Consumer) URL*. Once done click *Save* and click the *Parameters* tab.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FVl3ecusgdJuQgNFoeFSg%2Fonelogin1.png?alt=media\&token=48c2b777-c7a7-4df7-874b-70a03683796f)

On the parameters tab click *Add parameter* and set the *Field name* to `username` and select *Include in SAML assertion* then click *Save*. Then click on the parameter and set the *Value* to `Username`. Do this again using `email` as the name and `Email` as the value.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FdF9MhevNcslMBYunZhZE%2Fonelogin2.png?alt=media\&token=81b3eb63-46ae-4998-853e-ae0bfa5b8f17)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FkHgUA9DWU53HqzrxEfEc%2Fonelogin3.png?alt=media\&token=68301c63-6b3f-4a0c-9f4a-7bad22d0143b)

### Setting User Organization

By default all OneLogin users will be added to the default organization set in the Pritunl settings. Users can be added to a specific organization using the `org` attribute. This attribute can be mapped to a value such as `Department`. The value of the attribute must exactly match the name of an existing organization on the Pritunl server. If a value is given for an organization that does not exist the user will be added to the default organization. OneLogin provides several mapped values including macros for more customized values. Refer to the OneLogin documentation for setting the value of the `org` attribute to best match Pritunl organizations.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FjqglzyAtlCrh5volZI22%2Fonelogin4.png?alt=media\&token=b1ae1e8e-5b6d-4ae8-bd1a-6fb39201bfad)

### Create API Token

Pritunl will require an API token to validate if a user exists and is enabled before allowing a VPN connection. To create a token click *Settings* then *API* and *New Credential*. Name the token `Pritunl` then select *Manage All* and save the token for later.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FfLVWO1iAu7Nog6Be1uDr%2Fonelogin7.png?alt=media\&token=75b1598b-544d-4e6b-a07d-43746931bfb8)

### Add Users to Pritunl App

After the OneLogin app has been created you will need to add users to the Pritunl app before they are able to use it. This can be done in the *Users* tab on the Pritunl app settings on OneLogin.

### OneLogin App Id

Next get the OneLogin app ID from the url in the OneLogin application settings. The ID is the last number component of the URL. For example the ID for this url `https://pritunl.onelogin.com/apps/581429/edit` is `581429`. This ID will be needed in the next step.

### Configure Pritunl

Once the OneLogin app has been configured click on the app then click *Sign On* and *View Setup Instructions*. Then open the Pritunl settings and set *Single Sign-On* to *OneLogin* and set the *Single Sign-On Organization*. This organization will be the default organization OneLogin users are added to. Set the *OneLogin App ID* to the ID from the previous step. Then copy the *SAML 2.0 Endpoint (HTTP)* to *SAML Sign-On URL*. Then *Issuer URL* to *SAML Issuer URL*. Then *X.509 Certificate* to *SAML Certificate*. Use the API token from earlier to fill in *OneLogin API Client ID* and *OneLogin API Client Secret*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FA7sfu7ZCxgYEnc0FyZo0%2Fonelogin5.png?alt=media\&token=61666a3b-da00-4776-aae3-2513d9360431)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FCO4yzH3kWYUmBHaXeQYM%2Fonelogin6.png?alt=media\&token=f3e512ef-2c36-49fa-bd10-b3ada2872da8)

### OneLogin API Region

When using OneLogin from the EU the command `sudo pritunl set app.sso_onelogin_region '"eu"'` must be run on one Pritunl host.


# JumpCloud

Single sign-on with JumpCloud

**Although JumpCloud includes a pre-configured Pritunl application, this configuration was done incorrectly by JumpCloud and should not be used. Instead create a custom SAML application as shown below.**

In the JumpCloud admin console click *New Application* then at the bottom click *Custom SAML App*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FoqzwVKopxCsuL3UznGht%2Fjump0.png?alt=media\&token=6af7a79c-085b-467b-92aa-7901ae168f0e)

Set the *Display Name* to `Pritunl` then open the *SSO* tab at the top.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F5TzrYaUgjk4u9m09C7VP%2Fjump1.png?alt=media\&token=5d7f6f57-afd2-4f47-a0eb-2375685585d3)

From the *SSO* tab scroll to the bottom and set *IDP URL* to `pritunl` followed by random numbers. This URL must be unique to other JumpCloud users. This URL will be needed in the next step.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FR3gIG6Hsee98SuiTrPbf%2Fjump2.png?alt=media\&token=256303e5-ab06-4b89-8bed-88c119c9007d)

Set the *IdP Entity ID* to `https://sso.jumpcloud.com/saml2/pritunl` followed by the same numbers in the URL from the previous step. Then set the *SP Entity ID* to `pritunl` and the *ACS URL* to `https://auth.pritunl.com/v1/callback/saml`. Enable both *Sign Assertion* and *Declare Redirect Endpoint*. Then set the *Default RelayState* to the URL of your Pritunl server. Set the *Login URL* to the URL of your server with the path `/sso/request`

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FC3I9CdYUf8SiWSvUQgTN%2Fjump3.png?alt=media\&token=de28e2a1-42b9-4d6b-a5b4-9bd9f69a5a9a)

To map group names to organizations in Pritunl the JumpCloud group name must match an existing organization name in Pritunl. To use this feature enable *include group attribute* and set the value to `org`.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FkoTXP6HJxhg1U20AGKCw%2Fjump4.png?alt=media\&token=36ac15dd-cac8-4fc3-839b-5ea63f8718f0)

Once done click *Activate* then open the application page. In the *SSO* tab of the SAML application copy the URL in *IdP Entity ID*. This will be needed in the next steps. While on this page copy the app ID from the URL. In this example the page URL is `https://console.jumpcloud.com/#/sso/61c44c96b87e5f50453473cf/details`, the app ID in this URL is `61c44c96b87e5f50453473cf`. This ID will be needed later.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FMXnc60nBCKAJsTO9SHC6%2Fjump5.png?alt=media\&token=66107146-86aa-4586-bf7d-fbcc3f19bd37)

On the left side click *IDP Certificate Valid* then select *Download certificate*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FVYJ3tKg9UDzkD3s1dqoE%2Fjump6.png?alt=media\&token=b56545a9-4c1b-417e-8b7b-c7405463e429)

Open the downloaded certificate in a text editor to copy for the next steps.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F4EsIitzTZgoDNH7k7e9i%2Fjump7.png?alt=media\&token=080415f9-1221-4be0-b72d-9a11bfb6dc3b)

From the JumpCloud administrator console click the user icon in the top right then click *API Settings*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FgRZHLvSTnzk6Vi2WrnRd%2Fjump10.png?alt=media\&token=94f19584-0615-4e10-b715-e4d9d9442682)

Copy this API key for the next step.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FGWojO5KIX01YinuQap1t%2Fjump8.png?alt=media\&token=33fcf005-1ffc-4b9b-83e7-b057cf4ae266)

In the Pritunl web console click *Settings*. Set the *SAML Sign-On URL* and *SAML Issuer URL* to the *IdP Entity ID* from the previous steps. In this example `https://sso.jumpcloud.com/saml2/pritunl` is used. Copy the certificate downloaded in the previous steps to the *SAML Certificate* field. Set the *JumpCloud App ID* to the app ID from the URL in the previous step. Then set the *JumpCloud API Key* to the API key from the previous step.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FWcxmdMNp5GdFGMJW8uvs%2Fjump9.png?alt=media\&token=5e55460c-ebff-4ac0-a90c-54f68d2a67a0)


# Auth0

Single sign-on with Auth0

Pritunl supports single sign-on with Auth0, the Auth0 authorization extension is used to match Auth0 user groups with a Pritunl organization.

### Auth0 Application

Open the *auth0* dashboard and click *Applications* then select *Create Application*. Name the application `Pritunl` and select *Regular Web Applications*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FKHDhZ3fKuWqr64zEDov3%2Fauthzero0.png?alt=media\&token=334865f1-63a9-4fe4-9357-53117d7acf96)

In the application settings set the *Application Logo* to `https://pritunl.com/img/logo.png` then set the *Allowed Callback URLs* to `https://auth.pritunl.com/callback/authzero`. Once done click *Save Changes*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FRmc8BnKiNaYTlgJfGgbz%2Fauthzero1.png?alt=media\&token=748bd732-4e36-4e4a-a4b9-dbd6daae90c1)

### Auth0 Management API

Open the *APIs* tab in the Auth dashboard and select *Machine to Machine Applications*. Then enable the *Authorized* for *Pritunl*. In the drop down menu enable the *read:users* scope. Once done click *Update*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FJnvutrlhY7WzAD0Z7qeI%2Fauthzero2.png?alt=media\&token=75c466be-ec07-4199-88c8-3886f3846261)

### Authorization Extension

If the authorization extension already exists skip the first step to create it. In the *Extensions* tab of the Auth0 dashboard click *All Extensions* and select *Auth0 Authorization*. Then select *install*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F6paUbPaY5Z3tXecCs7Ol%2Fauthzero3.png?alt=media\&token=6397ec7c-7f45-4a43-b8d7-c724ca069390)

Click on the *Auth0 Authorization* extension to open the extension dashboard. Then in the top right menu click *Configuration*. At the bottom of the configuration page enable *Groups* and *Roles* in the *Persistence* section. Then at the top click *Publish Rule*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F1XHbxOR7zDk7e6ym9NUp%2Fauthzero4.png?alt=media\&token=c0f1b842-c8d2-4c04-a9bc-37a51a77b1c4)

### Configure Pritunl

Open the *Applications* section in the Auth0 dashboard and select the *Pritunl* application. Click *Reveal client secret* and copy the *Client ID* and *Client Secret*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FMDFao4OrKu3a3QY0Nmko%2Fauthzero5.png?alt=media\&token=2189a703-3519-4fd8-a46a-b86bddda79d1)

In the Pritunl management interface open the *Settings* and set *Single Sign-On* to `Auth0`. The *Default Single Sign-On Organization* will be used if an existing organization does not match one of the users Auth0 groups. Then enter the *Auth0 Sub-Domain*. It must be the first portion of the Auth0 domain excluding the Auth0 domain, this domain is shown in the application settings page above. For this example configuration the domain is `pritunl`. Then copy the *Client ID* and *Client Secret* from the step above. Once done click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FdTACjkeUie3JHjVLWjlb%2Fauthzero7.png?alt=media\&token=79633e23-c031-42f0-a46c-b84d753f1072)


# Azure

Single sign-on with Azure

Pritunl supports single sign-on with Azure Entra ID. Azure Entra *Security* and *Office 365* groups will be matched to existing organizations.

### Restrict Groups Management Access

By default Azure Entra allows all users to create groups. If you plan on using groups to control access to Pritunl non-administrator users should be restricted from creating groups.

To do this open Microsoft Entra ID then select Manage -> Groups -> Settings -> General. Then set the *Security Groups* and *Microsoft 365 Groups* options to no.

<figure><img src="https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FpVt53cPs6xl2PbjViiYX%2Fazure_groups_permissions.png?alt=media&amp;token=868ad2c6-d264-4076-b636-839f86550000" alt=""><figcaption></figcaption></figure>

### Create Microsoft Entra Application

Open the [**Microsoft Entra** ](https://entra.microsoft.com/)​[**admin center**](https://entra.microsoft.com/) by selecting it from the Azure portal or by going to [**entra.microsoft.com**](https://entra.microsoft.com/) .

From the left panel select *Applications* then *Enterprise applications*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FkfdnIstxl1rM78UGXBo1%2Fentra_sso1.png?alt=media\&token=45fa158f-19df-4f16-89a1-694469016373)

Click *New application* then *Create your own application*. Set the *Name* to `Pritunl` then select *Register an application to integrate with Microsoft Entra ID (App you're developing)*. Then click *Create*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FVGFSAFi0yXofU6HL3Vtn%2Fentra_sso2.png?alt=media\&token=ca91d502-d0ac-4e2f-bf47-f53a5017d4a7)

On the application registration set *Supported account types* to *Accounts in this organizational directory only (Pritunl only - Single tenant)*. Then set *Redirect URI (optional)* to *Web* and enter `https://auth.pritunl.com/callback/azure`. Then click *Register*. **It is very important that the&#x20;*****Supported account types*****&#x20;option is configured correctly. If this were not set to a single tenant any user with a Microsoft account could access the Pritunl server. If a multi tenant configuration is required the&#x20;*****Assignment required*****&#x20;option described below must also be used to control what external organizations can access the application.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fx5FiE83gOK7IPdPJDWve%2Fentra_sso3.png?alt=media\&token=705809b2-e132-485e-8b8c-c39d27dd22d4)

From the left panel select *Applications* then *App registrations*. Then click *All applications* and open the Pritunl application.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FW8Y5V0KTx3lgaVET2gEW%2Fentra_sso4.png?alt=media\&token=e1b84a77-79fd-4673-9b4b-e093b5d41a80)

Open *Branding and Properties* and upload the [**Pritunl Logo**](https://pritunl.com/img/logo.png). Set the *Home page URL* to the URL of your Pritunl server. Then click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F28Gftkcb7f4ZMkOqIT1m%2Fentra_sso5.png?alt=media\&token=e6c7895d-9411-4de6-9034-17d5e52b629f)

Open the *Authentication* tab and set *Implicit grant and hybrid flows* to *Access tokens (used for implicit flows)*. Then click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FLXdQuh0r0Rq3jrT9Rooe%2Fentra_sso6.png?alt=media\&token=2155ca08-8efb-42e4-ac79-632c5da3009a)

Open *API permissions* and click *Add a permission*. Then click ***Microsoft Graph*** and select ***Delegated permissions***. Search for `User.Read` and select *User.Read*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FompPHFwnAdU2PRHcEaku%2Fentra_sso7.png?alt=media\&token=e5315933-12e4-46dd-bad7-acc329a4553e)

Next search for `Group.Read` and select *Group.Read.All*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F1UrTd3wLNkUrlr2GQ5qd%2Fentra_sso8.png?alt=media\&token=698dcb5a-9b26-4cf6-a1ec-51a9ca3848b9)

Next search for `offline_access` and select `offline_access`. Then click *Add permissions*

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F4CKEYJ1ypH3xgCQ2vSAE%2Fentra_sso16.png?alt=media\&token=a2e2f613-6885-4f28-8600-549db51e9c5b)

Next click *Add a permission*. Then click ***Microsoft Graph*** and select ***Application permissions***. Search for `Directory.Read` and select *Directory.Read.All*. Then click *Add permissions*. This gives the Pritunl server access to lookup the Azure users groups for group to organization matching.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F1qDDJm9BWdnd9fTsZbAn%2Fentra_sso9.png?alt=media\&token=6659eefd-1a0b-4cb9-9897-fe4153eea78e)

From the *API permissions* panel the permissions shown below should all be listed. After confirming this click *Grant admin consent for Pritunl*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FHrrPqNScCZ1xhcjhSObY%2Fentra_sso10.png?alt=media\&token=1060fab9-905f-4d87-bac7-b6b082010f96)

After this all permissions should have the status shown below.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FT5aeKySmLvs9KbykLqmP%2Fentra_sso11.png?alt=media\&token=08e2e498-ced2-45ba-99ce-0868297312eb)

Open *Certificates & secrets* and click *New client secret*. Then set the *Description* to `Pritunl` and set *Expires* to the maximum value available. Once done click *Add*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FvY6htK745fYynMbr3uy2%2Fentra_sso12.png?alt=media\&token=5a02dbb4-2156-47e4-a901-d526338696ed)

On the *Certificates & secrets* page copy the *Value* from the list of secrets. **The&#x20;*****Secret ID*****&#x20;is not relevant and should not be copied.** Save this value and label it **Azure Application Secret** for the steps below.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FxnL4vu70eWlUIXLXXblj%2Fentra_sso13.png?alt=media\&token=700cb006-4a7e-4826-b26a-2e247e15b381)

### Entra App Permissions

From the [**Azure Portal**](https://portal.azure.com) open *Microsoft Entra ID* then from the sidebar select *Manage* then *Enterprise applications*. This should display a list of the enterprise applications. This section is different from the previous *App registrations* section and contains different options.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FKxPTpXaVmcRnTRkU9qP8%2Fentra_sso17.png?alt=media\&token=b8ccd4f0-b102-4d37-8ecf-60941f5e0176)

Select the *Pritunl* application to open the application management. This section will allow controlling access to the application and adding users. From the sidebar select *Manage* then *Properties*. This will display the *Assignment required* option. By default all users in the Azure organization will be able to access the Pritunl server. Turning assignment required on will require that users or a users group are manually added to the application from this management console. It is recommended to use this option for more secure and controlled access to the Pritunl server. Once done click *Save* at the top.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fka69tVszsueQo1ZWxv70%2Fentra_sso18.png?alt=media\&token=28efe236-73f7-4ba8-adad-6046823047ec)

Next from the sidebar select *Security* then *Permissions* and click *Grant admin consent for Pritunl*. Then complete the prompts to approve the permissions.

### Configure Pritunl

Open the *Overview* of the *Pritunl* app in *App registrations*. Copy the *Directory (tenant) ID*, and *Application (client) ID* for the configuration below.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fsi9kW9S557BhqyFbFhxU%2Fentra_sso14.png?alt=media\&token=f5d45ab4-b3a7-4092-8611-ade95812fd98)

Open the *Settings* in the Pritunl web console and set *Single Sign-On* to *Azure*. Then set *Azure Region* to *Global (OAuth v2)* and *Azure API Version* to *Microsoft Graph*. Copy the *Directory ID* and *Application ID* from the steps above. Then copy the Azure key value from the earlier steps into *Application Secret*. When users sign in the Pritunl server will attempt to match one of the users Azure groups to a case sensitive name of an existing organization. This allows grouping users in Pritunl by their Azure groups. The *Default Single Sign-On Organization* will be used if none of the Azure groups match an existing Pritunl organization.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FwibnJ7e3JKLkmsUdcLbS%2Fentra_sso15.png?alt=media\&token=c08a1464-e750-40bf-bc32-78b5e41ccacf)

### Azure Permission Issues

Adjustments to the **Azure consent and permissions** may be needed if error messages about admin approval required are shown. Refer to the Azure [**configure how users consent to applications**](https://learn.microsoft.com/en-us/entra/identity/enterprise-apps/configure-user-consent) documentation for more information.


# Slack

Single sign-on with Slack

Pritunl supports single sign-on using Slack to allow employees to use their Slack account to sign into Pritunl. Oauth is used to authenticate users, re-authentication is also done on each connection. When a Slack user is removed or disabled they will no longer be able to connect to a Pritunl server. To start set the *Single Sign-On* to *Slack* and set the *Slack Team*. The team should be the Slack url used to access login such as `pritunl.slack.com`.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FSBdstYgBF5omuU3164Ce%2Fslack0.png?alt=media\&token=357092ef-6561-4d6e-b53c-bb71e094fc49)

Once configured a *Sign in with Slack* button will appear on the login page. Before users can login *Sign in with Slack* must be enabled in the Slack permission settings. Once compete users will be able to login and download their profiles using Slack. By default users will be added to the organization set in the *Single Sign-On Organization* in the settings. If a Slack team group name matches an organization in Pritunl the user will be added to that organization. The match is case sensitive and will only match the lowercase *Group name* set in the Slack group settings not the *Name*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F4Fw7FvOiWmJ8jcJ4VqBi%2Fslack3.png?alt=media\&token=1d5e1997-0cec-48d2-8e7a-91fc58e76542)

### Organization Priority

The first matching group will be used with group names sorted alphabetically. For more control over users with multiple groups the group description can be used to set the priority by placing `pritunl:100` with the lowest number have first priority. The priority declaration can be placed anywhere in the group description and the description may contain unrelated text.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F8IN3MDRDo5PluP1tlj6A%2Fslack2.png?alt=media\&token=831e9005-a96a-43e8-a766-8ab4a4048bce)


# Duo

Single sign-on with Duo

This tutorial will explain configuring Duo for single sign-on to Pritunl. Users will authenticate through Duo when downloading VPN profiles and before each VPN connection. Although Duo can be used independently for best security it should be used in combination with another single sign-on provider. If Duo is used in combination with another provider the user will need to authenticate with Duo when downloading VPN profiles and before each VPN connection. VPN re-connections will not require a Duo authentication, this can be changed with the [**Two-Step Authentication Cache**](https://docs.pritunl.com/kb/vpn/users/two-step-authentication) settings.

### Create Pritunl App on Duo

In the Duo admin interface select *Applications* then click *Protect an Application* and search for *OpenVPN*. Then click *Protect this Application*. Once the the application has been created set the *Name* to `Pritunl` and set *Username normalization* to *Simple*. Then click *Save Changes*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FWjxEx3TUHufw11X0Ai9q%2Fduo0.png?alt=media\&token=c16d2700-3f90-4987-be74-fc399c459277)

### Configure Pritunl

Once the Duo app has been configured open the *Pritunl* settings and set *Single Sign-On* to *Duo* or one the combinations including Duo. Then copy the *Integration key* to *Duo Integration Key*, *Secret key* to *Duo Secret Key* and *API hostname* to *Duo API Hostname*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FbhxZrgdU9uKZgYtQW0KM%2Fduo1.png?alt=media\&token=82082469-e940-4f67-ab07-6cceaf096e3e)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FBEOmO1YCj2n4sL4kEMGC%2Fduo2.png?alt=media\&token=3f66a392-aba8-475b-8272-9ae805f86784)

### Select Duo Mode

Pritunl supports several Duo modes. The *Push* mode will send a push authentication request to the users mobile device. The *Phone Callback* mode will call the users phone and ask the user to approve the authentication request. The *Passcode* mode will require the user to enter the passcode from the Duo mobile app or a hardware token from Duo. The *Push + Phone Callback* mode will use a phone callback if the user does not have the Duo mobile app installed.


# YubiKey

Single sign-on with Yubico YubiKey

This tutorial will explain configuring Yubico YubiKeys for single sign-on to Pritunl. Users will authenticate with a YubiKey when downloading VPN profiles and before each VPN connection. YubiKey must be used in combination with another single sign-on provider. VPN re-connections will not require a YubiKey authentication, this can be changed with the [**Two-Step Authentication Cache**](https://docs.pritunl.com/kb/vpn/users/two-step-authentication) settings. The Yubico authentication uses [**Yubico OTP**](https://developers.yubico.com/OTP/). Any YubiKey supporting this can be used including the [**YubiKey 4**](https://www.yubico.com/product/y4/), [**YubiKey 4 Nano**](https://www.yubico.com/product/yk4nano/), [**YubiKey 4C**](https://www.yubico.com/product/yubikey-4c/) and [**YubiKey Neo**](https://www.yubico.com/products/yubikey-hardware/yubikey-neo/).

### Purchase YubiKeys

YubiKeys can be purchased with **Amazon Prime**. All the YubiKeys below are supported.

* [**YubiKey 4 ($40)**](https://www.amazon.com/gp/product/B018Y1Q71M/ref=as_li_tl?ie=UTF8\&tag=pritunl0e-20\&camp=1789\&creative=9325\&linkCode=as2\&creativeASIN=B018Y1Q71M\&linkId=f89a9c0c4705c1514f79260b190c3d36)
* [**YubiKey 4 Nano ($50)**](https://www.amazon.com/gp/product/B018Y1XXT6/ref=as_li_tl?ie=UTF8\&tag=pritunl0e-20\&camp=1789\&creative=9325\&linkCode=as2\&creativeASIN=B018Y1XXT6\&linkId=75768303dd702eec02a94882efa53eac)
* [**YubiKey Neo ($50)**](https://www.amazon.com/gp/product/B00LX8KZZ8/ref=as_li_tl?ie=UTF8\&tag=pritunl0e-20\&camp=1789\&creative=9325\&linkCode=as2\&creativeASIN=B00LX8KZZ8\&linkId=2851cf95c315c44a4ce4d9f49df8e5a3)

### Get Yubico API Key

The Yubico OTP servers require an API key. This can be generated at [**upgrade.yubico.com/getapikey**](https://upgrade.yubico.com/getapikey)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FXCmuQbKCIPFWDMHp3vaJ%2Fyubikey0.png?alt=media\&token=05ff7c3c-eac6-4169-809f-6ae938d1adb3)

### Configure Pritunl

After generating a Yubico API key open the *Pritunl* settings and set *Single Sign-On* to one of the *Yubico* modes. Then copy the *Integration key* to *Duo Integration Key*, *Secret key* to *Duo Secret Key* and *API hostname* to *Duo API Hostname*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FlXkgyrOQFaGrbr9xvGz1%2Fyubikey1.png?alt=media\&token=bb6ff2c9-da9a-402f-8dd5-7d5584a53394)

### Custom Yubico API Servers

By default the offical YubiCloud API servers are used to validate YubiKeys. The servers can be changed by running the command `pritunl set app.sso_yubico_servers '["https://server0", "https://server1"]'`


# Active Directory

Single sign-on with Active Directory

This tutorial will explain configuring single sign-on with Active Directory using a Windows Radius server. If AWS Directory Service is used a Windows 2012 R2 EC2 instance can be created to serve the Radius server.

To begin open the server manager and install the *Network Policy and Access Services* role.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FaV9qNM4gjTmiZnmNhqbt%2Factive_directory0.png?alt=media\&token=e4ef6f9d-f425-47aa-84a4-408ef92a0b4a)

Once done search for and open the *Network Policy Server* management. Then in the *RADIUS Clients* section click *New*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FyRlDngMMbnpZPMns4SYU%2Factive_directory1.png?alt=media\&token=db0e8b4e-c5af-4a58-b56f-d0a52bcaefd7)

In the Radius client configuration set the *Friendly name* to *Pritunl* then enter the IP address or IP address range of the Pritunl servers. The DNS name can also be used. The IP address should be the address that the Pritunl Radius request will come from this will most likely be the private IP address of the Pritunl server. If multiple Pritunl servers are used all Pritunl servers that will be accepting client connections for Active Directory users will need to be added. Select *Generate* for the shared secret then click *Generate*. Copy the shared secret to the Radius settings in the Pritunl web console.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FL8QdND53VraeTIXYLSO9%2Factive_directory2.png?alt=media\&token=02249364-d0d9-4371-9c64-f110680f4d5f)

Next open the *Network Polices* section and click *New*. If you intend on matching Active Directory groups to Pritunl organizations or groups you should continue with the [**Active Directory with Organizations**](broken://pages/NMbhJ4UNpsohZaeOVr4e) tutorial. This tutorial will only show adding Active Directory clients to the default single sign-on organization.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FTFdDChtQcNUHYICNhIrE%2Factive_directory3.png?alt=media\&token=64bc6f9e-294e-4a8f-a96a-e8c4790684ac)

Set the policy name to *Pritunl* and click *Next*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fc6kxsuamEfxzygozN23Z%2Factive_directory4.png?alt=media\&token=9979d3b3-6501-4480-b4f8-01e22963349b)

On the specify conditions page click *Add* and select *User Groups* then click *Add*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Ft5m2p2kfVPu4MPh1IGg6%2Factive_directory5.png?alt=media\&token=1ab06681-e830-49fb-bf89-4796122eb8e3)

Click *Add Groups* and enter the name of the Active Directory groups that will be permitted to connect to the Pritunl server. Then click *Ok*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F37KVZuZJWpfYytns2Aax%2Factive_directory6.png?alt=media\&token=da858e33-c5d2-43cb-b3dc-97df75ecf912)

Then select *Add* and choose the *ClientIPv4Address* and enter the IP address of the Pritunl server. This will only allow the policy to be used by the Pritunl server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F7DqmfL5mqMZDoym94mHy%2Factive_directory7.png?alt=media\&token=1ba451cc-8f5b-496a-adbf-ab90c0d4fa2a)

For the authentication methods configuration select *Unencrypted authentication (PAP, SPAP)*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F4eydN3FSVFyMp9lN1kl3%2Factive_directory8.png?alt=media\&token=196a62a6-06f1-4bce-8480-a97f9f93b478)

Once done insure the Pritunl policy is above the deny access policies at the bottom.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FueB2B0j8fl6nMvPSh3O1%2Factive_directory9.png?alt=media\&token=c4bf4f08-7ebe-476f-9c80-56be00fa1971)

Once the Radius server is configured enter the IP address of the Windows Radius server with port *1812* and the shared secret from earlier in the Pritunl settings. Users will then be able to login to the web console using their Active Directory credentials. When users connect they will also be required to enter their Active Directory password.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FvIn25Lux5vHmq9fGP3wl%2Factive_directory11.png?alt=media\&token=986d25d9-44ce-4406-b665-ad696a208fee)

The event viewer is useful for determining why Radius authentication requests failed.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FI1tylU9gnBsRtZ2ebPek%2Factive_directory10.png?alt=media\&token=160bc487-620d-432a-ba9c-ca5b77f2872d)


# Active Directory with Organizations

Single sign-on with Active Directory including Organizations

This tutorial will explain including organization and group names in the Active Directory Radius response. This will allow adding Pritunl users to organizations and groups based on the users group membership in Active Directory. Each organization will need a network policy which will include the Pritunl organization and group names as custom string attributes.

To start create a new network policy. For this example the Pritunl Developers organization will be used. The name of the network policy should include the Pritunl organization name.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FbLUmr2CK4wEGItFqjdf2%2Fad_group0.png?alt=media\&token=8f1ed7d2-946f-4675-8054-0074ccf54ee7)

Next create a condition for the network policy to only match users in the Developers group in Active Directory.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FRejuTF7IDh7WfKylW4AF%2Fad_group1.png?alt=media\&token=3b1fe767-1767-4416-9be5-2384e7204f53)

Then select *Add* and choose the *ClientIPv4Address* and enter the IP address of the Pritunl server. This will only allow the policy to be used by the Pritunl server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F5KrQANUi26PEObxh7ocY%2Fad_group11.png?alt=media\&token=ec871ac0-d873-4213-b60c-7b99900ced4d)

For the authentication methods configuration select *Unencrypted authentication (PAP, SPAP)*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FR262g7guXMTExw1FcJiH%2Fad_group2.png?alt=media\&token=356aa07a-be8d-400b-a885-17b6073f2ad1)

In the configuration settings select the *Vendor Specific* section then click *Add*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FgMkwHBOmyXg0bRhysgmM%2Fad_group3.png?alt=media\&token=130073e6-79a6-465d-9bfc-9b0e5ff4cfbd)

In the add vendor specific attribute window set *Vendor* to *Custom* then select the *Vendor-Specific* attribute. Then click *Add*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FnoXptQLVDyIOUAGqNckt%2Fad_group4.png?alt=media\&token=75083cd1-f785-41a1-8186-c8023d50200a)

In the attribute information window set the vendor code to *97* then select *Yes. It conforms* and click *Configure Attribute*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FdxxyOwPAMEBlFqGUhMqA%2Fad_group5.png?alt=media\&token=618f5583-acd1-4465-9e1b-d9d783d4e996)

In the VSA configuration window set the attribute number to *0* and the format to *String*. Then enter one organization name in the value. The organization name must match an existing organization in Pritunl. Multiple organization names can be provided by adding additional attributes with the attribute number *0*. Pritunl will add the user to the first matched organization.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Ft6x8saWknG1lYH7TjPeL%2Fad_group6.png?alt=media\&token=1f859a27-df3d-4959-bedc-28a504777414)

Group names can also be included by are not required. This can be done by adding repeating the process above to add an attribute with vendor code *97* then setting the attribute number to *1*. Multiple group names can be provided by adding additional attributes with the attribute number *1*. Pritunl will add the user to all of the groups specified.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FMLcuDlNfmX1un5tGmEvl%2Fad_group7.png?alt=media\&token=d7a41911-3e71-406f-a674-66808fa3bb84)

Once done the attribute information window should look similar to the example below. This example will add the user to the *Developers* organization and both groups *Group* and *Group2*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FajkZ0nktqWGGSczPw1DV%2Fad_group9.png?alt=media\&token=38a46c74-fb1e-4597-9927-d452502c2bd5)

For users belonging to multiple Active Directory groups the priority can be configured by moving the network polices. The example below shows the *Developers* organization taking priority over the *Operations* organization. A user that is a member of both *Developers* and *Operations* will be added to the *Developers* organization.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FCKPQkx73TUKFVPmtXdam%2Fad_group10.png?alt=media\&token=58eca4ae-50ec-457a-b66b-760c1a7b39db)

Once the Radius server is configured enter the IP address of the Windows Radius server with port *1812* and the shared secret from earlier in the Pritunl settings. Users will then be able to login to the web console using their Active Directory credentials. When users connect they will also be required to enter their Active Directory password.

The event viewer is useful for determining why Radius authentication requests failed.


# Connection Authentication

VPN connection authentication options

By default when single sign-on is used in Pritunl the user will authenticate with the single sign-on provider from the Pritunl web console then import a VPN profile into a client. The VPN profile will contain a certificate and private key that will be used to authenticate the user to the VPN server. Instead of requiring the user to re-authenticate with single sign-on for each connection the Pritunl server will utilize the API from the single sign-on provider to verify the status of the user. This check will verify that the user exists and is not disabled. Most providers also support defining a single sign-on application, the API will also be used to verify the user has access to the defined application. These checks will occur for every connection even when authentication cache is enabled. If a single sign-on user were to fail the check the VPN connection would be blocked.

This design allows supporting all OpenVPN clients where there is no support for opening a web browser to complete authentication. It also allows the user to quickly connect to a VPN server without additional prompts. For most configurations this will not reduce the security of the connection, most users web browsers will already have a cached session for the single sign-on login. If the profile private key stored on the client was compromised the cached single sign-on sessions would also likely be compromised.

For additional authentication the *Single Sign-On Authentication* option can be enabled in the server settings. This will require the user to complete authentication with the single sign-on provider for each connection. The [**authentication cache**](https://docs.pritunl.com/kb/vpn/security/authentication-cache) can also be enabled in the top right settings to allow caching the authentication.

The most effective method of getting better connection security is to use multi-factor authentication. Pritunl provides multiple options for multi-factor authentication. This will always provide a higher level of security.

This option requires an updated Pritunl server and Pritunl client.

### Feature Support

| Feature                                                      | Default Configuration | SSO Authentication |
| ------------------------------------------------------------ | --------------------- | ------------------ |
| User authentication with profile certificate and private key | ✅                     | ✅                  |
| User status verified with single sign-on API                 | ✅                     | ✅                  |
| Multi-factor authentication with single sign-on provider     | ✅                     | ✅                  |
| Supports connection authentication cache                     | ✅                     | ✅                  |
| Supports all OpenVPN clients                                 | ✅                     | ❌                  |
| Requires web browser single sign-on prompt for connections   | ❌                     | ✅                  |
| User pin                                                     | ✅                     | ❌                  |
| Google Authenticator                                         | ✅                     | ❌                  |

### Configuration

Single sign-on connection authentication can be enabled for each individual server. This allows configuring servers with or without single sign-on authentication. Only single sign-on users will be able to connect to a server with single sign-on authentication.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FRr3nUlPZc8XZPT3jmYlF%2Fconn_sso1.png?alt=media\&token=b47e288c-7dc7-482e-b9d0-0832a218c5e7)

After this option has been enabled on a server the *Connection Single Sign-On Domain* will appear in the top right settings. This should be configured to a domain that is used to access the Pritunl web console. If a load balancer is configured for access to the web console the domain of the load balancer should be used.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fl2cTsMfBMxNPh6waIxxd%2Fsso_connection_domain.png?alt=media\&token=ca0bc025-95a3-44e5-b202-66bc769b4be1)

Once the option is configured a web browser will open after the user clicks connect. If a default system browser is not configured the link can be copied from the prompt shown.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F3hb91abcGjDpoUUUJNkx%2Fconn_sso2.png?alt=media\&token=0fee4494-1f91-41e4-8588-062ac63feba3)

Once the web browser opens the user will complete the single sign-on authentication and the VPN connection will authenticate.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FGEbyahPGOySUlWKC60Pg%2Fconn_sso3.png?alt=media\&token=c97bbbee-f11b-46ef-b37a-9400f81bcff8)


# Azure AD Migration

Migrate to new Azure Entra authentication API

[**Azure AD Graph**](https://learn.microsoft.com/en-us/graph/migrate-azure-ad-graph-overview) is reaching an end of life on June 30 before this date administrators will need to update to a version of Pritunl that has support for Microsoft Graph. This will be indicated by the OAuth v2 Azure Regions shown in the top right settings. After updating to a supported version change the *Azure Region* to one of the (OAuth v2) regions. Then set the *Azure API Version* to *Microsoft Graph* and click *Save*. **If issues continue refer to the** [**Azure Single Sign-On Documentation**](https://docs.pritunl.com/kb/vpn/sso/azure) **and follow the guide to verify all the settings match. A new API secret should be created as it appears the new API enforces earlier expiration of API secrets. Permissions should only be added, existing permissions should remain in place as explained below.**

**Additionally as older version Azure users expire users should be instructed to login to the Pritunl server web console with Azure to reauthorize the OAuth token with the newer Azure version.**

After doing this users will continue to connect with Azure AD Graph OAuth tokens until they open the web console and complete the *Sign in with Azure* authentication process. After completing this it will generate new Microsoft Graph OAuth tokens. Eventually these tokens will be forced to *Microsoft Graph* which may continue to work but are these are not guaranteed to work indefinitely.

If [**connection single sign-on**](https://docs.pritunl.com/kb/vpn/sso/connection-authentication) is configured this update will occur automatically the next time the user completes a connection without cached authentication. No user action is needed with these configurations.

The new API has a reduced scope and will only require the permissions below. **Refer to the** [**Azure Single Sign-On Documentation**](https://docs.pritunl.com/kb/vpn/sso/azure) **on how to add these new permissions. The existing permissions must remain in place until all users have completed a new sign-in.**

**Attempting to fix issues by creating a new sign-on application on Azure will require all users to immediately complete an OAuth authorization and will disconnect users who have not when the hourly single sign-on update occurs. This should only be done after attempting all other fixes.**

#### Azure AD Permissions

#### New Microsoft Graph Permissions


# Infrastructure

Pritunl cluster infrastructure

Pritunl is designed for high availability with no master servers and no single point of failure. All servers in a Pritunl cluster are independent and do not rely on other servers. Below is a diagram of a Enterprise cluster setup with a MongoDB replica set.

### Simple Design

Pritunl is designed to keep the configuration simple. All hosts in a cluster are equal and there is no master server. Adding hosts to a cluster only requires connecting the new host to the database used by the other host/hosts. When a new host connects to an existing Pritunl database the host/hosts using the database will automatically be aware of the new host. All inter-host communication is done through the database. Networking connectivity between hosts is not needed unless required by a VPN configuration such as a replicated VPN.

### Dual Web Server

The Pritunl web console uses an internal and external web server. This was done to protect the internal Python web server with the external Golang web server and to validate incoming JSON with static types. The Golang HTTP server is secure, regularly maintained and properly implements SSL. The external web server process has SELinux policies installed to secure the process when SELinux is available. When configured with LetsEncrypt or a signed SSL certificate the Pritunl web console will pass all checks in the [**Qualys SSL Test**](https://www.ssllabs.com/ssltest).

### External Web Server

The external web server is a Golang server that runs in a separate process. Other then the OpenVPN process this is the only process with open ports. All the paths and JSON data structures with static types are programmed on this server. When a request is received the server will check the path and the JSON data will be parsed into a struct with static types. This will ensure that the path is valid and the received JSON data matches the expected format for that path. The server will then create a new HTTP request and encode the struct back to JSON. A specific set of headers will also be copied to the new request. The new request is then sent to the internal server and the response is returned to the client. This server also binds to port 80 to redirect requests to HTTPS and to respond to the LetsEncrypt domain verification requests. The source code for this server can be found in the [**pritunl/pritunl-web**](https://github.com/pritunl/pritunl-web) repository.

### Internal Web Server

The internal web server is a Python server and is part of the main codebase. This server is bound only to `127.0.0.1` and will never receive requests directly from clients. There is some additional type checking and filtering done on this server for important path handlers.

### Inter-Server Messaging System

All communication between servers is done through the MongoDB database. This allows servers in a cluster to function without local network access. A tailable cursor in MongoDB is used to create a publish/subscribe messaging pattern allowing for fast and efficient communication across all servers in the cluster. This is also used for an event system to notify the web console that changes have occurred allowing for live updates.

### Resource Pooling System

Pritunl performs several resource intensive tasks that often take a long time to complete. These tasks include generating private keys and dh parameters that are then used by users, organizations and servers. Pritunl creates these resources in advanced and keeps them in a pool for future use. This allows task such as creating a user, organization or server to occur almost instantly. In the event that the pool is empty the resources will be created on-demand. The pooling system will also allow reserving a resource that is partially completed as opposed to generating a new one on-demand. This is useful for dh parameters where it can often take several minutes to generate.

### Queue System

A distributed queue system is available for resource intensive tasks which include generating private keys, dh parameters and re-assigning ip addresses to a server when changing the network address. The queue system will evenly distribute the tasks across all the servers in the cluster. This allows making full use of the resources in a large Pritunl cluster.

### Task System

Pritunl is designed to handle an inconsistent state caused by server failures. Scheduled tasks are run to repair inconsistencies in the database. These tasks include removing lost users, repairing a vpn servers ip pool and removing lost network links. The task system is also used to ensure all vpn servers are running and in the event of a server failure the task will perform the configured recovery. Tasks are reserved and run by only one server in the cluster to prevent unnecessary overlap. No master server is selected to schedule the tasks instead all servers in a cluster will attempt to reserve a scheduled task with a random delay. All the servers will also check for incomplete tasks and run the task again when a task is left uncompleted past the tasks timeout.


# Bandwidth Performance

Improving VPN bandwidth performance

Both the Pritunl server and client will need to encrypt/decrypt all network traffic sent over the VPN connection. If either the server or the client have a slow CPU the bandwidth will be significantly lower. The AES encryption cipher is used by default and a CPU with the AES-NI hardware acceleration will perform significantly better. A fast Intel CPU with AES-NI on both the client and server will be needed to achieve connection speeds exceeding 100mbps. If high bandwidth is needed for a large number of VPN clients concurrently a much more powerful CPU with AES-NI will be needed on the server.

Using smaller key sizes such as AES 128bit with SHA-1 in the server settings will significantly improve bandwidth but will make the encrypted traffic more vulnerable.


# Logging

Pritunl logging system

Pritunl stores log information in the MongoDB database. This allows viewing the logs for all the servers in the cluster. In the event that an error occurs when there is no connection to the database the logs will write to `/var/log/pritunl.log`

### Viewing Logs

Logs can be viewed by either running using the `pritunl logs` command or using the log viewer in the web console. More information on the logs command can be found in the commands section.

### Log Format

All log messages start with the name of the Pritunl host, time stamp for log message and log level.


# Monitoring

Monitoring with InfluxDB

To enable monitoring with InfluxDB v2 set the InfluxDB URL in the settings to the http URL of the InfluxDB host with the port such as `http://123.123.123.123:8086`. Then set the InfluxDB org, bucket and token.

### Grafana Dashboard

Below is a Grafana dashboard template with all the Pritunl metrics that can be imported. This can also be [**downloaded**](https://raw.githubusercontent.com/pritunl/pritunl/master/tools/grafana.json)

```json
{
  "id": 1,
  "title": "Pritunl",
  "originalTitle": "Pritunl",
  "tags": [],
  "style": "dark",
  "timezone": "browser",
  "editable": true,
  "hideControls": false,
  "sharedCrosshair": false,
  "rows": [
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 3,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Requests",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "0"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_requests",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "remote_ip"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "count"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Requests",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 1,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Response Time",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "auto"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "0"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_requests",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "response_time"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Response Time",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "ms",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    },
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 5,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Connections",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "0"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_user_connections",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "user"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "count"
                  }
                ]
              ],
              "tags": []
            },
            {
              "alias": "Disconnections",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "0"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_user_disconnections",
              "policy": "default",
              "refId": "B",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "user"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "count"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "User Connections",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 6,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Received",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_server_bandwidth",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "bytes_recv"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "sum"
                  }
                ]
              ],
              "tags": []
            },
            {
              "alias": "Sent",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_server_bandwidth",
              "policy": "default",
              "refId": "B",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "bytes_sent"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "sum"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Server Bandwidth",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "bytes",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "bytes",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    },
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 10,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Running Servers",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_cluster",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "server_count"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Running Servers",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": 0,
              "min": 0,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 11,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Connected Devices",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_cluster",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "device_count"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Connected Devices",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    },
    {
      "collapse": false,
      "editable": true,
      "height": "250px",
      "panels": [
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 7,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "CPU Usage",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_system",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "cpu_usage"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            },
            {
              "alias": "Memory Usage",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_system",
              "policy": "default",
              "refId": "B",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "mem_usage"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Host System",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "percent",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "percent",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        },
        {
          "aliasColors": {},
          "bars": false,
          "datasource": null,
          "editable": true,
          "error": false,
          "fill": 1,
          "grid": {
            "threshold1": null,
            "threshold1Color": "rgba(216, 200, 27, 0.27)",
            "threshold2": null,
            "threshold2Color": "rgba(234, 112, 112, 0.22)"
          },
          "id": 9,
          "isNew": true,
          "legend": {
            "avg": false,
            "current": false,
            "max": false,
            "min": false,
            "show": true,
            "total": false,
            "values": false
          },
          "lines": true,
          "linewidth": 2,
          "links": [],
          "nullPointMode": "connected",
          "percentage": false,
          "pointradius": 5,
          "points": false,
          "renderer": "flot",
          "seriesOverrides": [],
          "span": 6,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "alias": "Thread Count",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_system",
              "policy": "default",
              "refId": "A",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "thread_count"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            },
            {
              "alias": "Open Files",
              "dsType": "influxdb",
              "groupBy": [
                {
                  "params": [
                    "$interval"
                  ],
                  "type": "time"
                },
                {
                  "params": [
                    "null"
                  ],
                  "type": "fill"
                }
              ],
              "measurement": "pritunl_system",
              "policy": "default",
              "refId": "B",
              "resultFormat": "time_series",
              "select": [
                [
                  {
                    "params": [
                      "open_file_count"
                    ],
                    "type": "field"
                  },
                  {
                    "params": [],
                    "type": "mean"
                  }
                ]
              ],
              "tags": []
            }
          ],
          "timeFrom": null,
          "timeShift": null,
          "title": "Host Process",
          "tooltip": {
            "msResolution": false,
            "shared": true,
            "value_type": "cumulative"
          },
          "type": "graph",
          "xaxis": {
            "show": true
          },
          "yaxes": [
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            },
            {
              "format": "short",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": 0,
              "show": true
            }
          ]
        }
      ],
      "title": "New row"
    }
  ],
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h",
      "2h",
      "1d"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "30d"
    ]
  },
  "templating": {
    "list": []
  },
  "annotations": {
    "list": []
  },
  "refresh": "5s",
  "schemaVersion": 12,
  "version": 37,
  "links": []
}
```


# Backup

Backing up Pritunl

All data for Pritunl is stored in the MongoDB database. This allows the entire system to be maintained without having to manage any complex components or configuration files. When Pritunl is installed it establishes a connection with the database using two configuration options.

The first is the MongoDB URI stored in `/etc/pritunl.conf` this URI will provide all the information needed to connect to a MongoDB database.

The second is a 32 length string in `/var/lib/pritunl/pritunl.uuid` this identifies the host in the cluster. This ID can also be viewed from the web console by holding shift and clicking the red host label. If the ID is lost it can be retrieved this way. If the ID were changed when the Pritunl service starts the host will appear as a new host in cluster, the previous host would remain until it is manually deleted from the web console.

Newer versions of Pritunl have commands to retrieve and update these values. Below are commands to backup and restore the values.

```shellscript
sudo pritunl get-mongodb
mongodb://localhost:27017/pritunl
sudo pritunl set-mongodb mongodb://localhost:27017/pritunl

sudo pritunl get-host-id
3d6bb90b269fd80073c28a352f0de983
sudo pritunl set-host-id 3d6bb90b269fd80073c28a352f0de983
```

There are other files such as `/var/lib/pritunl/setup_key` that are not important to the host configuration. The setup key is a temporary key used during the initial setup of a database when the web browser prompts to enter a MongoDB URI as shown below. This key is not used after this setup.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FI8XOf7m1dAxWkCqOFApU%2Fdatabase_setup0.png?alt=media\&token=09f0ab77-1066-49b3-98ba-4fd5924e0f4e)

### MongoDB

If the MongoDB database is run on the local server the commands below can be used to backup and restore the database. The clear message cache command should be run on a Pritunl host after a database restore.

```shellscript
mongodump --db=pritunl
tar cf pritunldb.tar dump

tar xf pritunldb.tar
mongorestore dump

sudo pritunl clear-message-cache
```


# Server Commands

Pritunl server CLI commands

Below is a list of the cli commands available in Pritunl.

### start

Starts the server this should only be used for debugging. For normal operation the server should be started using the service system available in the Linux distro. Below is a table of the available options.

| Option    | Description                |
| --------- | -------------------------- |
| --daemon  | Daemonize process          |
| --pidfile | Path to create pid file    |
| --conf    | Path to configuration file |
| --quiet   | Suppress logging output    |

### version

Pritunl the version information for the Pritunl installation.

### reset-password

This command will reset the administrator username and password back to `pritunl`. It will also remove any single sign-on and two-step authentication settings for the administrator user if enabled.

### reset-version

Pritunl will prevent running a version older then the version that was last used for the database. This prevents potential corruption that could occur when database layout changes are made during updates. If a Pritunl server has been downgraded this command will need to be run to reset the version in the database to the current version. You should contact support before running this command to ensure the downgraded version of Pritunl is still compatible with the current database layout. Before running all servers in the cluster should be stopped.

### reset-ssl-cert

When custom ssl certificates are improperly configured the Pritunl web console can become inaccessible. This command will reset the ssl certificates and generate a new self signed certificate. Before running all servers in the cluster should be stopped.

### reconfigure

During the initial setup of Pritunl the MongoDB uri is set. in the event that the MongoDB server is moved the uri can be reset by running this command. After running the command the Pritunl server will display the initial setup allowing a new MongoDB uri to be set. The server should be stopped before running this command.

### set-mongodb

This command can be used to set the MongoDB uri. This is helpful for automating Pritunl installations. The server should be stopped before running this command.

### logs

This command will allow viewing the logs for all the servers in the Pritunl cluster. Below is a table of the options available.

|           |                                                |
| --------- | ---------------------------------------------- |
| --archive | Archive all the logs to the provided location. |
| --tail    | Tails the log output as it occurs.             |
| --limit   | Sets a limit on the number of lines outputted. |

### set

Sets an advanced configuration property using the format `pritunl set category.property value`

### unset

Clears an advanced configuration property using the format `pritunl unset category.property`

### get

Gets the current value of an advanced configuration property using the format `pritunl get category.property`


# Load Balancing

Load balancing web console

All hosts in a Pritunl cluster can be used to access the web console. For high demand clusters that handle a lot of single sign-on users it is best to setup a Pritunl host dedicated for web console access that does not host any vpn servers. A single dedicated web console Pritunl server should handle almost all high demand configurations but if additional capacity or high availability is required a load balancer can be used. To do this enable the reverse proxy option, this will configure the server to read the `X-Forwarded-For` and `X-Forwarded-Proto` headers. If `X-Forwarded-Proto` is equal to `http` the client will always be redirected to HTTPS even if the Pritunl server is running with SSL off and on port 80. Load balancers can be configured to proxy both HTTP and HTTPS traffic to the Pritunl server and as long as the load balancer sets the `X-Forwarded-Proto` header the Pritunl server will handle HTTPS redirection. The `/check` handler will return 200 if the Pritunl server is online and connected to the database.

```shell
sudo pritunl set app.reverse_proxy true
sudo pritunl set app.redirect_server false
sudo pritunl set app.server_ssl false
sudo pritunl set app.server_port 80
```

**If the load balancer supports HTTPS passthrough to backend servers this should be used instead. This requires the load balancer to support sending HTTPS requests to the internal Pritunl host IP without HTTPS certificate verification.** This will provide the best compatibility when using connection methods that request HTTP requests to reach the Pritunl host directly.

```shellscript
sudo pritunl set app.reverse_proxy true
sudo pritunl set app.redirect_server true
sudo pritunl set app.server_ssl true
sudo pritunl set app.server_port 443
```

### Domain Configuration

When configuring a load balancer configure the relevant domains as documented below.

#### Hosts Tab

* **Host Public Address**: The public IPv4 address or domain of the Pritunl host. This should always be the public IP of the host for all configurations even when using a load balancer.
* **Host Public IPv6 Address**: The public IPv6 address or domain of the Pritunl host. This should always be the public IP of the host for all configurations even when using a load balancer.
* **Host Sync Address**: In the advanced host settings. The public address or domain that the web server of the Pritunl servers can be accessed from. If a load balancer is configured that address should be set here.

#### Top Right Settings

* **Connection Single Sign-On Domain**: Only shown when using single sign-on connection authentication. The public address or domain that is used to validate single sign-on requests through the Pritunl web server for a new VPN connection. If a load balancer is configured that address should be set here. Requires valid SSL certificate.

### Configuration Sync

When configuring load balancing the clients will not be able to access the hosts directly to sync the configuration. This is fixed by setting the *Sync Address* in the host settings to the domain name of the load balancer.

### HAProxy Configuration

Below is an example HAProxy configuration for Pritunl. This requires a certificate at `/etc/ssl/haproxy.pem`.

```
global
    log 127.0.0.1 local2
    chroot /var/lib/haproxy
    pidfile /var/run/haproxy.pid
    maxconn 4000
    user haproxy
    group haproxy
    daemon
    stats socket /var/lib/haproxy/stats
    tune.ssl.default-dh-param 2048

defaults
    mode http
    log global
    option httplog
    option dontlognull
    option http-server-close
    option forwardfor
    retries 3
    timeout http-request 10s
    timeout queue 1m
    timeout connect 10s
    timeout client 1m
    timeout server 1m
    timeout http-keep-alive 10s
    timeout check 10s
    maxconn 4000

frontend http
    bind :::80 v4v6
    reqadd X-Forwarded-Proto:\ http
    default_backend backend

frontend https
    bind :::443 v4v6 ssl crt /etc/ssl/haproxy.pem
    reqadd X-Forwarded-Proto:\ https
    default_backend backend

backend backend
    balance roundrobin
    server pritunl0 <PRITUNL0_IP>:80 check
    server pritunl1 <PRITUNL1_IP>:80 check
```

### Nginx Configuration

The Nginx configuration below uses SSL for the upstream connection. In this configuration the Pritunl server should be configured with SSL.

```shell
sudo pritunl set app.reverse_proxy true
sudo pritunl set app.redirect_server false
sudo pritunl set app.server_ssl true
sudo pritunl set app.server_port 8443
```

Configure the Nginx configuration and self-signed certificate for unmatched domains. Replace `123.123.123.123` with the IP address of the Pritunl server and `demo.pritunl.com` with the domain name of the server.

```shell
sudo openssl req -x509 -nodes -days 18250 -newkey rsa:2048 -keyout /etc/nginx/ssl/notfound.key -out /etc/nginx/ssl/notfound.crt

sudo tee /etc/nginx/nginx.conf << EOF
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
worker_rlimit_nofile 400000;
pcre_jit on;

events {
    worker_connections 20000;
    multi_accept on;
    use epoll;
}

http {
    server_tokens off;
    charset utf-8;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    client_header_timeout 45;
    client_body_timeout 45;
    keepalive_timeout 65;
    connection_pool_size 1024;
    request_pool_size 8k;
    client_header_buffer_size 2k;
    client_body_buffer_size 32k;
    server_names_hash_bucket_size 512;
    server_names_hash_max_size 1024;
    types_hash_max_size 2048;

    server {
        listen 80;
        listen [::]:80;
        server_name _;
        return 404;
    }

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl_certificate /etc/nginx/ssl/notfound.crt;
        ssl_certificate_key /etc/nginx/ssl/notfound.key;
        server_name _;
        return 404;
    }

    include /etc/nginx/conf.d/*.conf;
}
EOF

sudo tee /etc/nginx/conf.d/pritunl-vpn.conf << EOF
upstream pritunl-vpn {
    server 123.123.123.123:8443;
}

server {
    listen 80;
    listen [::]:80;
    root /usr/share/nginx/html;
    server_name demo.pritunl.com;
    location / {
        return 301 https://demo.pritunl.com\$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/nginx/ssl/demo.pritunl.com.crt;
    ssl_certificate_key /etc/nginx/ssl/demo.pritunl.com.key;
    server_name demo.pritunl.com;
    location / {
        proxy_pass https://pritunl-vpn;
        proxy_ssl_verify off;
        proxy_set_header Host \$http_host;
        proxy_set_header X-Forwarded-For \$remote_addr;
        proxy_set_header X-Real-IP \$remote_addr;
    }
}
EOF
```

Below is a certbot script to generate a LetsEncrypt certificate for the server.

```shell
sudo dnf -y install certbot

sudo tee /etc/systemd/system/certbot.target << EOF
[Unit]
Description=Cerbot target
StopWhenUnneeded=yes
EOF

sudo tee /etc/systemd/system/certbot.timer << EOF
[Unit]
Description=Cerbot timer

[Timer]
OnCalendar=*-*-* 8:00:00
Unit=certbot.target

[Install]
WantedBy=basic.target
EOF

sudo tee /etc/systemd/system/certbot.service << EOF
[Unit]
Description=Cerbot
Wants=certbot.timer

[Service]
ExecStart=/usr/bin/certbot-nginx

[Install]
WantedBy=certbot.target
EOF

sudo tee /usr/bin/certbot-nginx << EOF
#!/bin/bash

getcert () {
  echo "Getting certificate email=\$1 domain=\$2"
  /usr/bin/certbot --webroot --agree-tos --non-interactive --webroot-path /usr/share/nginx/html --preferred-challenges http --email \$1 -d \$2 certonly
  /usr/bin/cp -f /etc/letsencrypt/live/\$2/fullchain.pem /etc/nginx/ssl/\$2.crt
  /usr/bin/chown nginx:nginx /etc/nginx/ssl/\$2.crt
  /usr/bin/cp -f /etc/letsencrypt/live/\$2/privkey.pem /etc/nginx/ssl/\$2.key
  /usr/bin/chown nginx:nginx /etc/nginx/ssl/\$2.key
}

getcert "contact@pritunl.com" "demo.pritunl.net"

/usr/bin/chown -R nginx:nginx /etc/nginx/ssl
/usr/bin/chmod 600 /etc/nginx/ssl/*
/usr/sbin/restorecon -R -v /etc/nginx
/usr/bin/systemctl reload nginx
EOF
sudo chmod +x /usr/bin/certbot-nginx
```

Generate the initial certificate and start the server.

```shell
sudo /usr/bin/certbot-nginx

sudo systemctl daemon-reload
sudo systemctl enable certbot.service
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer

sudo systemctl restart nginx
sudo systemctl enable nginx
```


# Scaling

Recomendations for scaling Pritunl on AWS and Google Cloud

Below are tables of recommended instance types and the recommended maximum connected clients. For best performance Pritunl servers should be replicated across as many instances as possible handling as few clients as possible. Prices below are estimated costs for AWS and Google Cloud deployments.

### Server Settings

For large deployments the *Max Clients* option should be set as low as possible *(maximum concurrent clients/nodes in cluster)*. OpenVPN clients will choose a random server when connecting. Setting the max clients will prevent clients from flooding one node by dropping additional clients to trigger the clients to attempt to connect to a different node.

### Creating Empty Hosts

When a user downloads the VPN profile it will contain a list of the hosts in a random order. Unless the official Pritunl client is used and clients have access to the web console port the configuration sync will not be available to update the configuration. For large deployments DNS names should always be used by setting the *Public Address* field in the host settings. In addition it is best to over estimate the number of hosts needed for the deployment so that client configurations will already contain the DNS names for hosts that will potentially be added in the future. This can be done by adding then removing multiple hosts to the cluster leaving the host entry in the hosts tab. To quickly create hosts with one server remove the `/var/lib/pritunl/pritunl.uuid` file then restart the Pritunl service. After the empty hosts have been added fill in the *Public Address* field and attach the hosts to a server. Attaching empty hosts to a server will not causes issues as Pritunl will not attempt to run a server on an offline host.

To replace the empty hosts with real hosts when scaling delete the empty host and copy the *Public Address* field. Then attach the real host to the server and adjust the *Replication Count*.

When a VPN client attempts to connect to an empty or offline host it will fail and move on to the next host this increases the connection time. This can be avoided by adjusting the DNS entries for the empty hosts to the IP address of a running host until the DNS entry is used for a real host. Having multiple DNS entries pointing to the same host will not cause any issues.

```
remote server3.pritunl.net 16105 udp
remote server5.pritunl.net 16105 udp
remote server2.pritunl.net 16105 udp
remote server0.pritunl.net 16105 udp
remote server4.pritunl.net 16105 udp
remote server1.pritunl.net 16105 udp
```

### Pritunl Recommended Instance Types

For Pritunl nodes instances with high CPU and high network bandwidth are recommend. On AWS c5 instance types have the best network performance. Google Cloud doesn't provide information on instance network performance. The max clients represents the maximum concurrent connections.

| Instance Type | Max Clients | Performance                     |
| ------------- | ----------- | ------------------------------- |
| t3.medium     | 250         | 2 vCPU, Low to Moderate Network |
| c5.large      | 1000        | 2 vCPU, Up to 10 Gigabit        |
| c5.xlarge     | 2000        | 4 vCPU, Up to 10 Gigabit        |
| c5.2xlarge    | 2000        | 8 vCPU, Up to 10 Gigabit        |
| c5.4xlarge    | 4000        | 16 vCPU, Up to 10 Gigabit       |
| c5.9xlarge    | 4000        | 36 vCPU, 10 Gigabit             |
| n1-highcpu-2  | 250         | 2 vCPU                          |
| n1-highcpu-4  | 1000        | 4 vCPU                          |
| n1-highcpu-8  | 2000        | 8 vCPU                          |
| n1-highcpu-16 | 4000        | 16 vCPU                         |
| n1-highcpu-32 | 4000        | 32 vCPU                         |

### MongoDB Recommended Instance Types

For MongoDB instances with high memory are recommended. The max users represents the maximum number of users that can exists in Pritunl.

| Instance Type | Max Users | Performance |
| ------------- | --------- | ----------- |
| r3.large      | 20000     | 15 GB       |
| r3.xlarge     | 40000     | 30.5 GB     |
| n1-highmem-2  | 20000     | 13 GB       |
| n1-highmem-4  | 40000     | 26 GB       |

### Example Deployments

| Instances                                        | Clients                                                                   |
| ------------------------------------------------ | ------------------------------------------------------------------------- |
| r3.large x2 (MongoDB), c5.large x10 (Pritunl)    | Moderate Bandwidth, Best Performance: 2500, Recommended: 5000, Max: 20000 |
| r3.large x2 (MongoDB), c5.xlarge x10 (Pritunl)   | High Bandwidth, Best Performance: 2500, Recommended: 5000, Max: 20000     |
| r3.xlarge x2 (MongoDB), c5.xlarge x20 (Pritunl)  | High Bandwidth, Best Performance: 5000, Recommended: 10000, Max: 40000    |
| r3.xlarge x2 (MongoDB), c5.xlarge x40 (Pritunl)  | High Bandwidth, Best Performance: 10000, Recommended: 20000, Max: 80000   |
| r3.2xlarge x2 (MongoDB), c5.xlarge x60 (Pritunl) | High Bandwidth, Best Performance: 15000, Recommended: 30000, Max: 120000  |


# Plugins

Pritunl plugin system

Plugins can be added to Pritunl by creating a Python file in the `/var/lib/pritunl/plugins` directory. Any filename for the plugin can be used. When the Pritunl service starts plugins in the directory will be loaded. Below is an example plugin with all the available handlers. When creating a plugin only the handlers being used should be included all other handlers should be removed. All event handlers are called asynchronously unless noted in the description below. The function arguments must match the names below and end with `**kwargs` to support new arguments added in future releases. Unused arguments can be removed from the function. Empty event handlers should be removed to prevent unnecessary function calls. Multiple plugins with the same handlers are supported but must be in separate files. An Enterprise subscription is required for plugins.

### Adding Python Libraries

The Pritunl packages use a packaged Python environment. Additional libraries can be installed by running `sudo /usr/lib/pritunl/usr/bin/pip3.9 install`

### Updating and Pritunl Clusters

When upgrading Pritunl the plugins will not be modified or removed and will continue to work. For Pritunl clusters all hosts in the cluster must have the plugin installed.

### Example

```python
# Available libraries included with a default Pritunl installation
from pritunl import logger
# import requests
# import pymongo
# import redis
# import boto3

# Called on authorization of user connection attempt. Allow will be True
# when user authenticated sucessfully. When allow is False reason will
# explain why the user was not authenticated.
def user_connection(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, platform, device_id, device_name,
        remote_ip, mac_addr, password, auth_password, auth_token, auth_nonce,
        auth_timestamp, allow, reason, wg_public_key, **kwargs):
    logger.info('Example log message', 'plugin',
        key1='value1',
        key2='value2',
    )

    try:
        raise Exception('example')
    except:
        logger.exception('Example exception log message', 'plugin',
            key1='value1',
            key2='value2',
        )

# Called after user has connected.
def user_connected(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, platform, device_id, device_name,
        virtual_ip, virtual_ip6, remote_ip, mac_addr, wg_public_key, **kwargs):
    pass

# Called on user disconnect, may not always be called if a server is stopped
# or unexpected failure occurs.
def user_disconnected(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, remote_ip, virtual_ip, virtual_ip6,
        wg_public_key, **kwargs):
    pass

# [SYNCHRONOUS] Called on user connect must return True or False to allow
# connection and None if allowed or a string with reason if not allowed.
def user_connect(host_id, server_id, org_id, user_id, host_name,
        server_name, org_name, user_name, remote_ip, mac_addr, mac_addrs,
        platform, device_id, device_name, bypass_secondary, has_token,
        password, **kwargs):
    if not 'auth_ok':
        return True, None
    else:
        return False, 'Reason for denial'

# [SYNCHRONOUS] Called on user login must return True or False and an
# organization name that the user will be added to. The organization name must
# be included. Also called on each user connection. This plugin is used to
# support user logins with credentials from other systems. The user_name and
# password must be verified in the plugin, no other authentication will be
# checked.
def user_authenticate(host_id, host_name, user_name, password, remote_ip,
        **kwargs):
    if not 'auth_ok':
        return True, 'organization_name', ['group', 'names']
    else:
        return False, None, None

# [SYNCHRONOUS] Called when a user configuration is synced or downloaded
# to return custom configuration lines that will be added to the users
# OpenVPN configuration.
def user_config(host_id, host_name, org_id, user_id, user_name, server_id,
        server_name, server_port, server_protocol, server_ipv6,
        server_ipv6_firewall, server_network, server_network6,
        server_network_mode, server_network_start, server_network_stop,
        server_restrict_routes, server_bind_address, server_onc_hostname,
        server_dh_param_bits, server_multi_device, server_dns_servers,
        server_search_domain, server_otp_auth, server_cipher, server_hash,
        server_inter_client, server_ping_interval, server_ping_timeout,
        server_ping_interval_wg, server_ping_timeout_wg,
        server_link_ping_interval, server_link_ping_timeout,
        server_allowed_devices, server_max_clients, server_replica_count,
        server_dns_mapping, server_debug, **kwargs):
    return ''

# Called every 15 seconds with user bandwidth used in that period
def user_bandwidth(host_id, server_id, org_id, user_id, device_id,
        host_name, server_name, org_name, user_name, device_name,
        remote_ip, virtual_ip, virtual_ip6, timestamp,
        bytes_sent, bytes_recv, **kwargs):

    logger.info('User bandwidth', 'plugin',
        server_id=server_id,
        server_name=server_name,
        user_id=user_id,
        user_name=user_name,
        remote_ip=remote_ip,
        virtual_ip=virtual_ip,
        bytes_sent=bytes_sent,
        bytes_recv=bytes_recv,
    )

# Called on log entries. The kwargs includes variables from the log event.
def log_entry(host_id, host_name, message, **kwargs):
    pass

# Called on audit event. User id can be referring to a user or administrator.
# The org_id will be None for administrators.
def audit_event(host_id, host_name, user_id, org_id, timestamp, type,
        remote_addr, message, **kwargs):
    pass

# [SYNCHRONOUS] Called after a user has authenticated with SSO when
# loging into the web console. Must return True or False to accept auth
# request and an organization name or None. If an organization name is
# included the user will be added to that organization. If Duo is used as a
# secondary authentication method and the organization name from Duo is set it
# will have priority over the organization name from the primary SSO provider.
# The sso_org_names will specify the list of org names provided by SAML and
# Slack single sign-on.
def sso_authenticate(sso_type, host_id, host_name, user_name, user_email,
        remote_ip, sso_org_names, sso_group_names, **kwargs):
    if sso_type == 'duo':
        pass
    elif sso_type == 'google':
        pass
    elif sso_type == 'slack':
        pass
    elif sso_type == 'saml':
        pass
    elif sso_type == 'radius':
        pass

    if not 'auth_ok':
        return True, 'organization_name', ['group', 'names']
    else:
        return False, None, None

# [SYNCHRONOUS] Called when a server is started to return custom configuration
# lines that will be added to the servers OpenVPN configuration.
def server_config(host_id, host_name, server_id, server_name, wg, port,
        port_wg, protocol, ipv6, ipv6_firewall, network, network6, network_wg,
        network6_wg, network_mode, network_start, network_stop,
        restrict_routes, bind_address, onc_hostname, dh_param_bits,
        multi_device, dns_servers, search_domain, otp_auth, cipher, hash,
        inter_client, ping_interval, ping_timeout, ping_interval_wg,
        ping_timeout_wg, link_ping_interval, link_ping_timeout, max_clients,
        replica_count, dns_mapping, debug, interface, interface_wg,
        bridge_interface, vxlan, routes, **kwargs):
    return ''

# [SYNCHRONOUS] Called when a server is started. Call occurs after OpenVPN
# process has been configured and started.
def server_start(host_id, host_name, server_id, server_name, wg, port,
        port_wg, protocol, ipv6, ipv6_firewall, network, network6, network_wg,
        network6_wg, network_mode, network_start, network_stop,
        restrict_routes, bind_address, onc_hostname, dh_param_bits,
        multi_device, dns_servers, search_domain, otp_auth, cipher, hash,
        inter_client, ping_interval, ping_timeout, ping_interval_wg,
        ping_timeout_wg, link_ping_interval, link_ping_timeout, max_clients,
        replica_count, dns_mapping, debug, interface, interface_wg,
        bridge_interface, vxlan, **kwargs):
    pass

# [SYNCHRONOUS] Called when a server is stopped.
def server_stop(host_id, host_name, server_id, server_name, wg, port,
        port_wg, protocol, ipv6, ipv6_firewall, network, network6, network_wg,
        network6_wg, network_mode, network_start, network_stop,
        restrict_routes, bind_address, onc_hostname, dh_param_bits,
        multi_device, dns_servers, search_domain, otp_auth, cipher, hash,
        inter_client, ping_interval, ping_timeout, ping_interval_wg,
        ping_timeout_wg, link_ping_interval, link_ping_timeout, max_clients,
        replica_count, dns_mapping, debug, interface, interface_wg,
        bridge_interface, vxlan, **kwargs):
    pass
```


# Upgrading

Upgrading Pritunl

Updates for Pritunl are installed by the package manager that is included with the Linux distribution used. After updating the packages using the package manager the Pritunl service must be manually restarted. On the first start the server may perform database updates if there are changes. If not the server will restart with the latest version.


# Downgrading

Downgrading the Pritunl package

If it is necessary to downgrade the Pritunl package run the commands below to download the package and reset the database version. Previous package releases can be found in the [**GitHub Releases**](https://github.com/pritunl/pritunl/releases). Insure the correct package is downloaded for the Linux distribution. After downloaded the package install it using the commands specific to the package manager used. Next the database version must be reset to the previous version before the Pritunl server will be able to run. The database version is used to prevent an older version of Pritunl from running on a newer database that may have a different layout. It is best to check if any incompatible database upgrades have occurred by looking at the change log in the releases. If unsure contact support before upgrading. Once done restart the Pritunl service. For Pritunl clusters all package versions must be the same.

```shell
wget https://github.com/pritunl/pritunl/releases/download/1.XX.XXXX.XX/pritunl_1.XX.XXXX.XX-0ubuntu1.trusty_all.deb
dpkg -i pritunl_1.XX.XXXX.XX-0ubuntu1.trusty_all.deb
service pritunl restart
```

```shell
wget https://github.com/pritunl/pritunl/releases/download/1.XX.XXXX.XX/pritunl-1.XX.XXXX.XX-1.el7.centos.x86_64.rpm
yum install pritunl-1.XX.XXXX.XX-1.el7.centos.x86_64.rpm
systemctl restart mongod pritunl
service mongod restart
```


# Configure NTP

Configure NTP on Pritunl servers

Accurate time is needed for multi host configurations with Pritunl. The script below can be used to configure NTP on RHEL systems.

```shell
sudo yum -y install ntp
sudo systemctl start ntpd
sudo systemctl enable ntpd
```

```shell
sudo dnf -y install chrony
sudo systemctl start chronyd
sudo systemctl enable chronyd
```


# Chrome Certificate Error

Chrome certificate error with HSTS

Pritunl will set the HSTS header to force the web browser to use HTTPS. When changing certificates it is possible to be locked out of the web console with the error message *You cannot visit example.domain right now because the website uses HSTS*. If this occurs the domain must be removed from the Chrome HSTS database. This is done by first closing any open tabs with the Pritunl web console then going to **chrome://net-internals/#hsts**. At the bottom of the page put the domain of the Pritunl web console in the *Delete domain security policies* field and click *Delete*. Then open a new tab and go to the web console and click *Proceed to example.domain (unsafe)*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F7LKmpTd0ku751O3HJUdG%2Fhsts.png?alt=media\&token=f9589b72-07d6-451c-8541-2635ed6a6c12)


# Auditing

Enable auditing logs in Pritunl

Auditing can be enabled in the settings by setting *Auditing* to *All*. Once enabled auditing can only be disabled by running `sudo pritunl unset app.auditing` on a Pritunl host. Gaining access to the web console will not allow auditing to be disabled or cleared. Once enabled the two auditing outputs below will be enabled.

### Administrator and User Audit

The administrator and user audit is stored in the database. This can be viewed from any host by clicking the audit icon on the right side of a user in the web console. This audit shows actions performed by the user but does not include VPN connections. This audit log is never expires and is never removed from the database.

### Journal Audit

The audit journal stores detailed events in the file `/var/log/pritunl_journal.log`. This file rotates five times starting with `/var/log/pritunl_journal.log.1` and ending at `/var/log/pritunl_journal.log.5`. Each line will contain an audit even formatted as JSON.

Each event has a `id` that is unique to each event. This can be used by parsing systems to identify each event. The `timestamp` is the epoch time in seconds. The `event` is the event type, the types can be found at [**Journal Events**](https://github.com/pritunl/pritunl/blob/master/pritunl/journal/events.py). The `reason` and `reason_long` describe why the event occurred. The values `user_name` and `remote_address` are included in most events and reference the clients IP address and the clients user name.

```json
{
  "id": "5c75cfc15285f54158d75a36",
  "timestamp": 1551224769.767757,
  "event": "admin_auth_failure",
  "reason": "invalid_username",
  "reason_long": "Invalid username",
  "host_id": "fbcf3dcc59874186a92065879e408627",
  "host_name": "pritunl0",
  "host_local_address": "8.8.8.8",
  "host_public_address": "8.8.8.8",
  "user_name": "testuser",
  "remote_address": "8.8.4.4",
}
```


# MongoDB Authentication

Add authentication to MongoDB

These instructions are for Oracle Linux 7. The commands for other distributions will be different. First install and start MongoDB.

```shell
sudo tee /etc/yum.repos.d/mongodb-org-4.0.repo << EOF
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOF

sudo yum -y install mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongod
```

Then create an `admin` user by first connecting with the mongo cli. Once connected switch to the `admin` database and run the create user command. Change the `PASSWORD` below to a secure random password.

```javascript
mongo
use admin;
db.createUser(
  {
    user: "admin",
    pwd: "PASSWORD",
    roles: [
      "userAdminAnyDatabase",
      "dbAdminAnyDatabase",
      "readWriteAnyDatabase"
    ]
  }
);
```

After the user has been created edit the MongoDB configuration to enable authorization. The net section should be replaced with the section below.

```shell
sudo nano /etc/mongod.conf
security:
  authorization: enabled
```

### Create Pritunl User

Then create a `pritunl` user for the `prituinl` database in the `admin` database. First connect with the mongo cli using the admin account then switch to the `admin` database. Change the `PASSWORD` below to a secure random password. When authenticating from mongo cli tools use `--authenticationDatabase admin`.

**If configuring Pritunl Zero or Pritunl Cloud update the name of the database below.**

```shell
mongo --host subnet.domain.com -u admin --authenticationDatabase admin

use admin;
db.createUser({
  user: "pritunl",
  pwd: "PASSWORD",
  roles: [{role: "dbOwner", db: "pritunl"}]
});
```

Test the new use with the command below.

```shell
mongo --host mongo-test.silicon.red -u pritunl --authenticationDatabase admin pritunl
```

### Connecting to MongoDB

When configuring Pritunl the username, password and ssl option must be added to the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@subnet.domain.com:27017/pritunl?authSource=admin` **If configuring Pritunl Zero or Pritunl Cloud update the name of the database.**

### Authentication Database

If the authentication user is on a different database the `authSource` parameter must be included in the MongoDB uri. Such as `mongodb://pritunl:PASSWORD@subnet.domain.com:27017/pritunl?authSource=admin`


# Connection Fix

Fix for connection issues

Older OpenVPN builds will have connection issues with newer client releases. To fix this issue run the command below to install the newer OpenVPN package from the Pritunl repository. A TCP server can also be used as a workaround to fix some of the issues.

## RHEL, Oracle Linux, Alma Linux, AmazonLinux

The `pritunl-openvpn` package is available on all the Pritunl RHEL repositories and will provide the latest version of OpenVPN.

```shell
sudo yum swap openvpn pritunl-openvpn
```

```shell
sudo yum --allowerasing install pritunl-openvpn
```

This can be reverted by running the command below.

```shell
sudo yum --allowerasing install openvpn
```

## Ubuntu

For Ubuntu use the [**OpenVPN Debian/Ubuntu repositories**](https://community.openvpn.net/openvpn/wiki/OpenvpnSoftwareRepos) by running the commands below.

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable focal main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable jammy main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable noble main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable buster main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable bullseye main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable bookworm main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```


# Update OpenVPN

Update OpenVPN package

Older OpenVPN builds will have connection issues with newer client releases. To fix this issue run the command below to install the newer OpenVPN package from the Pritunl repository. A TCP server can also be used as a workaround to fix some of the issues.

## RHEL, Oracle Linux, Alma Linux, AmazonLinux

The `pritunl-openvpn` package is available on all the Pritunl RHEL repositories and will provide the latest version of OpenVPN.

```shell
sudo yum swap openvpn pritunl-openvpn
```

```shell
sudo yum --allowerasing install pritunl-openvpn
```

This can be reverted by running the command below.

```shell
sudo yum --allowerasing install openvpn
```

## Ubuntu

For Ubuntu use the [**OpenVPN Debian/Ubuntu repositories**](https://community.openvpn.net/openvpn/wiki/OpenvpnSoftwareRepos) by running the commands below.

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable focal main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable jammy main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable noble main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable buster main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable bullseye main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```

```shell
sudo tee /etc/apt/sources.list.d/openvpn.list << EOF
deb [ signed-by=/usr/share/keyrings/openvpn-repo.gpg ] https://build.openvpn.net/debian/openvpn/stable bookworm main
EOF
curl -fsSL https://swupdate.openvpn.net/repos/repo-public.gpg | sudo gpg -o /usr/share/keyrings/openvpn-repo.gpg --dearmor --yes
sudo apt update
sudo apt --assume-yes install openvpn
```


# Single Sign-On Outage Fix

Handle single sign-on outages

Once a Pritunl user has authenticated with single sign-on from the Pritunl web console a VPN profile is created. This profile contains a private key and certificate used to authenticate with the Pritunl server. The Pritunl server will also use additional single sign-on APIs to verify the status of users on each VPN connection. This prevents users that are deleted or disabled on the single sign-on provider from connecting to the VPN.

If a single sign-on service becomes unavailable it is possible to skip the connection check and allow existing Pritunl users to connect. Doing this will temporarily disable the VPN connection check that checks the status of the Pritunl user with the single sign-on provider. If the single sign-on provider is also used for secondary authentication this will also be disabled. The users will authenticate using only the private key and certificate in their VPN profile.

The first option is to disable external single sign-on verification using the command `sudo pritunl set user.skip_remote_sso_check true`. Depending on what single sign-on services are offline this may allow connections. This option will not skip all single sign-on verification and secondary authentication that is dependent on external providers such as Duo will still be required. After the outage the command `sudo pritunl set user.skip_remote_sso_check false` must be run.

For further outages single sign-on can be completely disabled temporarily. To disable single sign-on connection verification open the settings from the Pritunl web console and first copy the existing single sign-on settings. These values should be saved to later restore the settings. Then set the single sign-on mode to disabled. The existing users will maintain the single sign-on association even with single sign-on temporarily disabled. Existing users will then be able to connect without single sign-on verification. New single sign-on users will not be able to authenticate from the web console until the settings are restored.


# Configure with Nginx

Load balance Pritunl web server with Nginx

### SELinux Configuration

If Nginx is running on a RHEL distributions such as Oracle Linux 8 by default SELinux will prevent proxied web requests from reaching internal servers. This can be enabled by running the commands below.

```shell
sudo setsebool -P httpd_can_network_relay 1
sudo setsebool -P httpd_can_network_connect 1
```

### Automatic Updates

The commands below will enable automatic updates on Oracle Linux 8 or any RHEL8 distribution.

```shell
sudo dnf -y update
sudo dnf -y install dnf-automatic
sudo sed -i 's/^upgrade_type =.*/upgrade_type = default/g' /etc/dnf/automatic.conf
sudo sed -i 's/^download_updates =.*/download_updates = yes/g' /etc/dnf/automatic.conf
sudo sed -i 's/^apply_updates =.*/apply_updates = yes/g' /etc/dnf/automatic.conf
sudo systemctl enable --now dnf-automatic.timer
```

### Nginx Configuration

The first command below will generate a self signed certificate to handle income requests for unknown domains and return 404. Any certificate information can be provided when prompted from the command.

The next command will write a basic optimized Nginx configuration.

```shell
sudo openssl req -x509 -nodes -days 18250 -newkey rsa:4096 -keyout /etc/nginx/ssl/notfound.key -out /etc/nginx/ssl/notfound.crt

sudo tee /etc/nginx/nginx.conf << EOF
user nginx;
worker_processes auto;
worker_cpu_affinity auto;
pcre_jit on;

events {
    worker_connections 2048;
    multi_accept on;
    use epoll;
}

http {
    server_tokens off;
    charset utf-8;
    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    access_log off;
    client_header_timeout 45;
    client_body_timeout 45;
    keepalive_timeout 65;
    connection_pool_size 1024;
    request_pool_size 8k;
    client_header_buffer_size 2k;
    client_body_buffer_size 32k;
    server_names_hash_bucket_size 512;
    server_names_hash_max_size 1024;
    types_hash_max_size 2048;

    server {
        listen 80;
        listen [::]:80;
        server_name _;
        return 404;
    }

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        ssl_certificate /etc/nginx/ssl/notfound.crt;
        ssl_certificate_key /etc/nginx/ssl/notfound.key;
        server_name _;
        return 404;
    }

    include /etc/nginx/conf.d/*.conf;
}
EOF
```

### Pritunl Server with Certbot

Nginx can also be configured to automatically renew SSL certificates with LetsEncrypt. Replace `10.123.123.123` with the internal IP address of the Pritunl server. Then replace `EMAIL@DOMAIN.COM` and `EXAMPLE.DOMAIN.COM` with a lowercase email and domain for the Pritunl server. Additional lines can be added to the `upstream` section to load balance multiple hosts.

The first command below will copy the notfound certificate to the Pritunl server domain. This will allow Nginx to start running initially. The LetsEncrypt certbot will then overwrite this certificate.

```shell
sudo cp /etc/nginx/ssl/notfound.crt /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.crt
sudo cp /etc/nginx/ssl/notfound.key /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.key
```

This configuration will send port 80 requests to `/.well-known` to the path `/usr/share/nginx/html/.well-known` where the LetsEncrypt certbot will store verification requests. All other requests will be sent to the Pritunl server.

```shell
sudo tee /etc/nginx/conf.d/pritunl-vpn.conf << EOF
upstream pritunl-vpn {
    server 10.123.123.123:443;
}

server {
    listen 80;
    listen [::]:80;
    root /usr/share/nginx/html;
    server_name EXAMPLE.DOMAIN.COM;
    location /.well-known {
      allow all;
    }
    location / {
      return 301 https://EXAMPLE.DOMAIN.COM\$request_uri;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.crt;
    ssl_certificate_key /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.key;
    server_name EXAMPLE.DOMAIN.COM;
    location / {
        proxy_pass https://pritunl-vpn;
        proxy_ssl_verify off;
        proxy_set_header Host \$http_host;
        proxy_set_header X-Forwarded-For \$remote_addr;
    }
}
EOF
```

**This configuration below will only allow access to the `/link/state` to accept requests from pritunl-link clients. This configuration can be used if the Pritunl server is only being used to accept pritunl-link clients.**

```shell
sudo tee /etc/nginx/conf.d/pritunl-vpn.conf << EOF
upstream pritunl-vpn {
    server 10.123.123.123:443;
}

server {
    listen 80;
    listen [::]:80;
    root /usr/share/nginx/html;
    server_name EXAMPLE.DOMAIN.COM;
    location /.well-known {
      allow all;
    }
    location / {
      return 404;
    }
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.crt;
    ssl_certificate_key /etc/nginx/ssl/EXAMPLE.DOMAIN.COM.key;
    server_name EXAMPLE.DOMAIN.COM;
    location /link/state {
        proxy_pass https://pritunl-vpn;
        proxy_ssl_verify off;
        proxy_set_header Host \$http_host;
        proxy_set_header X-Forwarded-For \$remote_addr;
    }
    location / {
      return 404;
    }
}
EOF
```

The scripts below will automatically check for a LetsEncrypt renewal every day.

```shell
sudo tee /etc/systemd/system/certbot.target << EOF
[Unit]
Description=Cerbot target
StopWhenUnneeded=yes
EOF

sudo tee /etc/systemd/system/certbot.timer << EOF
[Unit]
Description=Cerbot timer

[Timer]
OnCalendar=*-*-* 8:00:00
Unit=certbot.target

[Install]
WantedBy=basic.target
EOF

sudo tee /etc/systemd/system/certbot.service << EOF
[Unit]
Description=Cerbot
Wants=certbot.timer

[Service]
ExecStart=/usr/bin/certbot-nginx

[Install]
WantedBy=certbot.target
EOF

sudo tee /usr/bin/certbot-nginx << EOF
#!/bin/bash

getcert () {
  echo "Getting certificate email=\$1 domain=\$2"
  /usr/bin/certbot --webroot --agree-tos --non-interactive --webroot-path /usr/share/nginx/html --preferred-challenges http --email \$1 -d \$2 certonly
  /usr/bin/cp -f /etc/letsencrypt/live/\$2/fullchain.pem /etc/nginx/ssl/\$2.crt
  /usr/bin/chown nginx:nginx /etc/nginx/ssl/\$2.crt
  /usr/bin/cp -f /etc/letsencrypt/live/\$2/privkey.pem /etc/nginx/ssl/\$2.key
  /usr/bin/chown nginx:nginx /etc/nginx/ssl/\$2.key
}

getcert "EMAIL@DOMAIN.COM" "EXAMPLE.DOMAIN.COM"

/usr/bin/chown -R nginx:nginx /etc/nginx/ssl
/usr/bin/chmod 600 /etc/nginx/ssl/*
/usr/sbin/restorecon -R -v /etc/nginx
/usr/bin/systemctl reload nginx
EOF
sudo chmod +x /usr/bin/certbot-nginx

sudo systemctl daemon-reload
sudo systemctl enable certbot.service
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer

sudo systemctl list-timers
```

Once done start Nginx and update DNS records then obtain the first LetsEncrypt certificate.

```shell
sudo systemctl restart nginx
sudo systemctl enable nginx
sudo /usr/bin/certbot-nginx
```

### Pritunl Sync Address

After configuring Pritunl on an Nginx server the *Sync Address* option in the Pritunl host settings should be configured to the domain for the Nginx server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fsk69A9UAh3fyOLYF5ACf%2Fpritunl_nginx0.png?alt=media\&token=43fcf772-99cf-4a20-a319-faeef0979127)


# LetsEncrypt SSL Certificate

Configure automatic signed SSL certificate from LetsEncrypt

LetsEncrypt is a free service that allows getting a valid signed certificate automatically. This is done using port 80 on the Pritunl server to verify the domain ownership. The certificate will then automatically renew every 80 days. Before setting the LetsEncrypt domain the dns settings for the domain must point to the public ip address of the Pritunl server. If a firewall is used port 80 must be publicly open. For the certificate to be able to automatically renew the firewall and dns settings will need to be properly configured. After setting the LetsEncrypt domain the Pritunl server will generate a signed certificate and automatically restart the web server. The certificate will be configured on all the hosts in an Enterprise cluster.


# Custom SSL Certificate

Configure custom SSL certificate for web console

Using a custom SSL certificate allows access the web console without a self-signed certificate warning. The certificate can be changed in the advanced *Settings*. The certificate setting should first include the certificate then any intermediates, and the CA's certificate. After the certificate has been changed the web servers will automatically restart. If the SSL certificate is improperly configured and the web console becomes inaccessible it can be reset using the cli command. More information on resetting the SSL certificate can be found in the [**Commands**](https://docs.pritunl.com/kb/vpn/system/commands) section.


# Configure with CloudFlare

Protect the Pritunl web server using CloudFlare

CloudFlare is a reverse proxy service that can protect a web server from attacks. This tutorial will configure CloudFlare to protect a Pritunl server. For a secure configuration a valid SSL certificate should be configured on the Pritunl server which can be easily done with Let's Encrypt. Once a valid SSL certificate is configured on the Pritunl server enable *Allow Reverse Proxy* in the server settings and set the *Web Console Port* to *443*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FoVYRgwwdUEyf5v7GkNo6%2Fcf_settings.png?alt=media\&token=4094c20e-4e86-4d98-8969-6b3526766379)

After the Pritunl server is configured enable CloudFlare for the Pritunl DNS entry in the CloudFlare settings.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FISgfmd1yP9Pb6WZZkJ2h%2Fcf_dns.png?alt=media\&token=0af52374-479f-41b3-8254-1f3dfa5ad833)

In the *Crypto* tab set *SSL* to *Full (strict)* if a valid SSL certificate is configured on the Pritunl server or *Full* if a self signed certificate is used.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F7pDWAi6TbVcOQEHUtAvC%2Fcf_crypto.png?alt=media\&token=f77a6a9a-a8ae-4c9a-b3e8-15b3dc6cd006)

In the *Firewall* tab disable *Browser Integrity Check* under\_ Web Application Firewall\_ settings.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FJmjzzMMtSgKYm4TLGHvZ%2Fcf_firewall.png?alt=media\&token=0a76645f-a0da-4c0a-bf25-a890526c8ed6)

Once configured CloudFlare will help protect the Pritunl server from attacks. Further restrictions such as IP ranges can also be added to improve the security of the server.

### CloudFlare IP Ranges

It is import to configure the firewall of the Pritunl server to only allow access from CloudFlares IP ranges. If this is not done an attacker could attack the IP address of the Pritunl server directly avoiding any of the protections provided by CloudFlare. The [CloudFlare IP Ranges can be found here](https://www.cloudflare.com/ips/).

### Configuration Sync

When configuring load balancing the clients will not be able to access the hosts directly to sync the configuration. This is fixed by setting the *Sync Address* in the host settings to the domain name used on CloudFlare.


# Configuration

User configuration

A user represents a client certificate that is generated using the CA certificate from the users organization.

### Settings

Below is a table of the user settings.

| Setting                         | Description                                                                                                                                                                                                                                                                                                          |
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                            | The name of user. When using single sign-on this should not be changed.                                                                                                                                                                                                                                              |
| Email                           | Email address of user. This will be used to set the Gravatar image for the user and for emailing the users configuration. When using single sign-on this should not be changed.                                                                                                                                      |
| Groups                          | List of groups to associate with user. Group names are case sensitive.                                                                                                                                                                                                                                               |
| Pin                             | The user pin. This will be required when connecting to a vpn server. The user can also set this on the profile download page.                                                                                                                                                                                        |
| Port Forwarding                 | Comma separated list of ports to forward. Format can be `source_port:dest_port/protocol` or `start_port:end_port/protocol`. The destination port can be left out if it is the same as the source port. If the protocol is not included both `tcp` and `udp` will be forwarded.                                       |
| Network Link                    | Comma separated list of network addresses with cidr subnet. This will provision access to a clients local network to the vpn server.                                                                                                                                                                                 |
| Client-to-Client Only           | Only allow this client to communicate with other clients. Access to routed networks will be blocked.                                                                                                                                                                                                                 |
| DNS Forwarding Server           | This will forward dns requests that are a sub-domain of the user such as `search.user.org.vpn`. The dns server must be accessible to the server, this can be done by using the clients vpn address or using a network link if the dns server is on the clients network. Multiple dns servers can be comma separated. |
| DNS Forwarding Suffix           | Suffix for dns forwarding. A user with a dns of `user.org.vpn` and a dns suffix of node.consul will forward the dns request `search.user.org.vpn` to `search.node.consul` via the dns forwarding server.                                                                                                             |
| Bypass Secondary Authentication | Bypass all secondary authentication systems such as two-factor authentication and Duo. This is useful for server users.                                                                                                                                                                                              |


# Chrome OS

Chrome OS support

Pritunl allows users to download a zip archive containing an onc configuration file and p12 cert file. The user can then import these files on their Chromebook and connect to a Pritunl server. Because of the limitations and bugs with OpenVPN on Chrome OS it is best to create a separate server for Chromebook users. Single sign-on should also be used which will allow users to authenticate with the Pritunl server using their Google account and then download their keys. The onc configuration file can only include one hostname so it is best to use only one host with the server. If multiple hosts are used all the hosts must be online which can be done by setting the Replication Count. Below is a list of known limitations with OpenVPN on Chrome OS. With an Enterprise license a Chromebook link will be displayed on the key download dialog and user key download page. Instruct users to use the Chromebook tutorial when connecting.

Refer to [**Debugging**](https://docs.pritunl.com/kb/vpn/debugging/client) for information on debugging Chrome OS clients.

Refer to [**Chrome OS Client**](https://docs.pritunl.com/kb/vpn/tutorials/chrome-os) for documentation on configuration a Chrome OS client.

### Known Limitations

* ChromeOS v66 corrupts routing table when Chromebook is suspended requiring manually reconnecting
* Password must be entered even if user has no password. If no password is configured the user should be instructed to enter any password. It is recommend to use an authentication configuration that has a pin or OTP code to avoid user confusion.
* IPv6 routing currently does not work on ChromeOS. Clients will still be able to connect to the Pritunl server over IPv6 but no IPv6 traffic will route through the VPN.
* Allow multiple devices should be disabled
* Configuration sync not available


# Emailing User Profile

Send profile link to users email address

Pritunl allows creating a temporary link that a user can open that will provide access to their two-factor authentication code if in use and their vpn configuration files. This link can be generated by clicking the link button on a user or by emailing the link to the users. Emailing key links can be done by configuring the SMTP settings and selecting users that have a email address set. Pritunl will then generate temporary links and email the links to the users to allow them to access their configurations. For the best security single sign-on should be used to give users access to Pritunl.


# Port Forwarding

Forward ports to vpn users

Port forwarding allows forwarding a port from the server to a connected user this can be done in the users settings. Port forwarding can be enabled for a user at any time including while the user is connected. The changes to port forwarding will happen immediately and don't require the user to reconnect or the server to be restarted. Multiple ports can be forwarded using a comma separated list. Below are some examples of port forwarding options.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FFlxyADIBpR1LrCsP1XcE%2Fport_forwarding.png?alt=media\&token=1b98a01e-fbd4-44bf-aa8a-2210cb89e257)

### Examples

| Setting         | Description                                                       |
| --------------- | ----------------------------------------------------------------- |
| `1024`          | Forward both tcp and udp port 1024                                |
| `80/tcp`        | Forward tcp port 80                                               |
| `1000-2000`     | Forward tcp and udp ports in range 1000 to 2000                   |
| `1000-2000/udp` | Forward udp ports in range 1000 to 2000                           |
| `1000:100`      | Forward tpc and udp port 1000 on the server to the users port 100 |
| `8000:80/tcp`   | Forward tcp port 8000 on the server to the users port 80          |


# Network Links

Create a network link to remote network behind client

Network links known as routed LANs or iroute in OpenVPN allow routing a subnet that is behind an OpenVPN client to the OpenVPN server. This creates a site-to-site link between the clients network and the VPN servers network. The option can be found in the user settings with an enterprise subscription. If other computers on the clients network need to access OpenVPN clients or routes on the OpenVPN server a static route will need to be added to the router of the clients network. If the OpenVPN client is a router such as when using the Pritunl EdgeRouter plugin this is not needed.


# Groups

Users groups usage

User groups allow more specific access control and allow a user to be associated with multiple groups. This is useful when organizations access requirements overlap and only a sub group of users in an organization need access to a server. To use user groups first associate users with groups then associate the same groups to a server. Then attach the organization to the server. Once done only users in a group associated with the server will be allowed to connect. If a user is not in one of the servers groups or the user is not in any groups the user will not be able to connect to the server.


# Two-Step Authentication

Client configuration for PINs and two-step authentication

Pritunl provides four methods for two-factor authentication. Additional six digit user pins can be required providing improved security.

### Yubico YubiKey

Yubico YubiKeys provide the highest level of security with Pritunl. The YubiKeys act as a USB keyboard, when the users touches the center of the key a 44 character OTP code will be sent followed by the enter key. This allows the key to work on any computer that supports USB keyboards, including Android phones using a USB-C adapter or the new YubiKey 4C with a USB-C connector. The code is then sent to the Yubico servers to be verified. The 44 character code also includes the ID of the key which allows for simple enrollment by the user. When the user first logs in to Pritunl they only need to touch the key once to associate it with the Pritunl user. YubiKeys also only require a one time purchase of the key with no monthly costs.

### Duo Hardware Token

Duo hardware tokens provide a level of security similar to YubiKeys. An administrator must manually associate each tokens serial number with a Duo account. The tokens rely on a battery and internal clock to keep the time synchronized which often becomes out of sync if not used often which will prevent the user from authenticating. These tokens also require a per user monthly subscription from Duo in addition to the cost of the token.

### Duo, OneLogin and Okta Push

Duo, OneLogin and Okta push allows users to authenticate by confirming a push notification that is sent to the users mobile phone. This is very effective in preventing phishing attacks although a phishing attack would be very difficult as a the user will generally only authenticate with the VPN client. Both require the user to install an app on their phone and have a monthly subscription cost.

### Google Authenticator

Google Authenticator uses a time based OTP code that is verified by the Pritunl server. Enrollment is done by the user scanning a QR code from the profile view page. It is intended for small user sets when users are created manually. This should not be used with single sign-on as the OTP secret is shown on the profile view page when a user signs in.

### Password Field

The official Pritunl client, OpenVPN for iOS and OpenVPN for Android are the only clients that directly support using both a PIN and two-step authentication. For all other OpenVPN clients the PIN and two-step authentication code must be combined. If the OpenVPN client supports challenge responses the user will be prompted to enter the passwords separately. Both the iOS and Android client support this. Below is a table showing how to format the OpenVPN password field. **The username must be filled in on most OpenVPN clients to enter a password but can be set to anything. The users certificate is only associated with one user on the Pritunl server so it is not necessary to verify the username. The OpenVPN username is ignored by the Pritunl server. This is also true for Radius users.**

| Authentication                     | Password Field                            | Example                |
| ---------------------------------- | ----------------------------------------- | ---------------------- |
| PIN Only                           | PIN (123456)                              | 123456                 |
| Two-Step Authentication            | OTP (123456)                              | 123456                 |
| Duo Passcode                       | Duo (123456)                              | 123456                 |
| YubiKey                            | YubiKey (cbdefghijklnrtuv)                | cbdefghijklnrtuv       |
| PIN and Two-Step Authentication    | PIN (111111) + OTP (222222)               | 111111222222           |
| PIN and Duo Passcode               | PIN (111111) + Duo (222222)               | 111111222222           |
| PIN and YubiKey                    | PIN (111111) + YubiKey (cbdefghijklnrtuv) | 111111cbdefghijklnrtuv |
| Radius                             | Radius Password (123456)                  | 123456                 |
| Radius and Two-Step Authentication | Radius Password (111111) + OTP (222222)   | 111111222222           |


# Too Many Authentication Attempts

Clear authentication limiter

When some clients have connection issues it is possible to trigger the authentication limiter that limits connection attempts to 20 per 10 minutes. The command below can be run on any Pritunl host in a cluster to clear the limiter data, this will reset the limit for all users. No Pritunl hosts or servers need to be restarted when running this command.

```shell
sudo pritunl clear-auth-limit
```

The commands below can be used to adjust the limit window in seconds and the attempt count. These commands only need to be run on one host in a cluster and no restarts are required.

```shell
sudo pritunl set app.auth_limiter_ttl 600
sudo pritunl set app.auth_limiter_count_max 20
```


# Searching

Searching for users in an organization

Searching for users can be done by entering part of a users name in the search field to find users containing the search term. It is also possible to use search operators for advanced searches. Below is a table of the available search operators.

| Operator | Example           | Description                                                                                                                                                                                 |
| -------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| group:   | group:name        | Matches users group by name. Group name is case sensitive.                                                                                                                                  |
| email:   | email:pritunl.com | Matches the term with any part of a users email address.                                                                                                                                    |
| status:  | status:online     | Matches status of user, can be *online* or *offline*.                                                                                                                                       |
| type:    | type:client       | Matches user type, can be *ca*, *server*, *client*, *server\_pool* or *client\_pool*. This search will require showing hidden users by holding shift and clicking the *Organization* label. |


# Configuration

Server configuration

Servers represent an OpenVPN server that can be run on one or more Pritunl hosts in the cluster.

### Client Configuration Sync

It is important to avoid changing some settings after users have downloaded the configuration. Several OpenVPN settings are stored in the client configuration file. When these settings change users not using a Pritunl client will not be able to connect to the vpn server without first updating the configuration file. Users using a Pritunl client will sync all configuration changes before connecting and will not need to update the configuration. The web console will display a warning when changing a setting that will require a configuration update.

### Settings

Below is a table of server settings.

| Setting                       | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                          | Name of server.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Port                          | Server port, default is a random port.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Protocol                      | Server protocol, udp is recommended for best performance.                                                                                                                                                                                                                                                                                                                                                                                                       |
| Virtual Network               | The network address with subnet that will be used for vpn clients. The network should be larger then the total number of users attached to the server. Networks smaller then the number of users attached can get address conflicts and connection issues. Default is a random network.                                                                                                                                                                         |
| WG Port                       | Server port for WireGuard connections.                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Virtual WG Network            | The network address with subnet that will be used for WireGuard vpn clients. The network should be larger then the total number of users attached to the server. Networks smaller then the number of users attached can get address conflicts and connection issues. Default is a random network.                                                                                                                                                               |
| DNS Server                    | Comma separated list of dns servers sent to client. Depending on the client system configuration the client could ignore this address using a system set dns server instead. This address can be an address that is only accessible to the client once connected. When using dns mapping the Pritunl server will use these servers to forward dns requests to.                                                                                                  |
| Groups                        | List of user groups that have access to server. Groups are matched in addition to organization. If groups are set all users connecting to the server must have at least one matching group.                                                                                                                                                                                                                                                                     |
| Enable WireGuard              | Enable WireGuard connections in addition to OpenVPN.                                                                                                                                                                                                                                                                                                                                                                                                            |
| Enable IPv6                   | Enables IPv6 support on the server, requires an IPv6 interface with an IPv6 address. The client IPv6 addresses will be derived from the IPv4 address. Enabling IPv6 is not recommend unless it is needed.                                                                                                                                                                                                                                                       |
| Enable Google Authenticator   | Require clients to use Google Authenticator. After enabling a button will appear next to users that will display a barcode and code for use with Google Authenticator. The code will also appear on the key view page. The two-step code should be entered as the password when using an OpenVPN client, the username field can be any value or empty.                                                                                                          |
| DH Param Bits                 | Length of DH parameters, a longer length provides greater encryption for connections. Lengths greater then 1536 bits can take several hours to generate depending on the performance and availability of random data on the server.                                                                                                                                                                                                                             |
| Encryption Chiper             | Encryption chiper used for encrypting client connections. Most servers will have hardware AES acceleration.                                                                                                                                                                                                                                                                                                                                                     |
| Hash Algorithm                | Authentication hash algorithm.                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| Ping Interval                 | The interval in seconds that pings will be sent between the server and client to verify client is still connected.                                                                                                                                                                                                                                                                                                                                              |
| Ping Timeout                  | The time in seconds that must pass without a ping from a client before the client is disconnected.                                                                                                                                                                                                                                                                                                                                                              |
| User Link Ping Interval       | The time in seconds between pings that will be sent to redundant network links. Used to determine when a redundant network link has failed at which point the link will be switched to an available failover.                                                                                                                                                                                                                                                   |
| User Link Ping Timeout        | The timeout in seconds for a redundant network link. When exceeded the network link will switch to an available failover.                                                                                                                                                                                                                                                                                                                                       |
| User Session Timeout          | Maximum length of user connection session.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Max Clients                   | The maximum number of clients that can connect to a server on a Pritunl host. If multiple hosts are used the limit will apply separately to each host.                                                                                                                                                                                                                                                                                                          |
| DNS Search Domain             | The dns search domain that will be pushed to clients.                                                                                                                                                                                                                                                                                                                                                                                                           |
| Network Mode                  | Set network node. Bridged mode is not recommended using it will impact performance and client support will be limited.                                                                                                                                                                                                                                                                                                                                          |
| Network Start                 | Shown only for bridged mode. The starting networking address for bridged VPN client IP addresses. This range should be large enough for all users attached to the server.                                                                                                                                                                                                                                                                                       |
| Network End                   | Shown only for bridged mode. The ending networking address for bridged VPN client IP addresses. This range should be large enough for all users attached to the server.                                                                                                                                                                                                                                                                                         |
| Replication Count             | The number of hosts that the server will run on. If there is not enough hosts online to satisfy the replication count the server will still run on the available hosts. When replication and inter-client communication is enabled routes will be created for the clients to the local network address of the respective host. For this to work the host local network must be properly configured and all the replica hosts must be on the same local network. |
| Allow Multiple Devices        | Allow users to use their key on multiple devices and connect at the same time. Additional clients from one user will be given a random IP address when connecting.                                                                                                                                                                                                                                                                                              |
| Enable Debugging Output       | Show verbose output for the server. This should not be enabled on a production server.                                                                                                                                                                                                                                                                                                                                                                          |
| Enable VPN Client DNS Mapping | Map the vpn clients ip address to the .vpn domain such as example\_user.example\_org.vpn. A custom dns server is run to support this feature. Clients should all use the vpn server address as the primary dns server. This will be the first host on the vpn network. The dns server will forward dns requests to the dns servers set in the server settings for requests that are not on the .vpn domain.                                                     |
| Inter-Client Communication    | Allow client-to-client communication.                                                                                                                                                                                                                                                                                                                                                                                                                           |


# Replication

Server replication

Servers can be replicated to several hosts to balance load and provide redundancy. When servers are replicated the VPN network will exist separately on each replica. To allow clients to communicate with clients on other replicas routes will be created for each client to the respective hosts local ip address. By default the local address will be automatically set for each host, it can also be manually set in the host settings.

### Client-to-Client Traffic

For client-to-client traffic to work all replicas must have layer 3 connectivity. Firewalls should also allow communication between the replicas including UDP port 4789. If replicated servers cannot communicate on a local network *Inter-Client Communication* must be disabled in the server settings.

### Replication with non-NAT Routes

If non-NAT routes are using the servers must be replicated with the VXLan and route advertisement enabled. The VXLan UDP port 4789 must also be opened between Pritunl hosts.

### Amazon Web Services

Using replication on EC2 requires the source/dest check to be disabled for the network interfaces attached to the Pritunl servers. This will allow the servers to route traffic from the VPN network. This can be found in the Network Interfaces section of the EC2 Dashboard. In addition to this the security group for the Pritunl servers must allow traffic from the VPN network.


# Routes

Server routes configuration

The server routes configure which networks vpn clients will send traffic to. By default a server will route all internet traffic to the vpn server. This is done with the `0.0.0.0/0` route.

### Settings

| Setting                        | Description                                                                                                                                                      |
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Network                        | The network address with cidr subnet that will be routed.                                                                                                        |
| NAT Route                      | Enable NAT for the route to NAT traffic from vpn clients to the network. This is required unless a static route is configured on the router for the vpn network. |
| VPC Route Advertisement Region | AWS region for route advertisement.                                                                                                                              |
| VPC Route Advertisement ID     | The VPC ID for the route advertisement. The EC2 server hosting the server must be connected to this VPC.                                                         |

### Amazon Web Services VPC Route Advertisement

Route advertisement allows Pritunl to automatically add a static route for a network on the VPC routing table. This will route traffic for the network to the current EC2 hosting the vpn server. This is useful for automatic configuration and fail over configurations. When route advertisement is used and a vpn server fails the static route will be updated to a healthy vpn server host. The source/dest check must be disabled for the network interfaces attached to the Pritunl servers. This will allow the servers to route traffic from the vpn network. This can be found in the Network Interfaces section of the EC2 Dashboard. In addition to this the security groups for servers on the VPC must be configured to allow traffic from the vpn subnet. When creating the AWS credentials the *AmazonVPCFullAccess* policy should be the only policy attached to the credentials.


# Routing Issues

Fixing server routing issues

By default Pritunl will add iptables rules to provide additional routing protection by restricting which networks a VPN client can access. The restrictions are added based on which networks are routed. This can create issues for some complex routing configurations. If you are having routing issues the restrictions can be disabled by unselecting *Restrict Routing* in the advanced server settings.

### Routing on AWS and Google Cloud

Many Pritunl configurations will require the instances to route traffic to different networks. By default this will be blocked by the source/dest check (AWS) or fowarding option (Google) and should be disabled (AWS) or enabled (Google) to avoid issues. This can be done on AWS in the Network Interfaces panel in the EC2 dashboard. For Google Cloud the forwarding option can be found in the network options when creating the instance.


# Internal DNS or VPC DNS Server

Provide access to an internal DNS or VPC DNS server

Some internal DNS servers such as the VPC DNS server used to access private hosted Route53 zones can only be accessed by servers on the VPC. If NAT is not used VPN clients will not be able to access the VPC DNS server as it will not respond to queries from other networks. This can be fixed by adding a `/32` NAT route to only the IP address of the internal DNS server. Below is example with non-NAT routes and NAT route for only the VPC DNS server on `10.150.0.2/32`. The *DNS Server* in the server settings is then set to `10.150.0.2`. This will allow users to access the VPC DNS server and the private Route53 zones. It is recommended to add `8.8.8.8` as the second DNS server in the settings such as `10.150.0.2, 8.8.8.8`. This will give clients a fallback server and some OpenVPN clients will not reset the DNS servers when reconnecting. If the DNS servers are not reset for reconnection the VPN client will be unable to lookup the VPN server domain to connect.

### Internal DNS Proxy

For some configurations it may be preferred to not give direct access to the internal DNS server or the internal network. For these configurations the *Enable VPN Client DNS Mapping* option in the server settings can be enabled. Then set the *DNS Server* to the IP address of the internal DNS server. When client DNS mapping is enabled the pritunl-dns server is used and all client DNS queries will be sent to this server. When the pritunl-dns server receives a query that is not for the *.vpn* client TLD it will proxy the query to the DNS server configured in the server settings then send the response back to the client.


# IPv6

IPv6 server configuration

Pritunl offers three primary IPv6 configurations, all three will provide IPv6 internet access to Pritunl clients including clients that only have IPv4 internet connections.

### NAT

This is the simplest IPv6 configuration that will NAT the primary IPv6 address of the Pritunl server. Clients will be given private IPv6 addresses. This configuration only requires enabling IPv6 in the server settings.

### Routed IPv6 Subnet

This configuration will give each Pritunl client an IPv6 address from a routed IPv6 subnet. All clients will get a public routable IPv6 address that will accept ICMPv6 traffic. The IPv6 firewall can be disabled in the advanced server to allow all traffic to reach the client. This configuration requires an IPv6 block that is routed to the Pritunl server. Some providers such as Linode will provide this upon request.

### Routed IPv6 Subnet with Proxied NDP

Some providers will only route IPv6 addresses once found with Neighbor Discovery Protocol. By default NDP packets wont reach the Pritunl clients. This can be fixed by enabling *Proxy NDP* in the host settings. Providers such as Vultr provide an NDP routed IPv6 subnet to all servers by default.


# Network Mapping

Network mapping to handle overlapping subnets.

Sometimes remote networks routed through the VPN server can overlap or conflict with the local network of the remote user connecting. This can cause connection issues and prevent the user from accessing network resources. Network mapping allows remapping a route on the server to a different subnet of the same size. In the diagram below the VPC network `192.168.0.0/16` overlaps with the users network `192.168.1.0/24`. This will be fixed by mapping `192.168.0.0/16` to `10.168.0.0/16`. The remote user will then be able to access all hosts on `192.168.0.0/16` using the subnet `10.168.0.0/16` without effecting connection to resources on the local network.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FicyPjcU4ljnn8F05IbGU%2Fnetwork_mapping.png?alt=media\&token=5b8f231d-8188-4002-9fc4-1830ae2b4752)

### Configure Server

When adding or modifying a route on the server enter the original network in the route *Network* field. Then enter the new subnet that will be used to access this network in the *NAT Network Mapping* field. This configuration will require NAT and doesn't support non-NAT configurations.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fm89wc6hRypUK4LWdpeee%2Fnetwork_mapping0.png?alt=media\&token=52703412-4e81-44d5-8ed1-8a42040e31ec)

Once done the route will have a label *NAT Mapped* and will be ready to use.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FzekOi5aJPp1qcZhuYnDU%2Fnetwork_mapping1.png?alt=media\&token=244d4f01-a927-4be4-bb1e-e7617aa92ed2)


# Adding Routes with API

Add server routes with Pritunl API

When managing servers with hundreds of routes the API can be used to create the routes. Below is an example of a common use case of adding public AWS ranges. The API requires an enterprise subscription and the key can be found in the administrators tab of the web console.

```python
import requests
import time
import uuid
import hmac
import hashlib
import base64
import json
import sys

BASE_URL = 'https://server.domain'
API_TOKEN = 'Hv2FxEMoa3moTVuRahMsMK3VUCwdmjmt'
API_SECRET = 'zihea5hTIpIgxsPFboby4hctopxWQSKd'
SERVER_ID = '57e9e364fd632c233e86f827'
REGIONS = {
    # 'GLOBAL',
    #
    # 'us-east-1',
    # 'us-east-2',
    # 'us-west-1',
    # 'us-west-2',
    # 'us-gov-west-1',
    #
    # 'eu-central-1',
    # 'eu-west-1',
    #
    # 'ap-south-1',
    # 'ap-northeast-1',
    # 'ap-northeast-2',
    # 'ap-southeast-1',
    # 'ap-southeast-2',
    #
    # 'cn-north-1',
    #
    # 'sa-east-1',
    #
    # 'us-gov-west-1',
}

def auth_request(method, path, headers=None, data=None):
    auth_timestamp = str(int(time.time()))
    auth_nonce = uuid.uuid4().hex
    auth_string = '&'.join([API_TOKEN, auth_timestamp, auth_nonce,
        method.upper(), path])
    if sys.version_info[0] < 3:
        auth_signature = base64.b64encode(hmac.new(
            API_SECRET, auth_string, hashlib.sha256).digest())
    else:
        auth_signature = base64.b64encode(hmac.new(
            API_SECRET.encode('utf-8'), auth_string.encode('utf-8'), hashlib.sha256).digest())
    auth_headers = {
        'Auth-Token': API_TOKEN,
        'Auth-Timestamp': auth_timestamp,
        'Auth-Nonce': auth_nonce,
        'Auth-Signature': auth_signature,
    }
    if headers:
        auth_headers.update(headers)
    return getattr(requests, method.lower())(
        BASE_URL + path,
        headers=auth_headers,
        data=data,
    )

response = requests.get('https://ip-ranges.amazonaws.com/ip-ranges.json')
ranges = response.json()
routes = []

for range in ranges['prefixes']:
    if range['region'] not in REGIONS:
        continue

    routes.append({
        'network': range['ip_prefix'],
        'nat': True,
    })

response = auth_request(
    'POST',
    '/server/%s/routes' % SERVER_ID,
    headers={
        'Content-Type': 'application/json',
    },
    data=json.dumps(routes),
)
assert(response.status_code == 200)
```


# Server Links

Cross link server networks to provide access to networks behind multiple servers


# Site-to-Site

Site-to-site VPN with linked servers

Site-to-site configurations are often unnecessary and should be avoided. If the only use for a site-to-site configuration is to provide remote users access to multiple sites creating a server at each site without linking will be more reliable and maintainable. Remote users can then connect to each site individually. If communication between servers at each site is required or users need to be able to connect to a single VPN server several services are available to interconnect networks such as AWS Direct Connect, Google Direct Peering and Azure ExpressRoute. These services partner with network providers using dedicated networks and hardware and will outperform any site-to-site VPN running on virtual instances. Additionally features such as replication are not available with linked servers.


# Link Configuration

Pritunl server Link configuration

Links allow creating site-to-site links with IPsec using Pritunl Link clients. The Pritunl Link client communicates with the Pritunl cluster using HTTPS. This allows linking sites without needing to provide database access. Multiple link clients can be deployed to each site for automatic failover. Automatic routing table support is available on AWS, Google Cloud and Ubiquiti Unifi. The diagram below shows the infrastructure design of Pritunl IPsec links.

**The Pritunl server does not provided site-to-site connectivity in a Pritunl Link configuration. The Pritunl server will only manage the link state for Pritunl Link clients connected to the Pritunl server. Each link must have at least two locations and each location must have at least one host. Pritunl Link cannot run on the same host as the Pritunl server.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F8wgh2T0A2C6r8zzt55ie%2Flink_infrastructure.png?alt=media\&token=6c58d32a-b9ab-436b-ae6a-afed7122ce74)

### Creating a Link

Create the link and locations for each network, the example below has two VPCs. Add a route for each subnet on the network. Create a host for each Pritunl link client, two link clients can not use the same host. The hosts will be associated with a Pritunl Link client using the URI.

The link hosts are defined in the Pritunl web server first then associated with a pritunl-link client using the URI. Click *Add Host* to add a new host then associate that host to a pritunl-link client configured using the other tutorials for each cloud provider.

**The pritunl-link client cannot run on a Pritunl server and the Pritunl server will not function as a link host. All hosts must be defined in the link configuration.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fw0ad161kehNxuX4XEHJ5%2Flink0.png?alt=media\&token=363749d7-892c-4624-9047-49ee5eecb8cd)

Once the links are configured the state will change to *Available* when the host is connected to the Pritunl cluster and *Active* when the host is being used for an IPsec connection.

### Recommended IPsec Ciphers

If all sites are using the latest version of pritunl-link it's recommended to use the `aes128-sha256-x25519` IKE cipher and `aes128gcm128-x25519` ESP cipher. The *Force Preferred Cipher* can also be used to require IPsec links to use this cipher to prevent automatic cipher selection from selecting a slower cipher.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FJCZReldpGYa9pLXUdIN1%2Fpreferred_cipher.png?alt=media\&token=f5b7d71a-b0af-4693-99e0-3c8c8e8f9b80)

Below is a list of common ciphers, a full list is available in the [**strongSwan Wiki**](https://wiki.strongswan.org/projects/strongswan/wiki/IKEv2CipherSuites). `AES 128 GCM` is the recommended cipher for the best performance

```
# AES 128 GCM
IKE=aes128-sha256-x25519 ESP=aes128gcm128-x25519

# AES 256 GCM
IKE=aes256-sha256-x25519 ESP=aes256gcm128-x25519

# ChaChaPoly
IKE=chacha20poly1305-prfsha256-x25519 ESP=chacha20poly1305-x25519
```

These newer GCM ciphers provide high link speeds with minimal CPU usage. High end network adapters such as the `Mellanox ConnectX-6 DX` also support offloading this cipher. Below is a speed test on an Oracle Cloud BM.Optimized3.36 bare metal server with Mellanox ConnectX-6 DX adapters. The single connection test measured 12.8 gigabit/sec and the 10 connection test measured a total speed of 13.2 gigabit/sec

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2F7T87o4yBXqlLREHGke7M%2Fipsec_speedtest2.png?alt=media\&token=28e79a0f-66fc-4ee0-b538-3b39931c0da6)

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAblFT9QMOcLPl5Vh4FUs%2Fipsec_speedtest.png?alt=media\&token=52c79589-10ea-4e8f-a568-abc03eca604f)

### Host Checking

Host checking uses an additional network check between all hosts in a link. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration. All link clients must be updated to v1.2 to support host checking.

**The client must have access to TCP port 9790 on all other hosts.**

### Backoff Timeout

The *Backoff Timeout* option in the host settings allows setting a duration in seconds that the host will be ineligible for becoming an active host. This timer will begin after a host goes offline, once the configured number of seconds has past since the host went offline the host can be selected as a primary.

### Route Removal

By default the link client will not attempt to remove any routes from routing tables. This is done to prevent potentially removing a route that was manually modified by an administrator. For larger more complex configurations automatic removal of unused routes can be important. To enable this run `sudo pritunl-link remove-routes-on` on all link clients. If a route is removed in the Pritunl link configuration the link clients will remove that route from the routing tables.

### Automatic Firewall

The link automatic firewall will configure iptables to only allow other link hosts to access ports `UDP/500`, `UDP/4500` and `TCP/9790`. The link will automatically adjust the allowed IP addresses when hosts are added or removed or when a host IP address changes. This allows configuring the instance/external firewall to allow all IP addresses to access these ports without reducing the security of the system. This option is useful for configurations where a host IP address can change frequently. Any application that interferes with iptables such as firewalld cannot be used with this option. This option is not intended to replace an instance/external firewall, it will only control access to the ports used by pritunl-link. Run the command `sudo pritunl-link firewall-on` on the link host to enable the firewall.

When enabling this option all external firewalls such as the instance or VCN firewall should allow ports `UDP/500`, `UDP/4500` and `TCP/9790` from `0.0.0.0/0`. The pritunl-link client will handle further restricting the access to these ports from the Linux system firewall.

### Host Priority

Each host has a priority that defaults to 1. The host with the highest priority that is available will always be used. This allows using a more powerful server as the primary and a less powerful server for failover to reduce costs. It is also necessary for some use cases such as the one shown below. In the example below the `unifi-office` location has a primary and failover client in both `us-east-office` and `us-west-office`. This configuration is useful if the `unifi-office` location needs access to both `aws-us-east` and `aws-us-west` but `aws-us-east` can not access `aws-us-west`. Port forwarding is needed for the clients in the `unifi-office` location because the clients are behind a Unifi Security Gateway with only one public IP address. Without setting a priority it would be possible for both `link0` and `link1` to become active at the same time. If this were to happen both clients would continue to update the port forwarding preventing the other client from connecting. To solve this `link0` in `unifi-office` should be given a higher priority then `link1` in both `us-east-office` and `us-west-office`. This will ensure the same link client is active between `us-east-office` and `us-west-office` while still having fast and automatic failover to `link1` if `link0` were to fail.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FIEsNtZ9kIOoKO880x5tZ%2Flink11.png?alt=media\&token=80f6889d-d14b-4aed-a4c6-77ccbfcff16a)

### Host Timeout

Each host has a optional timeout, this will override the default timeout of 30 seconds. The time to failover is around 3 seconds + timeout. A longer timeout will increase the time to failover when a link host goes offline. Depending on how the link host is lost it may send a signal to the Pritunl server to indicate it is offline which will allow the link to failover in 3 seconds. Setting a lower timeout can shorten the time to failover but can also lead to an unnecessary downtime and failover in the event of a short latency spike or connectivity issue.

### IPsec Routers

When running pritunl-link on a network with an IPsec router only one host can be used. Automatic failure for that network will not be available but other link locations can use automatic failover. After configuring all link locations use the list of routes in `/var/lib/pritunl_link/routes` to then create static routes. Add a static route on the local network router for each of the subnets with the next-hop set to the local IP of the server running pritunl-link. If new link locations or routes are added this file will update and the static routes will also need to be updated.

**Extensive testing with different routers and cloud provider IPsec offerings has shown that these router IPsec clients will significantly underperform an instance or server running IPsec. This includes cloud IPsec offerings that are managed by the cloud provider. Running IPsec on a router should only be done when it is not possible to configure a pritunl-link client with port forwarding. Additionally many failover features will be unsupported when not using pritunl-link clients for IPsec.**

### Connectivity Issues

Connectivity issues are often caused by incorrectly configured firewalls. In the example below **client1** is making a SSH connection to **server1**. For this connection **server1** must allow ssh traffic from the IP address of **client1**. This connection will also require that **pritunl-link** accept ssh traffic from **client1**. The ssh connection going to **server1** will still be detected as ingress traffic to **pritunl-link** requiring that both **pritunl-link** and **server1** allow the traffic from **client1**. To avoid this typically **pritunl-link** should accept all traffic from the VPC network with **client1**.

(client1 ssh client) -> (pritunl-link) -> (server1 ssh server)


# Host Checking

Pritunl Link host checking

Host checking uses an additional network check between all hosts in a link. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration. All link clients must be updated to v1.2 to support host checking. This feature is optional but if the port is not opened the link page will show the link hosts as offline.

**The client must have access to TCP port 9790 on all other hosts.**


# Connectivity Issues

Pritunl Link connectivity issues

Connectivity issues are often caused by incorrectly configured firewalls. In the example below **client1** is making a SSH connection to **server1**. For this connection **server1** must allow ssh traffic from the IP address of **client1**. This connection will also require that **pritunl-link** accept ssh traffic from **client1**. The ssh connection going to **server1** will still be detected as ingress traffic to **pritunl-link** requiring that both **pritunl-link** and **server1** allow the traffic from **client1**. To avoid this typically **pritunl-link** should accept all traffic from the VPC network with **client1**.

(client1 ssh client) -> (pritunl-link) -> (server1 ssh server)


# Installation

Install Pritunl Link client

Pritunl Link client is packaged for several Linux distributions. Refer to [**Repositories**](doc:repo) for the available Linux repositories then install the package `pritunl-link`. Once installed the client will be started automatically and will be ready to configure. Follow the cloud provider specific instructions in the *IPsec Peering* section for more detailed instructions.


# AWS

Pritunl Link client on AWS

**For a more detailed tutorial refer to** [**Site-to-Site with IPsec**](https://docs.pritunl.com/kb/vpn/tutorials/pritunl-link)

First create a IAM Instance Role with full VPC access. This is needed to allow the Pritunl Link client to modify the VPC routing table.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Ft6wteRYdTbT0zXvoq1a2%2Flink1.png?alt=media\&token=fb43bc3c-85f5-44c7-bbf2-438c8ba2292a)

Below is a more specific IAM JSON policy for the instance role.

```json
{
 "Version": "2012-10-17",
 "Statement": [
   {
     "Effect": "Allow",
     "Action": [
       "ec2:DescribeRouteTables",
       "ec2:CreateRoute",
       "ec2:ReplaceRoute",
       "ec2:DeleteRoute"
     ],
     "Resource": "*"
   }
 ]
}
```

Create a security group and open `UDP` ports `500` and `4500` to allow IPsec traffic. The clients must also have HTTPS access to the Pritunl cluster.

**Optionally TCP port 9790 can also be opened for host to host checking. This allows each pritunl-link host to ping other hosts to measure latency and availability. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FSBhL2QWM2JNiYqEgpGsh%2Flink4.png?alt=media\&token=150d4868-1cb4-46e6-8aaf-68b41b2fa1ca)

Launch an Amazon Linux 2023 server in the VPC that is going to be linked. Select the IAM role created earlier. Use the startup script below.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FTEaemIDpigI8mlWxWmt5%2Flink10.png?alt=media\&token=3806b020-cca4-4a55-a056-149a0487a30c)

Below is the startup script that can be put it in the *User data* or run manually. The first pritunl-link command needs to be run if the Pritunl server does not have a signed HTTPS certificate. The data will be signed and encrypted with AES independently an unsigned certificate will not effect security. The second command sets the provider to `aws`. The third command will add the URI, this needs to be replaced by clicking *Get URI* in the Pritunl web console. This command can be run multiple times if more then one link is configured. The `pritunl-link verify-off` line can be left out if the Pritunl server is configured with a valid SSL certificate. It is not necessary to verify the SSL certificate, the sensitive data is encrypted with AES-256 and signed with HMAC SHA-512 using the token and secret in the URI.

<pre class="language-shell"><code class="lang-shell">#!/bin/bash
sudo tee /etc/yum.repos.d/pritunl.repo &#x3C;&#x3C; EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/amazonlinux/2023/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo yum -y update
<strong>sudo yum -y install pritunl-link
</strong>
<strong>sudo pritunl-link verify-off
</strong>sudo pritunl-link provider aws
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
</code></pre>

If an IPv6 link is being configured the sysctl commands below must be run at the instance startup to configure IPv6 autoconf.

```shell
sudo sysctl -w net.ipv6.conf.all.accept_ra=2
sudo sysctl -w net.ipv6.conf.default.accept_ra=2
sudo sysctl -w net.ipv6.conf.eth0.accept_ra=2
```

Right click on the instance and select *Networking* then *Change Source/Dest. Check* to disable the source/dest check. This is needed to allow the instance to transmit network traffic from other networks.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FawKDfILglzCY665olIHj%2Flink3.png?alt=media\&token=c6e4a7ea-b583-4170-9b09-35a7be72cfb8)

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```


# Azure

Pritunl Link client on Azure

**For a more detailed tutorial refer to** [**Site-to-Site with IPsec**](https://docs.pritunl.com/kb/vpn/tutorials/pritunl-link)

Create a *Virtual Machine* and set the *Image* to *AlmaLinux 10*. Configure the instance authentication and set *Public inbound ports* to *None*. Then click *Next Disks* use the default disk settings and click *Next: Networking*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FB0jTndO5w1OrABYW6qdz%2Fazure_link0.png?alt=media\&token=10f4ebf5-194e-4895-b825-8299c33149f7)

Select the *Virtual network* that will be peered and select a subnet. A link is only needed on one subnet. The routing table of all subnets in the virtual network will be configured. Set *Network security group* to *Advanced* and click *Create new* under *Configure network security group*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fj2v7ELC2eXWw8ZUTfKWd%2Fazure_link1.png?alt=media\&token=4d4b0e4e-1015-4a03-b4fb-5669f91943ac)

Set the *Name* of the security group to `prutunl-link` and click *Add an inbound rule*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FrF8pZLVCX6CZVXCsi0rN%2Fazure_link2.png?alt=media\&token=f7670159-18d6-49b1-ad42-513ca95a5731)

Set the *Source* to *Any*, *Source port ranges* to `*`, *Destination* to *Any* and *Port* to `500`. Then select *UDP* and set *Priority* to `100`. Set the *Name* to `Port_500`. Then click *Add*.

**Optionally TCP port 9790 can also be opened for host to host checking. This allows each pritunl-link host to ping other hosts to measure latency and availability. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FWJX5YSztGjH8zVenlZnT%2Fazure_link3.png?alt=media\&token=f1adddec-c5ca-489e-a3f5-4cc207bc8ae3)

Click *Add an inbound rule* again. Set the *Source* to *Any*, *Source port ranges* to `*`, *Destination* to *Any* and *Port* to `4500`. Then select *UDP* and set *Priority* to `101`. Set the *Name* to `Port_4500`.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FvieuN4sJjaDjmMf7sfp3%2Fazure_link4.png?alt=media\&token=c8cc515b-e2ef-4756-baa8-cbbcfedc1618)

Click *Next: Management* and set *System assigned managed identity* to *On*. Then create the virtual machine.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FnPGcWcOvsG5sarYLnNwy%2Fazure_link5.png?alt=media\&token=1d3c8d66-7b23-4b5a-8b02-d5b55ff60f14)

Open the *Virtual Machine* settings and select *Networking*. Then click on the *Network Interface*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FnBWRgwFEdJEkLijHqvnq%2Fazure_link9.png?alt=media\&token=a2194ee9-d55d-43c2-8260-1c9bf4f40f99)

Open *IP configurations* and set *IP forwarding* to *Enabled*. Then click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FlRpYGnhJrvrMYPPkeO6i%2Fazure_link10.png?alt=media\&token=24a0e84b-7033-4f64-bcee-8deb1e20b7af)

Open the *Resource Groups* dashboard and select the resource group that contains the Pritunl Link instance. Then open *Access control (IAM)*. Optionally these access controls can be added to the virtual network and Pritunl Link instance instead of the resource group for a more restricted configuration.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FHozGxwHjgLb0Tt7zj7vF%2Fazure_link6.png?alt=media\&token=c1f15b0a-a6da-4684-8581-2d349661facc)

Click *Add* and set the *Role* to *Owner*, *Assign access to* to *Virtual Machine* and search for the Pritunl Link instance and add it. Then click *Save*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FL748zLPb8zx5R38Vo3lU%2Fazure_link7.png?alt=media\&token=baf7aee3-2d10-4210-a82c-c1d05c5f2a4a)

Click *Add* again and set the *Role* to *Reader*, *Assign access to* to *Virtual Machine* and search for the Pritunl Link instance and add it. Then click *Save*.

Connect to the server with SSH and run the script below. The first pritunl-link command needs to be run if the Pritunl server does not have a signed HTTPS certificate. The second command sets the provider to `azure`. The third command will add the URI, this needs to be replaced by clicking *Get URI* in the Pritunl web console. This command can be run multiple times if more then one link is configured. The `pritunl-link verify-off` line can be left out if the Pritunl server is configured with a valid SSL certificate. It is not necessary to verify the SSL certificate, the sensitive data is encrypted with AES-256 and signed with HMAC SHA-512 using the token and secret in the URI.#!/bin/bash

```shell
#!/bin/bash
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update
sudo dnf -y install pritunl-link

sudo pritunl-link verify-off
sudo pritunl-link provider azure
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
```

The security group or security rules of other instances will need to be modified to allow traffic from the peered networks. The outbound security rules may also need to be modified to allow traffic to the peered networks.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FAZEdhVTITR7TLF3ivALN%2Fazure_link11.png?alt=media\&token=69b12b6c-2687-4349-a18c-7e67bb349d8c)

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```


# Google Cloud

Pritunl Link client on Google Cloud

**Google Cloud networking limitations will prevent non-local traffic from routing between two instances. This will prevent running more then one active Pritunl Link client on different instances or running a non-NAT Pritunl VPN server that routes to a Pritunl Link client. Failover configurations will only run one active link client at a time and are not effected by the limitation. Multiple links can still be used as long as the links are all run on the same instance. For multi-link failover configurations use host priority to ensure different links will run on the same instance.**

### Configure Pritunl Link

**For a more detailed tutorial refer to** [**Site-to-Site with IPsec**](https://docs.pritunl.com/kb/vpn/tutorials/pritunl-link)

First create the firewall rules to tag on the instance. Open `UDP` ports `500` and `4500` for IPsec traffic.

**Optionally TCP port 9790 can also be opened for host to host checking. This allows each pritunl-link host to ping other hosts to measure latency and availability. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fr5SaaF9AURMHrZWUxwb5%2Flink6.png?alt=media\&token=1839434f-1272-484b-8e07-03536b474776)

Create a Rocky Linux 10 server in the virtual network that will be linked. Select *Allow full access to all Cloud APIs* and enable *IP forwarding*. This is done to allow modify the routing table and allow traffic to be forwarded from other networks. Use the startup script below.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FqaE0OARGYDGLv5IZIPG4%2Flinks16.png?alt=media\&token=db6ff44c-3af6-4fe8-b065-54773016a139)

Below is the startup script that can be put it in the *Startup script* or run manually. The first pritunl-link command needs to be run if the Pritunl server does not have a signed HTTPS certificate. The second command sets the provider to `google`. The third command will add the URI, this needs to be replaced by clicking *Get URI* in the Pritunl web console. This command can be run multiple times if more then one link is configured. The `pritunl-link verify-off` line can be left out if the Pritunl server is configured with a valid SSL certificate. It is not necessary to verify the SSL certificate, the sensitive data is encrypted with AES-256 and signed with HMAC SHA-512 using the token and secret in the URI.

```shell
#!/bin/bash
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Stable Repository
baseurl=https://repo.pritunl.com/stable/yum/almalinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update
sudo dnf -y install pritunl-link

sudo pritunl-link verify-off
sudo pritunl-link provider google
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
```

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```


# Oracle Cloud

Pritunl Link client on Oracle Cloud

**For a more detailed tutorial refer to** [**Site-to-Site with IPsec**](https://docs.pritunl.com/kb/vpn/tutorials/pritunl-link)

First create security list rules to allow `UDP` ports `500` and `4500` for IPsec traffic. You will also need to allow traffic from the other linked networks.

**Optionally TCP port 9790 can also be opened for host to host checking. This allows each pritunl-link host to ping other hosts to measure latency and availability. These checks are used to detect network partitions and discover the best link to activate in a high availability configuration.**

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FO9zphFSXapx6GE2gGehG%2Foraclecloud0.png?alt=media\&token=94fa4986-a317-4b49-9d7e-9a345c5dc5a4)

Create a private key for the API user using the command below. These commands can be run on any Linux computer.

```shell
openssl genrsa -out oci_key.pem 2048
openssl rsa -pubout -in oci_key.pem -out oci_pub.pem
cat oci_pub.pem
```

Open the *Users* section of the *Identity* console and select a user that will be used to authenticate with the Oracle Cloud API. Then copy the *OCID* in the user info, this will be needed later.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FQEtWcnwVQTP5CEamQnG5%2Foraclecloud4.png?alt=media\&token=d725492c-6c9e-47c0-9d1f-a360a938855e)

Open the user details click *Add Public Key*. Then copy the output of `cat oci_pub.pem` to the *Public Key* field.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FEsEAsB7nfcVFUiPkMyZM%2Foraclecloud2.png?alt=media\&token=10c1a379-433d-418d-b832-68154da56fc4)

Get a base64 copy of the private key by running the command below. This will be needed in the next step. Once done run the second command to delete the key.

```shell
openssl base64 -in oci_key.pem | tr -d "\n"
rm oci_*.pem
```

Access with this user should be controlled with a policy. This can be done by creating a user group and adding the user to that group then configuring a policy for the group. Below is an example policy for the user. This can be further restricted based on the environment.

```
ALLOW GROUP pritunl TO MANAGE virtual-network-family IN tenancy
ALLOW GROUP pritunl TO MANAGE vnics IN tenancy
```

Below is the startup script that can be put it in the *User data* or run manually. The first three pritunl-link commands need to be updated with the Oracle Cloud tenancy ocid, Oracle user ocid and the Base64 private key from above. The fourth pritunl-link command needs to be run if the Pritunl server does not have a signed HTTPS certificate. The fifth command sets the provider to `oracle`. The sixth command will add the URI, this needs to be replaced by clicking *Get URI* in the Pritunl web console. This command can be run multiple times if more then one link is configured. The `pritunl-link verify-off` line can be left out if the Pritunl server is configured with a valid SSL certificate. It is not necessary to verify the SSL certificate, the sensitive data is encrypted with AES-256 and signed with HMAC SHA-512 using the token and secret in the URI.

```shell
#!/bin/bash
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/10/
gpgcheck=1
enabled=1
gpgkey=https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc
EOF

sudo dnf -y update
sudo dnf -y install pritunl-link

sudo systemctl stop firewalld
sudo systemctl disable firewalld

sudo pritunl-link oracle-tenancy-ocid ocid1.tenancy.oc1..aaaaaaaa6emuu...
sudo pritunl-link oracle-user-ocid ocid1.user.oc1..aaaaaaaagfbc5x7qsrq...
sudo pritunl-link oracle-private-key LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBL...
sudo pritunl-link verify-off
sudo pritunl-link provider oracle
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
```

Create an Oracle Linux 10 instance and open the *Advanced Options* and click *Paste cloud-init script*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FfxbT4teGjYDbxTu6PapW%2Foraclecloud3.png?alt=media\&token=e561cac7-0bad-4281-84c1-15f876f19efe)

Select the VNIC attached to the instance and click *Edit VNIC*. Then select *Skip Source/Destination Check*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FuJIqs0y00crKNFMGM2yt%2Foraclecloud5.png?alt=media\&token=ef5b9db8-1c8b-4bbe-b19e-e3f04b4d2987)

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```


# Ubiquiti Unifi UDM

Pritunl Link client on Ubiquiti Unifi UDM

The Pritunl link client will automatically manage the routing table and port forwarding on the Unifi UDM. This allows for a high availability configuration to handle a failure on the link client. For dual WAN configurations a link client can be configured to port forward each WAN and the link will remain available with one WAN offline.

### Unifi Configuration

From the portal click *Manage Users* then click *Add User*. Set the *Name* to `Pritunl API` and set the *Role* to `Limited Admin`. Set the username to `pritunl` and generate a random password. Then select *Administrator* under the *UniFi Network* permissions. Set all the other permissions to *None* then click *Add*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FQjDzYXD7tMMPDZuVshoa%2Fudm0.png?alt=media\&token=54b528f0-9387-4115-93ae-52c004daf7d6)

Run the commands below on the instance to install the `pritunl-link` package. The firewalld service must also be disabled.

```shell
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/10/
gpgcheck=1
enabled=1
EOF

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A > key.tmp; sudo rpm --import key.tmp; rm -f key.tmp
sudo yum -y upgrade
sudo yum -y install pritunl-link

sudo systemctl stop firewalld
sudo systemctl disable firewalld
```

Next run the first command if your Pritunl server does not have a signed HTTPS certificate. The data will be signed and encrypted with AES independently an unsigned certificate will not effect security. Then run the second command to manually set the provider to `unifi`. The next three commands are used to set the Unifi username, password and controller URL. The third command will clear all host URI's, this should be run to ensure previously configured URIs are removed. The fourth command will add the URI, this needs to be replaced by clicking *Get URI* in the Pritunl web console. This command can be run multiple times if more then one link is configured. The `sudo pritunl-link verify-off` line can be left out if the Pritunl server is configured with a valid SSL certificate. It is not necessary to verify the SSL certificate, the sensitive data is encrypted with AES-256 and signed with HMAC SHA-512 using the token and secret in the URI.

```shell
sudo pritunl-link provider unifi
sudo pritunl-link unifi-username pritunl
sudo pritunl-link unifi-password pritunl
sudo pritunl-link unifi-controller https://10.10.0.1

sudo pritunl-link verify-off
sudo pritunl-link clear
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
```

For dual WAN configurations the forwarding interface can be set using the command below. For the first link client use `WAN` and `WAN2` for the second link client. If only one link client is used on a dual WAN configuration the interface must be set to `BOTH`. For single WAN configurations this command is not needed.

```shell
sudo pritunl-link unifi-interface WAN
```

If you are using multiple sites you will need to set the site ID using the command below. The site ID can be found in the dashboard url such as `default` in `https://10.0.0.1/network/default/dashboard`. If the site ID is `default` this command is not needed.

```shell
sudo pritunl-link unifi-site default
```

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```


# IPsec Router

Connect IPsec router to Pritunl Link

**Extensive testing with different routers and cloud provider IPsec offerings has shown that these IPsec clients will significantly underperform an instance or server running IPsec. Running IPsec on a router should only be done when it is not possible to configure a pritunl-link client with port forwarding. Additionally many failover features will be unsupported when not using pritunl-link clients for IPsec.**

Pritunl Link supports static hosts for connecting IPsec routers. This allows creating site-to-cloud configurations with any router that supports IPsec. Refer to [**Ubiquiti EdgeRouter Static**](https://docs.pritunl.com/kb/vpn/link/ubiquiti-edgerouter-static) or [**VyOS Static**](https://docs.pritunl.com/kb/vpn/link/vyos) for guides specific to those routers. This guide will provide general information for other routers.

Static hosts are not able to automatically pull changes to the link configuration from the Pritunl server. Because of this the link configuration must be fully completed and all non-static hosts must be deployed first. The non-static hosts will push the public address of the host to the Pritunl server, this must be done before configuring the static host. If it's necessary to deploy a static host before non-static hosts the public address must be manually configured on the non-static hosts.

To configure a static host first create a location for the routers network and click *Add Host* in the location. Then click *Advanced* at the top right and enable *Static Host*. Set the *Public Address* to the public IP address of the EdgeRouter. If an IPv6 link is being configured also set the *IPv6 Address*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FUMyPP3FurlYila9MuigO%2Fedgerouter2.png?alt=media\&token=8a8783b8-542e-4e03-9fcf-bee191e71820)

Once done a *Get Conf* button will be displayed on the right side of the host. Click this to get the IPsec configuration in a strongSwan `ipsec.conf` format. It may be easier to refer to the EdgeRouter format by clicking *Get EdgeRouter Conf*. Below is a list of encryption proposals supported by pritunl-link, use the first one that is available on the router.

`aes128-sha256-modp2048s256` - AES-128, SHA-256, DH Group 24`aes128-sha256-ecp256` - AES-128, SHA-256, DH Group 19`aes128-sha256-modp3072` - AES-128, SHA-256, DH Group 15`aes128-sha256-modp2048` - AES-128, SHA-256, DH Group 14`aes128-sha256-modp1536` - AES-128, SHA-256, DH Group 5`aes128-sha1-modp2048s256` - AES-128, SHA1, DH Group 24`aes128-sha1-ecp256` - AES-128, SHA1, DH Group 19`aes128-sha1-modp3072` - AES-128, SHA1, DH Group 15`aes128-sha1-modp2048` - AES-128, SHA1, DH Group 14`aes128-sha1-modp1536` - AES-128, SHA1, DH Group 5

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FibzUqbpRzXnoWCGYcCXY%2Fedgerouter.png?alt=media\&token=af5ea094-6305-4216-8c51-516709983afc)

Once configured the other link locations should connect to the router.


# Direct Link

IPsec direct link

A direct link allows forwarding all inbound and outbound traffic from a server behind a NAT to a cloud server. This is useful when a high performance physical server needs to be accessed from the internet or a VPC network. Direct links can also be used to lower cloud costs by running high performance servers from available local physical hardware and linking to low cost cloud servers. Failover hosts can be added on both sides to allow high availability. Once the link is established the local server will essentially take the place of the cloud server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FSpKk5R6gDtVMQXY9v4a8%2Fdirect_diagram.png?alt=media\&token=5e41361e-89fa-42c5-9eea-d80190898c77)

### Configure Pritunl

To create a direct link open the *Links* tab and click *Add Link*. Set the *Type* to *Direct*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FkV1knw4jhUYDHLojU6PG%2Fdirect0.png?alt=media\&token=67346837-0b16-4be5-837b-c097055e3d20)

Add a host to the *client* and *server*. The *client* host will represent the local server and the *server* host will represent the cloud server.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FKREpnQEu44jZxkn9Zupe%2Fdirect1.png?alt=media\&token=d6864383-8025-4520-b8ee-54f66e944458)

Once done refer to the [**Installation**](https://docs.pritunl.com/kb/vpn/link/installation) section for instructions on installing the Pritunl Link client. Then copy the URI's to each client and run the command below to add the URI. Once the direct link is active SSH access to the cloud server will no longer be available, the SSH traffic will be forwarded to the local server. To avoid this while testing run the `pritunl-link direct-ssh-on` command on the cloud server. The link can also be stopped from the Pritunl web console to gain access to the cloud server.

```shell
pritunl-link add pritunl://token:secret@test.pritunl.com
```


# Upgrading

Upgrading Pritunl IPsec links

When upgrading links it is recommended to deploy a new link host instead of upgrading an existing host. This will prevent unexpected downtime and allow quickly rolling back the upgrade if an issue occurs. To deploy an upgraded host first create a new host in the link location then set the priority of the host higher then the priority of the existing hosts. This will force the link to run on the new host when it becomes available. Then deploy the new host using the instructions in the IPsec Peering section. Once the new host is active the old host can be removed. If an issue occurs increase the priority of the old host to a higher priority then the new host to roll back the upgrade.


# VyOS Static

IPsec peering with VyOS

**Extensive testing with different routers and cloud provider IPsec offerings has shown that these IPsec clients will significantly underperform an instance or server running IPsec. Running IPsec on a router should only be done when it is not possible to configure a pritunl-link client with port forwarding. Additionally many failover features will be unsupported when not using pritunl-link clients for IPsec.**

Pritunl Link has support for the VyOS using IPsec links with a static host. A static host in Pritunl Link is a IPsec client that is not running the pritunl-link application. This allows connecting on-site routers that have support for IPsec. Using a static host will have some limitations such as not being able to automatically update changes to the link configuration.

### Configure VyOS

Static hosts are not able to automatically pull changes to the link configuration from the Pritunl server. Because of this the link configuration must be fully completed and all non-static hosts must be deployed first. The non-static hosts will push the public address of the host to the Pritunl server, this must be done before configuring the static host. If it's necessary to deploy a static host before non-static hosts the public address must be manually configured on the non-static hosts.

To configure a VyOS static host first create a location for the VyOS network then click *Add Host* in the location. Then click *Advanced* at the top right and enable *Static Host*. Set the *Public Address* to the public IP address of the VyOS. If an IPv6 link is being configured also set the *IPv6 Address*.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FUMyPP3FurlYila9MuigO%2Fedgerouter2.png?alt=media\&token=8a8783b8-542e-4e03-9fcf-bee191e71820)

Once done a *Get EdgeRouter Conf* button will be displayed on the right side of the host. Both EdgeRouter and VyOS are based on the same operating system, except for the first auto firewall command all the EdgeRouter commands will run on VyOS. Click the button to get the configuration. Connect to the VyOS router with SSH then run the command `configure` and paste these commands excluding the first one into the configuration mode. Then run `commit` and `save`. This will configure all the needed options and the router will then connect and route the traffic to the networks.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FibzUqbpRzXnoWCGYcCXY%2Fedgerouter.png?alt=media\&token=af5ea094-6305-4216-8c51-516709983afc)

The commands `show vpn ipsec status`, `show vpn ipsec state` and `sudo ipsec statusall` will show the status of the IPsec connection on VyOS.


# Pritunl Cloud Link

Pritunl Link client on Pritunl Cloud

**For a more detailed tutorial refer to** [**Site-to-Site with IPsec**](https://docs.pritunl.com/kb/vpn/tutorials/pritunl-link)

Pritunl Cloud has built in support for Pritunl Link by adding the link host URI to the VPC settings in Pritunl Cloud. It will be more reliable and secure to isolate the Pritunl Link client in an instance as documented below.

First create a firewall policy for the Pritunl Cloud instance to allow traffic from `UDP` port `500` and `4500`. Traffic from the Pritunl Cloud VPC going through the IPsec tunnel will also need to be allowed, this can be done by allowing all traffic from the Pritunl Cloud VPC subnet or specifying the required ports.

If the Pritunl Cloud instances are behind a NAT port forwarding will need to be used to forward the IPsec ports to the Pritunl Link instance.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2Fs2UBxaQMtEaZaEkZZe9J%2Fpritunl_cloud_link0.png?alt=media\&token=55fc1251-3a96-4ca0-8594-87ae134eedb0)

Create a new user and set the *Type* to *API*. Then generate a token and secret, this will be used by Pritunl Link to automatically update the VPC routing table. Currently only administrator users can be used with Pritunl Link.

![](https://1783284711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhDA4eusSNQcv5QfappvI%2Fuploads%2FxSxqzeHXqTmBu8A16seE%2Fpritunl_cloud_link1.png?alt=media\&token=83498db0-d5cb-42be-9206-a0d0a8fa535c)

Next create a new Oracle Linux instance in Pritunl Cloud and add the role for the IPsec firewall policy created above. Then install Pritunl Link and run the commands below to configure the link. The `pritunl-hostname` should be set to admin domain of the Pritunl Cloud URL.

```shell
#!/bin/bash
sudo tee /etc/yum.repos.d/pritunl.repo << EOF
[pritunl]
name=Pritunl Repository
baseurl=https://repo.pritunl.com/stable/yum/oraclelinux/8/
gpgcheck=1
enabled=1
EOF

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 7568D9BB55FF9E5287D586017AE645C0CF8E292A
gpg --armor --export 7568D9BB55FF9E5287D586017AE645C0CF8E292A > key.tmp; sudo rpm --import key.tmp; rm -f key.tmp
sudo yum -y update
sudo yum -y install pritunl-link

sudo pritunl-link pritunl-hostname cloud.pritunl.com
sudo pritunl-link pritunl-vpc 5c80565f9fe2e4bcca931f36
sudo pritunl-link pritunl-token daELQSOwll8w48H0nZDLzr9O0bYYNeK8fRrN2Ka4
sudo pritunl-link pritunl-secret cIY4qEz3B78qiL1b4iOz8kcNXfAJcaKNEyBEAoyi
sudo pritunl-link provider pritunl
sudo pritunl-link add pritunl://token:secret@test.pritunl.com
```

The commands below can be run to check the logs and status of the link. The `pritunl-link` service will already be running and connected once the URI is added.

```shell
journalctl -u pritunl-link
sudo ipsec status
```




---

[Next Page](https://docs.pritunl.com/kb/llms-full.txt/1)

