
Estou tentando criar um servidor VPN simétrico com openvpn em um docker-compose. Aqui está:
---
version: "3"
services:
vpn:
image: whitebox/vpn:0.2
networks:
- standard
tty: true
ports:
- "1194:1194/udp"
volumes:
- ./server:/home/server:ro
- ./static.key:/home/static.key:ro
cap_add:
- NET_ADMIN
- SYS_MODULE
restart: always
networks:
standard:
ipv4_address: "10.10.0.254"
web:
image: tutum/apache-php
volumes:
- ./web:/var/www/html:ro
- ./client:/home/client:ro
networks:
standard:
ipv4_address: "10.10.0.2"
networks:
standard:
driver: bridge
ipam:
config:
- subnet: 10.10.0.0/16
Quando ele é iniciado, eu (temporariamente) instalo manualmente o openvpn, faço algumas configurações básicas e inicio o serviço. Tudo parece funcionar bem, exceto que não consigo me conectar a ele de nenhum dispositivo.
Arquivo de configuração do servidor:
ifconfig 10.10.0.254 10.10.0.10
verb 3
secret static.key
keepalive 1 10
persist-key
persist-tun
proto udp
port 1195
dev tun
status /home/vpn.log
Arquivo de configuração do cliente:
remote 192.168.37.137 1194
dev tun
ifconfig 10.10.0.10 10.10.0.254
secret static.key
O estranho nisso é que tentei montar exatamente o mesmo servidor em uma VM simples e tudo funcionou. O cliente pode se conectar a ele e acessar a rede 10.10.0.0/16. Porém, aqui está o log de conexão do cliente:
Wed Aug 11 00:37:16 2021 TUN/TAP device tun0 opened
Wed Aug 11 00:37:16 2021 /sbin/ip link set dev tun0 up mtu 1500
Wed Aug 11 00:37:16 2021 /sbin/ip addr add dev tun0 local 10.10.0.10 peer 10.10.0.254
Wed Aug 11 00:37:16 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]192.168.37.137:1194
Wed Aug 11 00:37:16 2021 UDP link local (bound): [AF_INET][undef]:1194
Wed Aug 11 00:37:16 2021 UDP link remote: [AF_INET]192.168.37.137:1194
E o servidor baseado em contêiner correspondente:
Wed Aug 11 07:34:40 2021 TUN/TAP device tun0 opened
Wed Aug 11 07:34:40 2021 TUN/TAP TX queue length set to 100
Wed Aug 11 07:34:40 2021 /sbin/ip link set dev tun0 up mtu 1500
Wed Aug 11 07:34:40 2021 /sbin/ip addr add dev tun0 local 10.10.0.254 peer 10.10.0.10
Wed Aug 11 07:34:40 2021 Could not determine IPv4/IPv6 protocol. Using AF_INET
Wed Aug 11 07:34:40 2021 Socket Buffers: R=[212992->212992] S=[212992->212992]
Wed Aug 11 07:34:40 2021 UDPv4 link local (bound): [AF_INET][undef]:1195
Wed Aug 11 07:34:40 2021 UDPv4 link remote: [AF_UNSPEC]
Como você pode ver, nenhuma conexão é feita. Alguém tem alguma ideia do porquê?
Responder1
Certifique-se de que as portas estejam configuradas corretamente.
Você está encaminhando a porta 1194 para o seu contêiner, mas o OpenVPN está configurado para escutar a porta 1195.