Port forward with iptables for VMs on libvirt based NAT network

Quite often I felt the need to setup port forwarding from the libvirt hypervisors public IP to the IP of the VM instance which is connected to a private network behind a NAT.
This way I can provide access these VMs from outside the Hypervisor.

This simple script gain Iptables based port forwarding for libvirt hosted kvm/lxc instances.
It takes input of the form <host_port>:<dest_ip>:<dest_port> or in this case <hypervisor_port>:<vm_ip>:<vm_port>

iptab_fwd.sh
Advertisements

Published by

Chandan Dutta Chowdhury

Software Engineer

One thought on “Port forward with iptables for VMs on libvirt based NAT network”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s