Giter Club home page Giter Club logo

openvpn-client-aio's Introduction

openvpn-client-aio

An "all-in-one" docker for all your private browsing needs. Built for both Unraid and Raspberry Pi 4 but should work in other Linux amd64 / arm32v7 / arm32v6 / i386 docker environments.

PULL THE RIGHT TAG!

  • I have finally managed to get multi-arch buildx working. LOL. Docker should automatically determine the right architecture to pull.
    • For verison with TOR (and Privoxy) -> pull testdasi/openvpn-client-aio:latest
    • For version without TOR (and Privoxy) -> pull testdasi/openvpn-client-aio:latest-torless

High-level instructions

  • Copy your OpenVPN configuration to the host path that is mapped to /etc/openvpn (must include openvpn.ovpn + credentials + certs).
  • Start docker

Key features

  1. OpenVPN client to connect to your favourite VPN provider. Full freedom with what you want to do with the ovpn file.
  2. 2 sets of kill switches. NFT kill switch to block connection when VPN is down. Piping kill switch HTTP proxy -> SOCKS5 proxy -> VPN tun0 / TOR tunnel.
  3. Stubby for DNS server to connec to DoT (dns-over-tls) services (ip:53 or 127.2.2.2:5253). Use Google and Cloudflare for best performance.
  4. Dante for SOCKS5 proxy to your VPN (ip:9118)
  5. Tinyproxy for HTTP proxy to your VPN (ip:8118)
  6. Torsocks for SOCKS5 proxy to TOR (ip:9119)
  7. Privoxy for HTTP proxy to TOR (ip:8119)

