My current setup is has a docker image running OpenVPN Client that connects to an Access Server in AWS. If i run the command:

docker exec <container-id> bash 

I can get into the OpenVPN Container itself and can ping relevant IP's connected to the OpenVPN Server. My question is how would i tell the local machine(ubuntu) to forward all local traffic, say im just doing a ping from outside the container, to go through the Docker0 interface and through the OpenVPN Client?

I've tried setting up a webproxy but I believe setting up the webproxy was to help with other containers forwarding traffic to the OpenVPN container, whereas i need to forward traffic from the local machine.


You need to add routes from your host machine to the destinations you want to be forwarded via the OpenVPN tunnel so that they point to your Docker container IP address.

For example:

route add -net gw

where is the IP network you want to route via Docker container's local IP address

If you cannot control the routing of the machines at the other end of tunnel, you need to set up a reverse route on those machines. Another option is to set up NAT on the Docker container.

  • Whenever i tried to ping after adding the route its still not possible, is there a different route i should be adding? – UtahUnix Jul 17 '18 at 19:58
  • Did you use correct IP addresses? Did you add the corresponding reverse route on the destination machine you tried to ping to? – Tero Kilkanen Jul 18 '18 at 6:35
  • @TeroKilkanen What is the reverse rule? – GuySoft Dec 29 '18 at 1:02
  • If you have two networks, (a) and (b), where and are the routers. Then on network a, you need to have route via, and on network b, via The latter one is the reverse rule. – Tero Kilkanen Dec 30 '18 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.