# Adding additional VPN locations

If you have used our one-line install setup (for example [described in this tutorial](https://docs.defguard.net/tutorials/step-by-step-setting-up-a-vpn-server)) one VPN location (one gateway instance) is done automatically.

There is often a need to launch additional locations (e.g. to separate groups of users or clients), to do this you need to add another location (and launch another gateway controlling this location).

Here is a step-by-step way to do so:

### Adding a new Location

In Defguard interface in VPN Location, please click: **Edit location settings** (button in the top right corner):

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-4be4b697e2ecc9c4b6b31a7d2d3573b1d4ec26ea%2FScreenshot%202024-08-15%20at%2021.40.38.png?alt=media" alt=""><figcaption></figcaption></figure>

Then ***Add new location*** and configure the new VPN location.

{% hint style="danger" %}
Without specified DNS field desktop client may be unable to use "All traffic" connection for the location.
{% endhint %}

{% hint style="warning" %}
Remeber that the:

* VPN IP address needs to be different then in the first location
* Gateway address should be the same (same public IP)
* Gateway port **must be different - and** remember that gateway port **must be open on firewall** (this is the new VPN location WireGuard port)
  {% endhint %}

After configuring the location, please:

* copy the gateway token
* and note that the gateway is disconnected

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-96c7a40bdb11f5987f93f2dbf24d7a086ff8142e%2FScreenshot%202024-08-15%20at%2021.28.25.png?alt=media" alt=""><figcaption></figcaption></figure>

### Adding new gateway in docker

Now go to the server and open the docker-compose.yml file, and scroll to the gateway section, it should look like this:

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-a0bef5e7996d862833a585cd5735a6c2fc0044ec%2Fdocker-gw1.png?alt=media" alt=""><figcaption></figcaption></figure>

Now copy the **whole gateway section and:**

* **name it in a uniqe way,** eg. *gateway-customer2*
* in the enviroment variable `DEFGUARD_TOKEN`: add the token you have copied from the new location
* **add the following line below the&#x20;*****image*****&#x20;-** to change the second gateway WireGuard interface:

```yaml
    command: ["-i", "wg1"]
```

{% hint style="danger" %}
**If you will not add the command line, both gateways will use by default the wg0 and both will not work.**
{% endhint %}

The configuration should like so:

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-9c0feee50dada8fcc5205e61599a108cf0209ea3%2FScreenshot%202024-09-02%20at%2021.17.14.png?alt=media" alt=""><figcaption></figcaption></figure>

Now you need to launch the new gateway, just by the following command:

```
docker compose up -d gateway-customer2
```

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-90983ea52516dc903cb438140d5b0f7936ffd9ae%2FScreenshot%202024-08-15%20at%2021.54.02.png?alt=media" alt=""><figcaption></figcaption></figure>

Now if you go back to the location settings you will see **instantly that the new gateway has connected for that location:**

<figure><img src="https://3466771104-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fe86iamwJVSYnIRsyVEAV%2Fuploads%2Fgit-blob-5c4314b3f986cf35fd48d87e2d8f3b53792109ea%2FScreenshot%202024-08-15%20at%2021.29.37.png?alt=media" alt=""><figcaption></figcaption></figure>

And that's it, you have a new VPN location ready.
