Debian で iptables を使用して openVPN 経由でポートを転送できない

Debian で iptables を使用して openVPN 経由でポートを転送できない

パブリックコンピュータをVPN経由で接続されている別のコンピュータにポート転送しようとしています。このVPNを介してデバイスがインターネットに接続されます。私はDebianでopenvpnとiptablesを使用しています。

VPNは期待どおりに機能しますが、ポート転送は機能しません。私は成功せずにstackexchangeに関する他の多くの質問を見直しました。

VPNクライアントはVPNに固定IPを持っています。パブリックインターネットアドレスも固定されています。

配信が有効になっています...

$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

クライアントのポートは VPN インターフェイスを介してパブリック コンピュータで開かれていますが、パブリック コンピュータから転送されるわけではありません。-d <public ip>とのようなiptablesコマンドのさまざまなバリエーションを試しましたが、-i eth0私が間違っているかどうかはわかりません。

$ iptables -t nat -A PREROUTING -p tcp --dport 14333 -j DNAT --to-destination 10.8.0.10:14333
$ iptables -t nat -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE

$iptables -t nat -L -v

Chain PREROUTING (policy ACCEPT 5252 packets, 328K bytes)
 pkts bytes target     prot opt in     out     source               destination         
 1471 85380 DNAT       tcp  --  any    any     anywhere             anywhere             tcp dpt:14333 to:10.8.0.10:64333

Chain INPUT (policy ACCEPT 50 packets, 2156 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 450 packets, 29316 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 1998 packets, 122K bytes)
 pkts bytes target     prot opt in     out     source               destination         
 4435  272K MASQUERADE  all  --  any    eth0    10.0.0.0/8           anywhere          

公開インターフェイスはeth0次のとおりです。 openvpnは次のようになります。tun0

ベストアンサー1

おすすめ記事