dedtech.info

Information about computer technology.

Port Forwarding With QEMU

This blog post will explain how to forward ports with QEMU. The -net flag will be used to setup a network interface and user. The model rtl8139 will be used as the network interface. When the user is setup, the hostfwd variable will be used to forward two ports. Those are the ssh and http ports. This is the format of the hostfwd variable, hostfwd=tcp::hostport-:guestport. QEMU listens for connections on the host port and forwards it to the virtual machine on the guest port.

-net nic,model=rtl8139
-net user,hostfwd=tcp::2222-:22,hostfwd=tcp::8080-:80

In order to access the virtual machine via ports 2222 and 8080, a ssh client and web browser will have to be used. The two examples below show how to connect to the virtual machine.

http://localhost:8080
putty -ssh user@localhost -pw pass -P 2222

The Windows version of QEMU was used to write this blog post.

Leave a Reply

Your email address will not be published. Required fields are marked *