
Estou tentando configurar o OpenVPN em um servidor, mas não consigo fazê-lo funcionar. Alterei a porta padrão (principalmente para ignorar possíveis bloqueios de VPN), mas não consigo me conectar ao servidor.
openvpnas@ip-xxx-xx-xx-xx:~$ sudo netstat -uapn | grep openvpn
udp 0 0 0.0.0.0:1190 0.0.0.0:* 1455/openvpn-openss
Outra saída
openvpnas@ip-xxx-xx-xx-xx:~$ netstat -atnp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:904 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:905 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:906 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:907 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:908 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:909 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:943 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 172.31.42.30:22 xx.xx.xxx.xx:52882 ESTABLISHED -
tcp 0 0 127.0.0.1:42390 127.0.0.1:908 TIME_WAIT -
tcp 0 150 xxx.xx.xx.xx:34884 xxx.xxx.xx.xx:443 ESTABLISHED -
tcp6 0 0 :::22 :::* LISTEN -
Na minha máquina local, a conexão atinge o tempo limite.
(base) ➜ dir nc -v x.xx.xx.xx 1190
nc: connect to x.xx.xx.xx port 1190 (tcp) failed: Connection timed out
Para corrigir isso, tentei executar o seguinte comando sem sucesso:
sudo iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 1190 -j ACCEPT
Ao conectar-me ao cliente OpenVPN no Linux, recebo o seguinte:
2022-06-13 17:49:00 WARNING: --ns-cert-type is DEPRECATED. Use --remote-cert-tls instead.
2022-06-13 17:49:00 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2022-06-13 17:49:00 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2022-06-13 17:49:00 TCP/UDP: Preserving recently used remote address: [AF_INET]x.xx.xx.xx:1190
2022-06-13 17:49:00 Socket Buffers: R=[212992->212992] S=[212992->212992]
2022-06-13 17:49:00 UDP link local: (not bound)
2022-06-13 17:49:00 UDP link remote: [AF_INET]x.xx.xx.xx:1190
2022-06-13 17:49:04 Server poll timeout, restarting
2022-06-13 17:49:04 SIGUSR1[soft,server_poll] received, process restarting
2022-06-13 17:49:04 WARNING: --ns-cert-type is DEPRECATED. Use --remote-cert-tls instead.
2022-06-13 17:49:04 Outgoing Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2022-06-13 17:49:04 Incoming Control Channel Authentication: Using 160 bit message hash 'SHA1' for HMAC authentication
2022-06-13 17:49:04 TCP/UDP: Preserving recently used remote address: [AF_INET]x.xx.xx.xx:1190
2022-06-13 17:49:04 Socket Buffers: R=[212992->212992] S=[212992->212992]
2022-06-13 17:49:04 UDP link local: (not bound)
2022-06-13 17:49:04 UDP link remote: [AF_INET]x.xx.xx.xx:1190
Qualquer ajuda na solução de problemas e correção será apreciada.
Responder1
Há algumas coisas aqui.
- O primeiro bloco de código da sua postagem mostra o OpenVPN escutando no UDP.
- O segundo bloco de código mostra TCP.
nc
tenta se conectar à porta TCP 1190, não à porta UDP 1190.- Sua
iptables
regra mostra novamente TCP; não UDP.
Por padrão, o OpenVPN usa UDP,por boas razões.
O UDP também implica que você não pode verificar a conectividade tão facilmente quanto com o TCP; é difícil dizer a diferença entre um firewall descartar pacotes silenciosamente e o serviço descartar silenciosamente entradas desconhecidas.
Teste com um cliente OpenVPN, não com NC. Resolva seu problema com TCP vs. UDP.