[Libvir] Port forwarding

Richard W.M. Jones rjones at redhat.com
Tue Dec 4 12:08:15 UTC 2007


What do people think about adding port forwarding to network configurations?

At the moment it's unnecessarily difficult to connect to (eg.) sshd port 
or remote desktop port on a virtual machine running under the virtual 
network configuration.  If those ports could be mapped to consecutive 
ports on the public (eth0) interface then connecting would be simply a 
matter of knowing the port number.

AFAICS this could be implemented by adding rules such as these to the 
iptables:

iptables -t nat -A PREROUTING -i $EXTIF -p tcp --dport 80 \
   -j DNAT --to-destination 192.168.122.5
iptables -A FORWARD -i $EXTIF -p tcp --dport 80 -j ACCEPT
iptables -t nat -A PREROUTING -i $INTIF -p tcp -d $EXTIP --dport 80 \
   -j DNAT --to-destination 192.168.122.5
iptables -A FORWARD -i $INTIF -p tcp -d $EXTIP --dport 80 -j ACCEPT

(rules taken from 
http://www.ma.utexas.edu/users/stirling/computergeek/server.html)

Rich.

PS. I'm assuming that this is _not_ what the current /network/forward 
XML does?  It seems to enable forwarding for a single privileged guest 
as far as I can work out.

-- 
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3237 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20071204/1f2f891d/attachment-0001.bin>


More information about the libvir-list mailing list