Index ¦ Archives ¦ RSS

KVM port forwarding

Estimated read time: 1 minutes

This is going to be like my mysql password set post, I got tired of looking up the docs all the time, so here it is.

If you have a host running kvm instances and you want to forward the TCP port $hostport of the host machine $host to a port $guestport of the guest machine $guest, then you need:

iptables -t nat -A PREROUTING -p tcp -d $host --dport $hostport -j DNAT --to-destination $guest:$guestport

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.