# OpenBalena OpenVPN Service

**URL:** <https://forums.balena.io/t/openbalena-openvpn-service/16785>\
**Category:** openBalena\
**Created:** [June 21, 2019, 8:52am UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785 "2019-06-21T08:52:42Z")\
**Posts on this page:** 11\
**Page:** 2

<div class="post-metadata">

**Author:** ![wrboyce](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/wrboyce/32/374_2.png) [@wrboyce](https://forums.balena.io/u/wrboyce)\
**Post date:** [June 25, 2019, 11:20am UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/29 "2019-06-25T11:20:05Z")

</div>

@dganesh81 as of v8.15.0 of open-balena-vpn you can use `VPN_BASE_SUBNET` and `VPN_INSTANCE_SUBNET_BITMASK` to dictate the IP addresses handed out to VPN clients. I’ve also switched the default subnet over to the CGN address space (100.64.0.0/10) so the defaults should work in the majority of cases now.

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [June 25, 2019, 6:14pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/30 "2019-06-25T18:14:48Z")

</div>

wow. Thats awesome. If you dont mind, could you please let me know the procedure to change `VPN_BASE_SUBNET` and `VPN_INSTANCE_SUBNET_BITMASK`? Do i need to upgrade open Balena ?

Thank you for your wonderful support.

---

<div class="post-metadata">

**Author:** ![chrisys](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/chrisys/32/1731_2.png) [@chrisys](https://forums.balena.io/u/chrisys)\
**Post date:** [June 25, 2019, 6:22pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/31 "2019-06-25T18:22:18Z")

</div>

@dganesh81 `VPN_BASE_SUBNET` and `VPN_INSTANCE_SUBNET_BITMASK` would need to be set as environment variables. The version of [`open-balena-vpn`](https://github.com/balena-io/open-balena-vpn) that @wrboyce mentioned (v8.15.0) was only released a few hours ago so you’ll need to update to get that version.

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [June 26, 2019, 7:07am UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/33 "2019-06-26T07:07:52Z")

</div>

Hello [chrisys], Do i need to update complete open Balena or just VPN container? Somewhere i can find the procedure? please let me know.

---

<div class="post-metadata">

**Author:** ![wrboyce](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/wrboyce/32/374_2.png) [@wrboyce](https://forums.balena.io/u/wrboyce)\
**Post date:** [June 26, 2019, 11:06am UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/36 "2019-06-26T11:06:19Z")

</div>

Hi @dganesh81, if you do `./scripts/compose pull vpn && ./scripts/compose up -d vpn` that should update and restart your vpn container inside openbalena.

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [June 26, 2019, 12:58pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/38 "2019-06-26T12:58:13Z")

</div>

@wrboyce,

It looks like it is still running on old version. Tried to stop and start again too.

root@balena:/home/balena/open-balena# ./scripts/compose pull vpn  
Pulling vpn … done  
root@balena:/home/balena/open-balena# ./scripts/compose up -d vpn  
openbalena\_s3\_1 is up-to-date  
openbalena\_db\_1 is up-to-date  
openbalena\_redis\_1 is up-to-date  
openbalena\_api\_1 is up-to-date  
openbalena\_vpn\_1 is up-to-date  
root@balena:/home/balena/open-balena# sudo docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
bf731bdfa0a6 openbalena\_haproxy “/docker-entrypoint.…” 12 days ago Up 54 seconds 0.0.0.0:80-\>80/tcp, 0.0.0.0:443-\>443/tcp, 222/tcp, 5432/tcp, 0.0.0.0:3128-\>3128/tcp, 6379/tcp openbalena\_haproxy\_1  
d6a1519002c3 balena/open-balena-vpn:v8.10.0 “/usr/bin/entry.sh” 12 days ago Up About a minute 80/tcp, 443/tcp, 3128/tcp openbalena\_vpn\_1  
2c242b91dbd7 balena/open-balena-registry:v2.7.0 “/usr/bin/entry.sh” 12 days ago Up 56 seconds 80/tcp openbalena\_registry\_1  
f5a2b9eab2f1 balena/open-balena-api:v0.19.5 “/usr/bin/entry.sh” 12 days ago Up About a minute 80/tcp openbalena\_api\_1  
771414aa1ea1 balena/open-balena-db:v2.0.3 “docker-entrypoint.s…” 12 days ago Up About a minute 5432/tcp openbalena\_db\_1  
1a309d8931ea redis:alpine “docker-entrypoint.s…” 12 days ago Up About a minute 6379/tcp openbalena\_redis\_1  
e02de65409cf balena/open-balena-s3:v2.6.2 “/usr/bin/entry.sh” 12 days ago Up 2 minutes 80/tcp openbalena\_s3\_1  
2a2ccea443a3 openbalena\_cert-provider “/entry.sh /usr/src/…” 12 days ago Up 55 seconds 80/tcp openbalena\_cert-provider\_1  
root@balena:/home/balena/open-balena#

---

<div class="post-metadata">

**Author:** ![richbayliss](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/richbayliss/32/1054_2.png) [@richbayliss](https://forums.balena.io/u/richbayliss)\
**Post date:** [June 26, 2019, 2:06pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/41 "2019-06-26T14:06:08Z")

</div>

@dganesh81 hey - you need to edit the `./compose/versions` file, [here in the repo](https://github.com/balena-io/open-balena/blob/master/compose/versions) to set the version you would like to run, then do the `pull` and `up` commands 👍

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [June 26, 2019, 2:17pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/43 "2019-06-26T14:17:57Z")

</div>

> [@richbayliss](#):
>
> `./compose/versions`

It is working now. perfect. Thanks a lot. I shall try the environment variable and post the output here.

root@balena:/home/balena/open-balena# sudo docker ps  
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES  
c1a573c20fee balena/open-balena-vpn:v8.15.1 “/usr/bin/entry.sh” 5 seconds ago Up 3 seconds 80/tcp, 443/tcp, 3128/tcp

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [July 2, 2019, 2:02pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/45 "2019-07-02T14:02:50Z")

</div>

> [@wrboyce](#):
>
> VPN\_INSTANCE\_SUBNET\_BITMASK

Hi All, have tried to set following in VPN container. But no success. Any idea?

root@c1a573c20fee:/usr/src/app# cat /etc/environment  
VPN\_BASE\_SUBNET=“172.17.15.0/24”  
VPN\_INSTANCE\_SUBNET\_BITMASK=“172.17.15.0/24”  
root@c1a573c20fee:/usr/src/app#

After setting the above, tried to stop/start the balena service as well.

---

<div class="post-metadata">

**Author:** ![wrboyce](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/wrboyce/32/374_2.png) [@wrboyce](https://forums.balena.io/u/wrboyce)\
**Post date:** [July 2, 2019, 3:27pm UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/48 "2019-07-02T15:27:09Z")

</div>

The best way to configure this would be passing the environment via your `config/docker-compose.yml`, such as:

```auto
# Project-specific config.
#
# All paths must be defined relative to `compose/services.yml` regardless of
# the location of this file, i.e. refer to `my-open-balena-checkout/somedir`
# as `../somedir`. This is because of the way docker-compose handles paths
# when specifying multiple configs and open-balena always specifying
# `compose/services.yml` as the "base" config.
#
# You may view the effective config with `scripts/compose config`.

version: '2.1'

services:
  vpn:
    environment:
      VPN_BASE_SUBNET: 172.17.15.0/24
      VPN_INSTANCE_SUBNET_BITMASK: 24

```

Note that `VPN_INSTANCE_SUBNET_BITMASK` should just be the bitmask, as it indicates the size subnet each vpn instance will take from the base subnet.

---

<div class="post-metadata">

**Author:** ![dganesh81](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@dganesh81](https://forums.balena.io/u/dganesh81)\
**Post date:** [July 3, 2019, 11:23am UTC](https://forums.balena.io/t/openbalena-openvpn-service/16785/50 "2019-07-03T11:23:18Z")

</div>

Perfect. I have modified as you suggested and it is working. I am also able to ssh using VPN client IP address. Thank you.

[Previous page](https://forums.balena.io/t/openbalena-openvpn-service/16785.md?page=1)
