Docker Community Forums

Share and learn in the Docker community.

[Solved] Openvpn config for container


(Olafbar) #1

[solution]
It was enough to restart container inside the same subnetwork as another an run inside the vpn container:

iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT

ip a:
tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.8.0.1 peer 10.8.0.2/32 scope global tun0
valid_lft forever preferred_lft forever

It works but I don know if I undestand why ? :slight_smile:
[end solution]

Hi ,
I have a proper config for openvpn runing as a server process ( on debian jessie). It works fine as a normal daemon process on server

When i try to copy this config to the container (debian with installed openvpn)
with exposed port 1194 to the server it does not work.

i used command
docker run -it --name vpn --rm
-p 1194:1194/udp
–cap-add=NET_ADMIN --device=/dev/net/tun
vpn bash

then I try to rm /etc/openvpn
and
docker cp /etc/openvpn vpn:/etc/openvpn

After that i try to start server inside container vpn:
service openvpn start (daemon openvpn starts correctly)

On the end I cannot connect to the server from client with the same authorization as before.

Any suggestions?
regards, Olaf

Dockerfile:

FROM debian
RUN apt-get -y update && apt-get -y install openvpn openssl nano iptables procps
RUN apt-get clean && apt-get autoclean && rm -rf /var/lib/apt/lists/*
EXPOSE 1194:1194/udp