Docker Containers in an LXC Container not able to access VPN

I have an LXC Container and from that container i was able to connect to VPN, But i’m running some docker containers in that LXC Container and those docker containers are not able to access my VPN. How can i make those docker containers access my VPN?

That part should be down to mostly normal networking, you’ll want to make sure that IP forwarding is enabled (/proc/sys/net/ipv4/ip_forward) and that you have suitable MASQUERADE rules in iptables.

Usually, something like this does the trick:

  • echo 1 > /proc/sys/net/ipv4/ip_forward
  • iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE

That assumes that tun0 is the VPN interface.