Proxmox 2. IP - sehe den Wald vor lauter Bäumen nicht

  • Servus,

    alles was mit eth0 zu tun hat funktioniert einwandfrei. Nun möchte ich allen eingehenden Traffic für die IP 152.53.175.70 auf eth0:0 umleiten. Kann mir jemand sagen was ich falsch mache? Danke


    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 152.55.89.136/22
    gateway 152.55.89.1
            
    # zusätzliche IP

    post-up ip addr add 152.53.175.70/32 dev eth0 label eth0:0
    pre-down ip addr del 152.53.175.70/32 dev eth0

    auto vmbr0
    iface vmbr0 inet static
    address 10.10.10.1/24
    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.10.0/24' -o eth0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
    post-up iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.10.10.100:80
    post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination 10.10.10.100:80
    post-up iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
    post-down iptables -t nat -D PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
    post-up iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
    post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
    post-up iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
    post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT

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

    # zusätzliche IP alles auf 10.10.10.110 umleiten

    iptables -t nat -A PREROUTING -d 152.53.175.70 -j DNAT --to-destination 10.10.10.110
    iptables -t nat -A POSTROUTING -d 10.10.10.110 -j MASQUERADE

  • Mal eine kurz überarbeitete Version, powered by Gemini:
    —-
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 152.55.89.136/22
    gateway 152.55.89.1
       
    # Zusätzliche Öffentliche IP für eth0
    post-up ip addr add 152.53.175.70/32 dev eth0 label eth0:0
    pre-down ip addr del 152.53.175.70/32 dev eth0

    auto vmbr0
    iface vmbr0 inet static
    address 10.10.10.1/24
    bridge-ports none
    bridge-stp off
    bridge-fd 0

    # IP-Forwarding aktivieren
    post-up echo 1 > /proc/sys/net/ipv4/ip_forward

    # 1. Proxmox-Firewall/Zone Fix
    post-up iptables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1
    post-down iptables -t raw -D PREROUTING -i fwbr+ -j CT --zone 1

    # 2. Port-Forwarding (Haupt-IP -> 10.10.10.100 für HTTP/HTTPS)
    post-up iptables -t nat -A PREROUTING -i eth0 -d 152.55.89.136 -p tcp --dport 80 -j DNAT --to-destination 10.10.10.100:80
    post-down iptables -t nat -D PREROUTING -i eth0 -d 152.55.89.136 -p tcp --dport 80 -j DNAT --to-destination 10.10.10.100:80
    post-up iptables -t nat -A PREROUTING -i eth0 -d 152.55.89.136 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
    post-down iptables -t nat -D PREROUTING -i eth0 -d 152.55.89.136 -p tcp --dport 443 -j DNAT --to-destination 10.10.10.100:443
       
    post-up iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
    post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 80 -j ACCEPT
    post-up iptables -A FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT
    post-down iptables -D FORWARD -p tcp -d 10.10.10.100 --dport 443 -j ACCEPT

    # 3. Vollständiges 1:1 NAT für Zusatz-IP (152.53.175.70 <-> 10.10.10.110)
    # Eingehend (DNAT)
    post-up iptables -t nat -A PREROUTING -d 152.53.175.70/32 -j DNAT --to-destination 10.10.10.110
    post-down iptables -t nat -D PREROUTING -d 152.53.175.70/32 -j DNAT --to-destination 10.10.10.110
       
    # Ausgehend (SNAT) - Wichtig: -I POSTROUTING 1 platziert diese Regel VOR dem Standard-Masquerade
    post-up iptables -t nat -I POSTROUTING 1 -s 10.10.10.110/32 -o eth0 -j SNAT --to-source 152.53.175.70
    post-down iptables -t nat -D POSTROUTING -s 10.10.10.110/32 -o eth0 -j SNAT --to-source 152.53.175.70

    # Traffic-Freigabe für 10.10.10.110
    post-up iptables -A FORWARD -d 10.10.10.110/32 -j ACCEPT
    post-down iptables -D FORWARD -d 10.10.10.110/32 -j ACCEPT

    # 4. Standard Outbound-MASQUERADE für alle übrigen VMs im Subnetz 10.10.10.0/24
    post-up iptables -t nat -A POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s 10.10.10.0/24 -o eth0 -j MASQUERADE
    —-
    Die beiden letzten iptables-Regeln fehlte das post-up. Es wird in interfaces nichts ohne post-up oder pre-up ausgeführt.
    Im Kern fehlte das Forward für die .110, das MASQUERADE für die .110 ist auch überflüssig (weil oben schon mit abgedeckt), das SNAT hab ich dazugenommen, damit auch mit der IP rückwärts geantwortet wird und nicht mit der primären NAT-IP, d.h. ein 1:1 NAT.