How to connect Docker containers to OpenVPN clients?

How to connect Docker containers to OpenVPN clients?

The third one creates the OpenVPN server. It is attached to the newly created Docker network and uses a fix IP. The fourth and fifth commands configure IP forwarding. The last command adds a new route towards the VPN client configuration via the OpenVPN container fixed IP.

How to route Docker container over a specific host interface?

By leaving line 25 commented we only routing traffic from the docker vpn network over the OpenVPN. The down.sh script removes the $trusted_ip which was added during setup. Finally, we want to avoid that packets go over over the eth0 interface if the OpenVPN on tun0 is down.

Why do we use proxy in Docker container?

Most of the time a proxy within the Virtual Private Network is used to achieve this. This has also the benefit that, if the network interface does down and the routing rules are reset, then the traffic is not sent though some other default interface.

Where does the network Create action in Docker take place?

The network create action creates a new interface on the host with 172.18.0.1/16 as subnet. It will be called vpn within docker and Linux. You can validate the settings by checking ip a: The docker host gets the IP 172.18.0.1.

How to reach OpenVPN clients directly from a private network?

If your VPN client subnet is for example 172.16.47.0/24, and your OpenVPN Access Server installation is at IP address 192.168.47.222 then add this static route: Network 172.16.47.0 with subnet mask 255.255.255.0 to go through gateway 192.168.47.222 Now traffic should find its way in both directions.

Can a VPN Client Access a private subnet?

Direct access to the VPN client IP subnet is not possible. To enable two-way traffic using routing, go to VPN Settings, Should VPN clients have access to private subnets, and set the option to yes, using routing (advanced) instead.

Where to find static route table for OpenVPN?

To make things work properly again now you have to look up the static route table in the default gateway system in your private network. If your VPN client subnet is for example 172.16.47.0/24, and your OpenVPN Access Server installation is at IP address 192.168.47.222 then add this static route: