[TUTORIAL] 2 Public IPs - One Host One Container AND with NAT

Same Problem / Selbes Problem?

  • Yes / Ja

  • No / Nein


Results are only viewable after voting.

djdomi

Renowned Member
Mar 1, 2014
35
2
73
Hallo,

ich habe ein pve 5.4-11 am laufen, welches per NAT alles soweit funktioniert (Primäry Public-IP)
Jetzt ist die Anforderung dazu gekommen, das ein container per zusätzlicher (Sekundärer)Public-IP direkt angesprochen werden muss.

Wenn ich die IP dem container direkt vergebe, kann ich diese nicht anpingen, wenn ich diese dem host testweise hinzufüge, kann die IP gepingt werden, ergo ist die IP grundsätzlich funktionsfähig.


cat interfaces
auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
address x.x.x.x #publicip
netmask 255.255.252.0
gateway x.x.x.x #publicgateay


auto vmbr0
#private sub network
iface vmbr0 inet static
address 10.0.0.1
netmask 255.0.0.0
bridge_ports none
bridge_stp off
bridge_fd 0
post-up /etc/postup_iptables
post_down /etc/postdown_iptables
#post-up echo 1 > /proc/sys/net/ipv4/ip_forward
#post-up iptables -t nat -A POSTROUTING -s '10.0.0.0/8' -o ens3 -j MASQUERADE
#post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/8' -o ens3 -j MASQUERADE

Nat funktioniert,ich frage mich ob ich hier, was ich übersehen habe?
 
Zusammenfassung: Proxmox Host mit Single IP, Plus NAT Plus Public-IP container/VM

  • 1.2.3.4 = primary public IP PROXMOX HOST
  • 4.3.2.1 = Subnetmask primary public IP PROXMOX HOST
  • 2.3.4.5 = PUBLIC IP CONTAINER
  1. interfaces auf dem PROXMOS HOST

    Code:
    # nano /etc/network/interfaces
    
    auto lo
    iface lo inet loopback
    
    auto ens3
    iface ens3 inet static
            address 1.2.3.4
            netmask x.x.x.x
            gateway 4.3.2.1
            post-up echo 1 > /proc/sys/net/ipv4/conf/ens3/proxy_arp
    
    auto vmbr0 vmbr1
    #NAT sub network, not bridged
    #10.0.0.0/8
    #192.168.0.0/16 (192.168.0.0-192.168.255.255, one space)
    #192.168.0.0/
    iface vmbr0 inet static
            address  10.0.0.1
            netmask  255.0.0.0
            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.0.0.0/8' -o ens3 -j MASQUERADE
            post-down iptables -t nat -D POSTROUTING -s '10.0.0.0/8' -o ens3 -j MASQUERADE
    
    #private sub network2
    #No Nat Subnetwork, Bridged
    iface vmbr1 inet static
            address  10.0.0.2
            netmask  255.0.0.0
            bridge_ports ens3
            bridge_stp off
            bridge_fd 0
            #add here each new Public IP for any Container
            #we need to tell here the Host to use the default gateway for this IP
            post-up         route add 2.3.4.5 dev vmbr1
  • 2.3.4.5 ist die neue Public-IP,
  • Netzwerkkarte hinzufügen
  • IP: 2.3.4.5
  • Gateway 10.0.0.2 (Umsetzung erfolgt am proxmox Host)
 
FEHLERMELDUNGEN:
Mein Server ist unerreichbar / vmbr1 funktioniert nicht
    • Prüfe ob die Netzwerkkarte (in unseren beispiel ens3)
      • auto ens3 - muss vorhanden sein, sonst kann vmbr1 nicht hochkommen weil bridge_port ens3 existiert und somit ohne ens3 keine vmbr1!
  • server plötzlich nicht mehr erreichbar.
  • es kann passieren dass die host config geändert wird und dann der server wegen der zweiten Brücke nicht mehr ins internet kommt. einfach statt ens3 durch none ersetzen
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!