Sign inSign up

tsoichinghin/ovpn

By tsoichinghin

โ€ขUpdated about 1 year ago

This is an OpenVPN client to allowing other containers to route traffic.

Image
0

1.1K

tsoichinghin/ovpn repository overview

โ ๐Ÿ“ก OpenVPN Client Docker Image

Purpose: This image runs an OpenVPN client to create a secure VPN tunnel, allowing other containers to route traffic through it via network sharing.


โ ๐Ÿ› ๏ธ Prerequisites

  • OpenVPN Files:
    • .ovpn configuration file from your VPN provider.
    • auth.txt with credentials (username on line 1, password on line 2).
  • Docker Setup:
    • Docker installed.
    • TUN/TAP device enabled (ls /dev/net/tun).

โ โš™๏ธ Configuration

โ #### Required Settings
  1. Volume Mount:

    • Map your OpenVPN config folder to /vpn.
    • Example: -v /root/ovpn:/vpn
    • Contains:
      • .ovpn file (e.g., client.ovpn).
      • auth.txt.
  2. Environment Variable:

    • Set OVPN_FILE to your .ovpn filename.
    • Example: -e OVPN_FILE=client.ovpn
    • Note: Use -e OVPN_FILE=us.ovpn for us.ovpn.

โ ๐Ÿš€ Running the Container

docker run -d \
  --restart always \
  --name ovpn \
  --cap-add=NET_ADMIN \
  --device=/dev/net/tun \
  -v /root/ovpn:/vpn \
  -e OVPN_FILE=client.ovpn \
  tsoichinghin/ovpn:latest
โ #### Customizable Parameters
ParameterDescriptionExample
--nameContainer name--name ovpn
-vLocal config folder-v /root/ovpn:/vpn
-e OVPN_FILE.ovpn filename-e OVPN_FILE=client.ovpn

โ ๐ŸŒ Using with Other Containers

Route traffic through the VPN by sharing the OpenVPN containerโ€™s network.

Example:

docker run -d \
  --name my-app \
  --network container:ovpn \
  my-app-image

โ ๐ŸŒ Exposing Services

Map ports to access services (e.g., web UI) from the host.

Example:

docker run -d \
  --restart always \
  --name ovpn \
  --cap-add=NET_ADMIN \
  --device=/dev/net/tun \
  -v /root/ovpn:/vpn \
  -e OVPN_FILE=client.ovpn \
  -p 4449:4449 \
  tsoichinghin/ovpn:latest
  • -p 4449:4449: Access services at http://<host-ip>:4449.

โ ๐Ÿ”’ Security & Notes

  • Password Caching: Add auth-nocache to .ovpn.
  • IPv6: Disable to prevent leaks:
    --sysctl net.ipv6.conf.all.disable_ipv6=1
    
  • Permissions:
    chmod 600 /root/ovpn/auth.txt
    
    chmod 600 /root/ovpn/client.ovpn
    

โ ๐Ÿงช Troubleshooting

  1. View Logs:
    docker logs ovpn
    
  2. Check Files:
    ls -l /root/ovpn
    
    docker run -it --rm -v /root/ovpn:/vpn ovpn
    
    ls -l /vpn
    
  3. Test VPN:
    docker exec -it ovpn /bin/sh
    curl -4 ifconfig.me
    nslookup google.com
    
  4. Verify TUN/TAP:
    ls /dev/net/tun
    sudo modprobe tun
    

โ ๐Ÿ“‹ Example Setup

  1. Run OpenVPN:

    docker run -d \
      --restart always \
      --name ovpn \
      --cap-add=NET_ADMIN \
      --device=/dev/net/tun \
      -v /root/ovpn:/vpn \
      -e OVPN_FILE=client.ovpn \
      -p 4449:4449 \
      --sysctl net.ipv6.conf.all.disable_ipv6=1 \
      tsoichinghin/ovpn:latest
    
  2. Run App:

    docker run -d \
      --name my-web-app \
      --network container:ovpn \
      my-web-app-image
    
  3. Access Service:

    • Visit http://<host-ip>:4449.

โ โ„น๏ธ Support

Check logs (docker logs ovpn) or contact your VPN provider for issues. Ensure .ovpn and auth.txt are valid.

Tag summary

Content type

Image

Digest

sha256:ffaf8b71cโ€ฆ

Size

8 MB

Last updated

about 1 year ago

docker pull tsoichinghin/ovpn