Monday, June 29, 2015

Proxmox Host and Nodes with Private IP - NAT and Port Forwarding

Here a quick solution for playing around when you only have 1 public IP and private IPs for your VMs/Nodes. Here we give 10.10.10.2 to your VM and forward port 10022 to port 22 (SSH) on the VM

Host Config:
auto eth0
iface eth0 inet static
        address 94.xxxxxxxxx
        netmask 255.255.255.0
        broadcast 94.xxxxxxxxx
auto vmbr0
iface vmbr0 inet static
        address  10.10.10.1
        netmask  255.255.255.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.10.10.0/24' -o eth0 -j MASQUERADE
                post-up iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 10022 -j DNAT --to-destination 10.10.10.2:22
        post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE

Node/VM Config:
auto eth0
iface eth0 inet static
         address 10.10.10.2
         gateway 10.10.10.1
         netmask 255.255.255.0


No comments:

Post a Comment