Bits and bobs

  • OpenVPN config files MUST be named openvpn.ovpn. The certs and credentials can be included in the config file or split into separate files. The flexibility is yours.
  • Explaining the parameters (the values you see in Usage section are default values)
    • DNS_SERVERS: set to 127.2.2.2 will point to stubby (which in turn points to Google / Cloudflare DoT services). Your DNS queries out of the VPN exit will also be encrypted before arriving at Google / Cloudflare for even more privacy. Change it to other comma-separated IPs (e.g. 1.1.1.1,8.8.8.8) will use normal unencrypted DNS, or perhaps a pihole in the local network.
    • HOST_NETWORK: to enable free flow between host network and the docker (e.g. when using docker bridge network). Otherwise, your proxies will only work from within the docker network. Must be in CIDR format e.g. 192.168.1.0/24
    • DNS_SERVER_PORT: the docker will serve as a DNS server for the local network so everything, including DNS, comes out of the VPN exit.
      • Work best if set to 53 as most things can't handle DNS on other ports. In which case, you have to give the docker its own static IP (i.e. use docker macvlan network) if the host also uses port 53 e.g. if you run a Pihole on the host IP. For Unraid, use Custom : br0 / br1 network (to enable this, go to Settings -> Docker).
      • You will need to set each device DNS to the docker IP.
      • Alternatively, you can set your router DHCP to set DNS to the docker IP.
    • SOCKS/HTTP_PROXY_PORT: use these proxies if you want to exit through your VPN. Point to your docker IP on the respective ports.
    • TOR_SOCKS/HTTP_PORT: use these proxies if you want to exit through TOR. Point to your docker IP on the respective ports.
    • The docker port mappings map host ports to docker ports. The docker ports are determined by the aforementioned PORT variables. So if you change the docker variables, you should also change the port mappings accordingly.
  • Choice of DoT (instead of DoH - dns-over-https) was intentional. When OpenVPN connects, it needs to resolve the VPN server domain so a port needs to open briefly. DoH would require opening HTTPS port (443), which shares with normal web-browsing so there's a potential point of leakage albeit only momentarily. DoT uses port 853 pretty much for itself. Of course, you can use IP instead of domain but that would restrict the use cases.
  • Based on Debian Buster base image mainly because Raspbian Buster is derived from the same. This allows easier development, testing and building on my end.
    • I originally developed this with iptables kill switch; however, iptables is sort of emulated from nftables in Debian Buster. Hence, I updated to using NFT kill switch instead. Iptables versions are kept in /iptables/* in case we need to revert back in the future.
    • Choices of stubby / dante / tinyproxy / torsocks / privoxy are out of convenience i.e. they are debian packages so no need to compile from source. A very-much-appreciated quality-of-life improvement.

Usage

docker run -d \
    --name=<container name> \
    --cap-add=NET_ADMIN \
    -v <path for openvpn config>:/etc/openvpn \
    -e DNS_SERVERS=127.2.2.2 \
    -e HOST_NETWORK=192.168.1.0/24 \
    -p 53:53/tcp \
    -p 53:53/udp \
    -p 9118:9118/tcp \
    -p 8118:8118/tcp \
    -p 9119:9119/tcp \
    -p 8119:8119/tcp \
    -e DNS_SERVER_PORT=53 \
    -e SOCKS_PROXY_PORT=9118 \
    -e HTTP_PROXY_PORT=8118 \
    -e TOR_SOCKS_PORT=9119 \
    -e TOR_HTTP_PORT=8119 \
    testdasi/openvpn-client-aio:<tag>

Unraid example

docker run -d \
    --name='OpenVPN-AIO-Client' \
    --cap-add=NET_ADMIN \
    -v '/mnt/user/appdata/openvpn-aio-client':'/etc/openvpn':'rw' \
    -e 'DNS_SERVERS'='127.2.2.2' \
    -e 'HOST_NETWORK'='192.168.1.0/24' \
    -p '8153:53/tcp' \
    -p '8153:53/udp' \
    -p '9118:9118/tcp' \
    -p '8118:8118/tcp' \
    -p '9119:9119/tcp' \
    -p '8119:8119/tcp' \
    -e 'DNS_SERVER_PORT'='53' \
    -e 'SOCKS_PROXY_PORT'='9118' \
    -e 'HTTP_PROXY_PORT'='8118' \
    -e 'TOR_SOCKS_PORT'='9119' \
    -e 'TOR_HTTP_PORT'='8119' \
    --net='bridge' \
    -e TZ="Europe/London" \
    -e HOST_OS="Unraid" \
    'testdasi/openvpn-client-aio:latest' 

Notes

  • I code for fun and my personal uses; hence, these niche functionalties that nobody asks for. ;)
  • Tested only with PIA since I can't afford anything else. Theoretically, it should work with any VPN services that support OpenVPN.
  • If you like my work, a donation to my burger fund is very much appreciated.

Donate.

openvpn-client-aio's People

Contributors

testdasi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

openvpn-client-aio's Issues

Add iputils-ping package to container

Hey!
I have been using you'r docker for a long time now, and i just love it!
The only thing i am missing, is the "iputils-ping" package, so i can combine it with Rebuild-DNDC docker.
Could you add this in an up-coming update?

Would be awesome!

Thanks.

TOR over VPN?

This was a bit unclear, but is TOR completely tunnelled through VPN (thus hiding TOR usage)?

More than one Host_network ?

Hello,
how I can set more than one HOST_NETWORK.
Example, like this..
HOST_NETWORK=192.168.0.0/16,10.10.0.0/24

Lan IP connections

Hi

I have multiple vlans on my network, if I set the HOST_NETWORK variable to 192.168.1.0/24 then only machines on that vlan can connect to the proxy, also if I set it to 192.168.5.0/24 then machines on that vlan can connect.

I know I could run two instances... that said is there a wild card entry? I've tried the obvious 192.168.*.0/24 and 192.168.0.0/24 but no dice. Even being able to disable incoming IP filtering would be ok?

Thanks!

Mark

airvpn.org providers

Hi, I'm trying to use the container on Unraid and I'm using the provider airvpn , just listing a piece of the configuration
"client
dev tun
remote 134.19.179.242 443"

When I look at the logs of docker, it's trying to connect on a port 2443 regardless of the port set in the openvpn.ovpn file.

[info] Setting up OpenVPN tunnel
[info] Create tunnel device
[info] Allow DnS-over-TLS for openvpn to lookup VPN server
[info] Connecting to VPN on port 2443 with proto udp...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...

Thanks for your promising container

Connection issue

Hello, see attached log. I used the configuration you provided with only 1 change: HOST_NETWORK - my router is on 192.168.0.1. My RPI4 is at 192.168.0.155 so I configured SwitchyOmega Proxy for Chrome to use 192.168.0.155:8118 but I can't hit the internet. It looks like the VPN is configured correctly because 94.140.11.62 is not my public IP address. How else I can troubleshoot this issue? There is only 1 error in the log but it seems to be related to TOR. I've tried all of the services but none work. I have other containers running on the PI (portainer as an example) and I can access that without issue. Your project looks like a fantastic AIO solution for my home network so I really wanted to get it to work but I'm stuck.

_openvpn_client_logs.txt

Are there some sort of firewall rules in place for incoming connections?

Hi, I have a vpn supporting port forwarding (purevpn) and I have a dockerized qbittorrent instance connecting to openvpn-aio thru socks5. The issue seems that I can get direct incoming connections only via UDP and nothing with TCP. I was using gluetunvpn docker before and after opening the firewall I got incoming connections fully working. With gluetunvpn not supporting socks5 I was connecting with --network=container:gluetunvpn docker option tho. I decided to switch to this because with socks5 updating the VPN container creates less hassles and be fully unattended. So are there some rules that could block incoming TCP connections from VPN to socks5 client? Thanks

Stuck at Connection in progress, wait 10s...

Hi,

I use a VPN provider called Integrity (https://integrity.st) and can´t seem to get this working correctly on my Unraid server, see log below.

My ovpn config file:

openvpn.ovpn client dev tun proto udp

remote Censored 1197

remote-random
resolv-retry infinite
reneg-sec 0
nobind
persist-key
persist-tun
verb 3
mute 10
auth-user-pass /etc/openvpn/auth.txt
explicit-exit-notify 2

cipher aes-256-cbc
auth SHA512

script-security 2

remote-cert-tls server
compress lzo

key-direction 1
<ca>
-----BEGIN CERTIFICATE-----
Censored
-----END CERTIFICATE-----
</ca>
<tls-auth>

-----BEGIN OpenVPN Static key V1-----
Censored
-----END OpenVPN Static key V1-----
</tls-auth>

The auth.txt file is a 2-liner file with user and pass

Docker Log [info] Config file detected...

[info] Setting variables
[info] Set various ports to docker variables
[info] Determine openvpn port from config file
[info] Determine openvpn protocol from config file
[info] Will connect openvpn on port=1197 proto=udp
[info] Determine eth0 network for nftables
[info] eth0 IP is 192.168.3.2 in network 192.168.3.0/24
[info] All variables set

[info] Fixing configs
[info] Tor build detected...
[info] torsocks fixed.
[info] privoxy fixed.
[info] stubby fixed.
[info] danted fixed.
[info] tinyproxy fixed.
[info] All configs fixed

[info] Run stubby in background on port 53
[06:51:52.018466] STUBBY: Read config from file /etc/stubby/stubby.yml
[warn] Your ISP public IP is Censored

[info] Set up nftables rules
[info] Editing base ruleset
[info] Tor build detected. Editing tor + privoxy ruleset
[info] Flusing ruleset
[info] Added route 192.168.1.0/24 via 192.168.3.1 dev eth0
[info] Apply rules

[info] Quick block test. Expected result is time out. Actual result is ;; connection timed out; no servers could be reached
[info] All rules created

[info] Setting up OpenVPN tunnel
[info] Create tunnel device
[info] Allow DnS-over-TLS for openvpn to lookup VPN server
[info] Connecting to VPN on port 1197 with proto udp...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...
[info] Connection in progress, wait 10s...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.