Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to create an IPtables rule that forwards all incoming traffic on port 80 on the host to port 80 of the qemu VM?

Is such a scenario possible with qemu?

share|improve this question

Yes, actually I do this for my personal test environment (I have a public website that goes to a QEMU-KVM VM on my home PC).

Basically if the VM has network access then you're just dealing with a routing issue.

I have several fake company "departments" set up in my VM to test different types of setups, each environment gets its own subnet hanging of a particular virbr* device (virbr1 happens to be the virtual interface to the website's VM but you're interface numbering is obviously going to be different.

At that point, the you can treat it the same way you would if you were going to do a NAT to some physical machine that only the hypervisor had network access to and could reach by IP Address.

I have my internet router forward port 80's to the hypervisor and the hypervisor just NAT's port 80 to the private IP associated with the KVM:

-A PREROUTING -d -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination is the IP address of my hypervisor, is the IP address of the VM I'm running apache on.

share|improve this answer

One simple solution:

qemu --enable-kvm -boot d image.vdi -m 1000 -redir tcp:80::80 
share|improve this answer
Can you maybe add a bit of explanation to make your post more valuable to others? – Bernhard Apr 9 '13 at 19:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.