5
4

More than 5 years have passed since last update.

dockerでOpenVPNコンテナを他のコンテナのゲートウェイにしたい

Posted at

pipework使わないで、なんとかできないものかと頑張ってみたんだけど、iptablesをいじらなきゃいけないのかな、、

構成

container1: openvpn client
container2: container1をゲートウェイにしてvpn server につなぐ

docker_with_openvpn_as_gateway.jpg

赤編みかけ: 設定したこと
青編みかけ: dockerデフォルト

設定

container2

ip route add 10.0.0.0/8 via 172.17.0.28

container1

iptables -t nat -A POSTROUTING -s 172.17.0.0/16  -j MASQUERADE

docker host

iptables -t nat -D POSTROUTING -s 172.17.0.0/16 ! -d 172.17.0.0/16 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 172.17.0.0/16 ! -d 10.0.0.0/8 -j MASQUERADE
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4