Simple port forwarding

In case someone else is looking for a way that actually works. Though @HorsePunchKid is right in his suggestion, I've found this walkthrough that fills in the missing steps:

http://www.debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/

In essence:

Enable IP Forwarding:

sysctl net.ipv4.ip_forward=1

Add your forwarding rule (use n.n.n.n:port):

iptables -t nat -A PREROUTING -p tcp -d 10.0.0.132 --dport 29418 -j DNAT --to-destination 10.0.0.133:29418

Ask IPtables to Masquerade:

iptables -t nat -A POSTROUTING -j MASQUERADE

And that's it! It worked for me in any case :)


If anyone searching for a temporary method, try the below solution.

    ssh -L 192.168.0.10:8080:10.0.0.10:80 [email protected]

The above command redirects all connections to the port 8080 on your base machine to 80 port of your virtual machine. You can test the working by accessing the web page http://192.168.0.10:8080, and it'll show you the web page on guest machine.

This applies to all ports :)