# Setting up custom VPS

{% hint style="info" %}
**This setup is primarily designed for Raspberry Pi, but it also supports any Debian-based Linux distribution.**
{% endhint %}

* For the best performance and lowest latency, we recommend renting a VPS from a hosting provider located in your country.
* When setting up the VPS, make sure to select **Debian** or **Ubuntu** as the operating system and confirm that the server offers enough bandwidth.
* After your hosting provider gives you the server’s **IP address** and **login credentials**, you can connect to it using **SSH**. Once logged in, update the system packages and then proceed with the setup.

## Install PiVPN

Official sources: <https://www.pivpn.io/> and <https://github.com/pivpn/pivpn>

{% stepper %}
{% step %}
**Run command in terminal:**

```
curl -L https://install.pivpn.io | bash
```

{% endstep %}

{% step %}
**Press Enter to confirm until next step.**

<figure><img src="/files/Hw5dh4dtMz7mEtHUTaJv" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select `yes` .**

<figure><img src="/files/EU8Km7CiozQCe3WgmkMq" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select your user.**

<figure><img src="/files/3EIjfGmWUurJmKraNifb" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select `WireGuard`.**

<figure><img src="/files/gZzL6C2uMRGHoEiGbDkV" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Confirm default port 51820**

<figure><img src="/files/AzoR0x5qLuGEJkhVO9m4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select DNS provider.**

* We recommend **CloudFlare** or **Google**. Use arrows and press **space** to confirm selection.

<figure><img src="/files/HuBUQcpHLMAQpWE7HCce" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Choose static IP or DNS**

* If your server uses a static IP address, select the IP option.
* If you’re using a hostname or have configured Dynamic DNS, choose the DNS option and enter the hostname.

<figure><img src="/files/vK46Q11Qi813jheMrAI5" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Enable security patches.**

<figure><img src="/files/khtK61FWK8fSK3npivgn" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select `No` to "Reboot now?"**

<figure><img src="/files/i8sxXjG6gYM1PJS6YoF3" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Update VPN's IP address range (optional)**

* We recommend updating your VPN’s IP address range by editing the file:

```
/etc/pivpn/wireguard/setupVars.conf
```

* Locate the line that starts with `pivpnNET` and replace the default randomly generated subnet with a custom range, for example: `10.10.10.0`
  {% endstep %}

{% step %}
**Run installation command again**

```
curl -L https://install.pivpn.io | bash
```

{% endstep %}

{% step %}
**Select `Repair` .**

<figure><img src="/files/FfOHehNAfMQ3hvOvDZOY" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Run PiVPN**

* Run PiVPN using command:

```
pivpn -d
```

* If the diagnostic detects an issue (such as the `missing iptables MASQUERADE rule`), type **`Y`** when prompted. This will automatically fix the problem that prevents VPN clients from accessing the internet.

<figure><img src="/files/iBU5D18SxRjsW4KTXxqx" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Reboot your system**
{% endstep %}
{% endstepper %}

## Creating Clients

* You will need a separate config for each client (Jetson, Ground stations, Android devices…)
* To create a new config use:

```
pivpn -a
```

* This will prompt you to choose a virtual ip address and name for this client. We recommend keeping a similar structure:
  * 10.10.10.2 – 10.10.10.9 **Ground stations**
  * 10.10.10.10 – 10.10.10.250 **Jetsons**

<figure><img src="/files/BGdT6qzx1F76LWTEofnJ" alt=""><figcaption></figcaption></figure>

* The generated client configurations are stored in `~/configs`.
* Copy the appropriate file to each Jetson device as: `/etc/wireguard/air.conf`
* Copy the corresponding file to your ground station as: `/etc/wireguard/ground.conf`

### For Android devices

* You can use the WireGuard app’s `Scan from QR code` feature.
* Run:

```
pivpn -qr
```

* Select a client, and a QR code will be displayed in your terminal, ready to scan.


---

# Agent Instructions: Querying This Documentation

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

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

```
GET https://docs.airvolute.com/uas-platforms/patron-fpv/patron-fpv-user-manual/lte-patron-fpv/getting-started/setting-up-custom-vps.md?ask=<question>
```

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

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