0

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.

0

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 192.168.1.0/24 gw 172.17.17.1

where 192.168.1.0/24 is the IP network you want to route via Docker container's local IP address 172.17.17.1.

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, 192.168.0.0/24 (a) and 192.168.1.0/24 (b), where 192.168.0.1 and 192.168.1.1 are the routers. Then on network a, you need to have route 192.168.1.0/24 via 192.168.0.1, and on network b, 192.168.0.0/24 via 192.168.1.1. 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.