OpenVPN がデフォルト以外のポート 1190 をリッスンしない

OpenVPN がデフォルト以外のポート 1190 をリッスンしない

サーバーに OpenVPN を設定しようとしていますが、うまく動作しません。デフォルトのポートを変更しましたが (主に VPN ブロックを回避するため)、サーバーに接続できません。

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 

別の出力

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      - 

ローカルマシンから接続がタイムアウトします。

(base) ➜  dir  nc -v x.xx.xx.xx 1190
nc: connect to x.xx.xx.xx port 1190 (tcp) failed: Connection timed out 

これを修正するために、次のコマンドを実行してみましたが、効果はありませんでした。

sudo iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 1190 -j ACCEPT

Linux 上の OpenVPN クライアントに接続すると、次のメッセージが表示されます。

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

トラブルシューティングと修正に関するご助力をいただければ幸いです。

答え1

ここにはいくつかあります。

  1. 投稿の最初のコード ブロックは、OpenVPN が UDP でリッスンしていることを示しています。
  2. 2 番目のコード ブロックは TCP を示しています。
  3. ncUDP ポート 1190 ではなく、TCP ポート 1190 に接続しようとします。
  4. ルールiptablesでは、UDP ではなく TCP が再度表示されます。

OpenVPNはデフォルトでUDPを使用します。正当な理由から

UDP では、TCP ほど簡単に接続性を確認できないことも意味します。ファイアウォールが黙ってパケットをドロップすることと、サービスが黙って不明な入力を破棄することの違いを見分けるのは困難です。

NC ではなく OpenVPN クライアントでテストします。TCP と UDP の問題を修正します。

関連情報