Proxmox 上的 NAT 设置

Proxmox 上的 NAT 设置

我正在尝试在 Proxmox VE 7.3-4 上设置 NAT。我按照本指南操作,但更改了 IP 范围,并且尚未进行任何端口转发https://bobcares.com/blog/setup-nat-on-proxmox/

我编辑了/etc/network/interfaces添加vmbr1,然后运行ifup vmbr1。我可以10.10.0.1从主机本身 ping 通,因此vmbr1已启动,我也可以从虚拟机 ping 通主机。但是,我无法从虚拟机内部访问互联网,甚至无法 ping 通1.1.1.1。这似乎是路由问题,但我不确定是什么。

主持人/etc/network/interfaces

    auto lo
    iface lo inet loopback

    iface eno3 inet manual

    iface eno4 inet manual

    auto vmbr0
    iface vmbr0 inet static
            address *.*.*.179/24
            gateway *.*.*.254
            bridge-ports eno3
            bridge-stp off
            bridge-fd 0
            hwaddress AC:1F:6B:63:77:4A

    auto vmbr1
    iface vmbr1 inet static
            address 10.10.0.1/22
            bridge-ports none
            bridge-stp off
            bridge-fd 0

            post-up echo 1 > /proc/sys/net/ipv4/ip_forward
            post-up   iptables -t nat -A POSTROUTING -s '10.10.0.0/22' -o vmbr0 -j MASQUERADE
            post-down iptables -t nat -D POSTROUTING -s '10.10.0.0/22' -o vmbr0 -j MASQUERADE

路由表和来自虚拟机的 ping 操作:

     % ip route
    default via 10.10.0.1 dev eth0 proto static
    10.10.0.0/22 dev eth0 proto kernel scope link src 10.10.0.100 
     % ping 10.10.0.1
    PING 10.10.0.1 (10.10.0.1) 56(84) bytes of data.
    64 bytes from 10.10.0.1: icmp_seq=1 ttl=64 time=0.086 ms
    64 bytes from 10.10.0.1: icmp_seq=2 ttl=64 time=0.068 ms
    ^C
    --- 10.10.0.1 ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1002ms
    rtt min/avg/max/mdev = 0.068/0.077/0.086/0.009 ms
     % ping 1.1.1.1
    PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
    ^C
    --- 1.1.1.1 ping statistics ---
    3 packets transmitted, 0 received, 100% packet loss, time 2055ms

我错过了什么?

答案1

解决了!忘记添加 conntrack 区域:

post-up   iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1

相关内容