Take the 2-minute tour ×
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.

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
add comment

2 Answers

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 192.168.1.9/32 -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination 10.0.1.9:80

192.168.1.9 is the IP address of my hypervisor, 10.0.1.9 is the IP address of the VM I'm running apache on.

share|improve this answer
add comment

One simple solution:

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

Your Answer

 
discard

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.