nftablesを使用してホストトラフィックを内部VMにリダイレクトできない

nftablesを使用してホストトラフィックを内部VMにリダイレクトできない

私の問題は次のとおりです。Ubuntu 20ホストで。外部からアクセスできるマルチチャネルハイパーバイザーと仮想マシンがあります。

  • 物理ホスト:eth1 192.168.10.33/16

  • 仮想マシン: mpqemubr0 10.54.32.232/24

転送が有効になっています。

cat /etc/sysctl.conf | grep forward
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

各インターフェイスでも有効です。

cat /proc/sys/net/ipv4/conf/mpqemubr0/forwarding
1

cat /proc/sys/net/ipv4/conf/eth0/forwarding 
1

iptablesとufwが無効になり、nftablesがインストールされます。

nftablesの設定は次のとおりです。

#!/usr/sbin/nft -f
flush ruleset
table ip nat {
        chain prerouting {
            type nat hook prerouting priority 100;
            
            ip daddr 192.168.10.33 tcp dport {80,8080} dnat 10.54.32.232:8080
        }
        chain postrouting {
            type nat hook postrouting priority 100; policy accept;
            ip saddr 10.54.32.0/24 oifname {eth0,mpqemubr0} masquerade
        }
}
table inet filter {
    chain input {
        type filter hook input priority 0;
    }
    chain forward {
        type filter hook forward priority 0;
            ip daddr 10.54.32.232 accept
    }
    chain output {
        type filter hook output priority 0;
    }
}
  • ホストからポート 8080 を介して VM に Telnet で接続できます。
  • 外部から所有者に連絡できます。
  • VMから外部にpingできます。

ホストからVMに外部からトラフィックをリダイレクトすることはできず、ホストでtcpdumpを使用するとシステムからパケットが到着することがわかりますが、ポート8080またはホスト10.54.32.232には出力がありません。

sudo tcpdump -i any -n port 80 or port 8080 -vvvv
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
14:30:36.229571 IP (tos 0x0, ttl 63, id 5375, offset 0, flags [DF], proto TCP (6), length 60)
    10.55.55.16.38848 > 192.168.10.33.80: Flags [S], cksum 0x71ba (correct), seq 560636356, win 64860, options [mss 1380,sackOK,TS val 1972236760 ecr 0,nop,wscale 7], length 0

明らかに、仮想マシンはインターフェイスに入ってくるものを見ません。

以前は同じホスト上の他のVMと連携していましたが、それを再作成する必要がありましたが、新しいVMは別のIPを使用していましたが、新しいVM IPと一致するようにnftables.confを変更しても機能しなくなりました(しかし、古い仮想マシン)以上存在しません。

構成が欠落しているようです。ところでどこにありますか?

ご協力ありがとうございます!

ベストアンサー1

おすすめ記事