Proxmox - network nat

  • Category: 電腦相關
  • Last Updated: Friday, 10 February 2017 09:26
  • Published: Friday, 10 February 2017 09:16
  • Written by sam

Set Proxmox - network nat function

From 172.24.1.249 icmp_seq=3424 Destination Host Unreachable
From 172.24.1.249 icmp_seq=3425 Destination Host Unreachable
From 172.24.1.249 icmp_seq=3426 Destination Host Unreachable
64 bytes from 172.24.1.248: icmp_seq=3427 ttl=64 time=2010 ms
64 bytes from 172.24.1.248: icmp_seq=3428 ttl=64 time=1005 ms
64 bytes from 172.24.1.248: icmp_seq=3429 ttl=64 time=2.10 ms

HOST:192.168.1.223

GUEST:172.24.1.248

VMBR0:172.24.1.249

Set host interfaces create vmbr0 trought eth0, and config ip address both.

root@wantgoo:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
#for host
auto eth0
iface eth0 inet static
        address 192.168.1.222
        netmask 255.255.255.0
        gateway 192.168.1.1
        post-up echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp
#for guest out
auto vmbr0
iface vmbr0 inet static
 address 172.24.1.249
  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 '172.24.1.0/24' -o eth0 -j MASQUERADE
 post-down iptables -t nat -D POSTROUTING -s '172.24.1.0/24' -o eth0 -j MASQUERADE
#for guest in    
    post-up iptables -t nat -A PREROUTING -i vmbr0 -p tcp --dport 30678 -j DNAT --to 172.24.1.248:22
    post-down iptables -t nat -D PREROUTING -i vmbr0 -p tcp --dport 30678 -j DNAT --to 172.24.1.248:22

And, don't forget set your guest ip

auto ens18 
iface ens18 inet static
  address 172.24.1.248
  netmask 255.255.255.0
 gateway 172.24.1.249