ポートリダイレクトと DNAT が vxlan で動作しない理由

ポートリダイレクトと DNAT が vxlan で動作しない理由

2 台のコンピューター A (Debian で IP 192.168.30.1) と B (archlinux で IP 192.168.30.3) の間に VXLAN 接続を作成する必要があります。そのために、次の操作を実行しました。

  • Aの場合:
  sudo ip link add vxlan1 type vxlan id 1 nolearning remote 192.168.30.3 dstport 33333 dev ens4
  sudo ip link set vxlan1 up
  sudo ip addr add 10.0.0.106/24 dev vxlan1
  • Bの場合:
  sudo ip link add vxlan2 type vxlan id 1 nolearning remote 111.111.111.111 dstport 33333 dev ens3
  sudo ip link set vxlan2 up
  sudo ip addr add 10.0.0.107/24 dev vxlan2

さらに、PC BI で DNAT ルールを作成します。

  sudo iptables -w -t nat -A OUTPUT -s 192.168.30.3 -d 111.111.111.111 -p udp --dport 33333 -j DNAT --to-destination 192.168.30.1:33333

それから私はこうしました:

  • PC Aの場合: ping 10.0.0.107.これはpingで期待通りに動作します返信します。
  • PC Bの場合: ping 10.0.0.106.これはpingで期待通りに動作します返信します。
  • PC A の場合: nc -u -lp 12345。 PC B の場合: nc -u 10.0.0.106 12345PC Bからnetcatコマンドでデータを送信したときに、PC Aのnetcatアプリケーションでデータを読み取ることを期待していました。しかし、何も読み取れませんでした。

私の問題は最後のポイントにあります。なぜ私のnetcatリスナーは何も受信しないのでしょうか。PC AIでwiresharkを使用すると次のようになります:

[PC A1 上の Wireshark ダンプ

追加情報

  • uname -aPC A は「Linux debian 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux」で実行されています (これはコマンドの結果です)

  • ens4のPC AのIPは192.168.30.1/24です

  • uname -aPC B は「Linux archlinux 5.13.9-arch1-1 #1 SMP PREEMPT Sun, 08 Aug 2021 11:25:35 +0000 x86_64 GNU/Linux」で実行されます (これはコマンドの結果です)

  • ens3のPC BのIPは192.168.30.3/24です

  • 2台のマシンはGNS3で起動されたQemu VMです

  • PC A 上の netfilter の nat テーブルと filter テーブルは空です。

seb@debian:~$ sudo iptables -t nat -L ; sudo iptables -t filter -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination    
  • PC BI には、DNAT ルールと、「ポート到達不能」タイプの ICMP パケットをドロップするルールのみがあります (これは別の目的で追加したルールです)。
[seb@archlinux vxlan]$ sudo iptables -t nat -L -n ; sudo iptables -t filter -L -n
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DNAT       udp  --  192.168.30.3         111.111.111.111      udp dpt:33333 to:192.168.30.1:33333

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
DROP       icmp --  0.0.0.0/0            0.0.0.0/0            icmptype 3

関連情報