# Feature Request: option to tunnel ALL traffic through a private VPN

**URL:** <https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221>\
**Category:** Product support\
**Created:** [June 13, 2017, 12:49pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221 "2017-06-13T12:49:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![che](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@che](https://forums.balena.io/u/che)\
**Post date:** [June 13, 2017, 12:49pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/1 "2017-06-13T12:49:51Z")

</div>

We want to use Resin to manage our devices in a very restricted environment. Even the [Network Requirements](https://docs.resin.io/deployment/network/2.0.0/#network-requirements) from the docs are not specific enough for our use case. Ideally we only have to request outbound access to one port on IP for **all** traffic (including [Resin.IO](http://Resin.IO)).

So ideally it should be possible to setup a VPN connection on host OS and route all traffic (resin + container) through that tunnel.

Could not find whether this is currently possible. If so, where can I find the documentation? If not, this would be somewhat blocking for us to really start using [Resin.IO](http://Resin.IO) in production.

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 13, 2017, 10:19pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/2 "2017-06-13T22:19:49Z")

</div>

@che - interesting request. This wouldn’t be possible with how the VPN is currently set up. However, we’re adding support for transparent use of HTTP and SOCKS proxies: [https://github.com/resin-os/meta-resin/pull/618](https://github.com/resin-os/meta-resin/pull/618)  
With this, you should be able to set up a SOCKS5 proxy somewhere (which is quite simple: [https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel](https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel) ) and configure your devices to route all traffic through that. Would that work?

---

<div class="post-metadata">

**Author:** ![che](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@che](https://forums.balena.io/u/che)\
**Post date:** [June 14, 2017, 2:09pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/3 "2017-06-14T14:09:07Z")

</div>

@pcarranzav, thanks for the quick reply. This might work indeed.  
What would be the easiest way to try if it would work right now?

---

<div class="post-metadata">

**Author:** ![pcarranzav](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/pcarranzav/32/94_2.png) [@pcarranzav](https://forums.balena.io/u/pcarranzav)\
**Post date:** [June 14, 2017, 9:42pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/4 "2017-06-14T21:42:43Z")

</div>

@che the only way I can think of is you building your own ResinOS from that meta-resin branch. If you wait a few days, though, I think this should make it into master and our staging server soon (though I can’t promise an exact date).

---

<div class="post-metadata">

**Author:** ![che](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@che](https://forums.balena.io/u/che)\
**Post date:** [July 26, 2017, 2:32pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/5 "2017-07-26T14:32:44Z")

</div>

Any updates on this? We currently use another device to do the tunneling within a VLAN. It would be much easier if we could do everything directly through resin 🙂

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [July 26, 2017, 2:53pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/6 "2017-07-26T14:53:19Z")

</div>

Currently proxy support to run traffic through a proxy you provide is in testing phase, just not quite ready to be released just yet. Will keep you posted! 🚧

---

<div class="post-metadata">

**Author:** ![che](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@che](https://forums.balena.io/u/che)\
**Post date:** [July 26, 2017, 3:04pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/7 "2017-07-26T15:04:23Z")

</div>

Hi @imrehg, thanks for the quick response.

Out of curiosity I checked the above mentioned pull request in `meta-resin` (618) and it looks like it is already available in the current ResinOS image (Resin OS 2.0.8+rev1 (prod)). Is that correct?

At first sight everything seems to be working, so we will already test everything thoroughly 😉  
Anything I should keep in mind when testing?

Keep up the good work guys!

---

<div class="post-metadata">

**Author:** ![imrehg](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/imrehg/32/36_2.png) [@imrehg](https://forums.balena.io/u/imrehg)\
**Post date:** [July 26, 2017, 9:01pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/8 "2017-07-26T21:01:36Z")

</div>

Ah, yes, here’s the Github pull request that added this change (and seems like starting in resinOS 2.0.7 already):

> <https://github.com/balena-os/meta-balena/pull/618>
>
> This PR adds a recipe for \[redsocks\](http://darkk.net.ru/redsocks/), which allow…s transparent redirection to SOCKS and HTTP proxies.
> 
> It introduces a \`resin-proxy-config\` service, which looks for redsocks.conf inside a system-proxy folder in the boot partition. The service creates the corresponding iptables rules and starts redsocks, only if the configuration file is found (otherwise it just exists).
> 
> Users wanting a device to connect behind a proxy would have to add a \`redsocks.conf\` file at the \`/mnt/boot/system-proxy/\`, specifying whatever proxy configuration they need but ensuring that:
> \* \`daemon = off\` is set, so that redsocks doesn't fork (because the service type is \`simple\`)
> \* \`local\_port = 12345\` is set, so that the iptables rules and redsocks' port match.
> 
> (I left the port shown in redsocks examples, but we can change it if we want to use a different one).
> 
> Additionally, \`resin-proxy-config\` can read a \`/mnt/boot/system-proxy/no\_proxy\` file with a newline-separated list of IPs or subnets to not route through the proxy.
> 
> This has been tested with http-connect and socks5 proxies and works as expected.

There are some details in the description regarding what to keep in mind and how to set things:

> It introduces a resin-proxy-config service, which looks for `redsocks.conf` inside a system-proxy folder in the SD card’s `resin-boot` partition. The service creates the corresponding iptables rules and starts redsocks, only if the configuration file is found (otherwise it just exists).
> 
> Users wanting a device to connect behind a proxy would have to add a redsocks.conf file at the /resin-boot/system-proxy/`, specifying whatever proxy configuration they need but ensuring that:
> 
> - daemon = off is set, so that redsocks doesn’t fork (because the service type is simple)
> - local\_port = 12345 is set, so that the iptables rules and redsocks’ port match.
> 
> Additionally, resin-proxy-config can read a `/mnt/boot/system-proxy/no_proxy` file with a newline-separated list of IPs or subnets to not route through the proxy.

Besides this, we’d just love to hear if you have any feedback through your testing 🙂

---

<div class="post-metadata">

**Author:** ![Jipsu](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jipsu](https://forums.balena.io/u/Jipsu)\
**Post date:** [December 8, 2017, 2:16pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/9 "2017-12-08T14:16:39Z")

</div>

Hi,

I’d be very interested in hearing if this works and whether it’s possible to get more detailed “how-to” about it?

As for being really newbie with Resin it seems unclear how to proceed with the installation and such.

---

<div class="post-metadata">

**Author:** ![Segaco](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Segaco](https://forums.balena.io/u/Segaco)\
**Post date:** [February 19, 2018, 1:36pm UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/10 "2018-02-19T13:36:34Z")

</div>

Be sure to always run an [IP leak test](https://www.vpnmentor.com/tools/ip-leak-test-vpns-tor/) so your VPN actually encrypts your data.

---

<div class="post-metadata">

**Author:** ![lekkas](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/lekkas/32/78_2.png) [@lekkas](https://forums.balena.io/u/lekkas)\
**Post date:** [February 20, 2018, 9:50am UTC](https://forums.balena.io/t/feature-request-option-to-tunnel-all-traffic-through-a-private-vpn/1221/11 "2018-02-20T09:50:47Z")

</div>

Hi @Jipsu ,

Yes, this approach works since [resinOS 2.7.7](https://github.com/resin-os/meta-resin/blob/master/CHANGELOG.md#v277) and you can find more details on how to set it up in the related docs section: [https://docs.resin.io/deployment/network/2.x/#connecting-behind-a-proxy](https://docs.resin.io/deployment/network/2.x/#connecting-behind-a-proxy)
