도커 - VPN에 연결

도커 - VPN에 연결

내 Windows OpenVPN 서버는 10.8.0.1에서 실행되고 있습니다.

server.ovpn은 다음과 같습니다.

server 10.8.0.0 255.255.255.0
port 1194

topology subnet

proto udp4       
dev tun

ca "C:\\Program Files\\OpenVPN\\config\\ca.crt"
cert "C:\\Program Files\\OpenVPN\\config\\server.crt"
key "C:\\Program Files\\OpenVPN\\config\\server.key"
dh "C:\\Program Files\\OpenVPN\\config\\dh2048.pem"

#for debug, allow same certs on all clients
duplicate-cn
        
keepalive 10 120

cipher AES-256-GCM

comp-lzo
persist-key
persist-tun
verb 3

explicit-exit-notify 1

WSL을 시작하고 다음을 통해 WSL2(Ubuntu)에서 도커 이미지를 실행했습니다.

docker run --gpus all --privileged -p 1777:1777 -p 1778:1778 --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 -it --rm -v/mnt/d/data:/mnt nvcr.io/nvidia/pytorch:23.06-py3

Docker 내부에서 다음을 통해 네트워크 도구와 OpenVPN을 설치했습니다.

apt update

apt -y install net-tools
apt -y install netcat
apt -y install iputils-ping
apt -y install iproute2
apt -y install iptables
apt -y install traceroute

apt -y install OpenVPN 

이제 설치 /mnt하고 실행합니다.

openvpn --config client.ovpn

client.ovpn은 다음과 같습니다.

client

dev tun
proto udp4
remote a.b.c.d 1194
resolv-retry infinite
nobind
persist-key
persist-tun

ca ca.crt
cert Client1.crt
key Client1.key    
remote-cert-tls server

cipher AES-256-GCM
comp-lzo
verb 3

(인증서는 client.ovpn과 동일한 디렉터리에 있습니다.)

ifconfig를 실행하면 다음을 볼 수 있기 때문에 연결이 설정된 것 같습니다.

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.15.1.1  netmask 255.255.255.0  broadcast 172.15.1.255
        ether 02:42:ac:0f:01:01  txqueuelen 0  (Ethernet)
        RX packets 22289  bytes 30846027 (30.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10953  bytes 734146 (734.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1500
        inet 10.8.0.2  netmask 255.255.255.0  destination 10.8.0.2
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

그러나 docker에서 실행하면 ping 10.8.0.1(나도 시도함) 서버나 연결된 다른 클라이언트에 ping을 보낼 수 없습니다. ping -I tun0 10.8.0.1Docker는 eth0아무 문제 없이 인터넷 서버를 ping할 수 있습니다.

내가 무엇을 놓치고 있나요? 참고: 저는 네트워킹이나 VPN 전문가가 아닙니다.

관련 정보