KVM: Passing a port from your public NATd IP to an internal VM host

If you're using KVM's "default" network to provide NAT to your VMs you may want to map certain inbound ports to a specific VM. Using these iptables commands and destination NAT you will be able to connect to your VMs using a single outward facing IP.

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to
Leave A Reply
All content licensed under the Creative Commons License