Friday, August 23, 2013

Setting up QEMU with a NAT

This is a continuation of my previous post which deals with setting up network connection for Qemu between host and guest. In this post we will learn to configure Qemu to access outside world.

There are a number of ways to configure Qemu to access internet like bridging, proxy arp, etc. In this post I will use tap device that we configured in the previous post and then make some changes to host iptables to forward the packets over the internet.

Nat
$ echo 1 > /proc/sys/net/ipv4/ip_forward
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -I FORWARD 1 -i tap0 -j ACCEPT
# iptables -I FORWARD 1 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Thats it. Verify now by pinging any of the outside connection in the guest. The simplest is,
$ ping google.com
Links
* http://tech-jnaan.blogspot.in/2013/08/configuring-qemu-tap-interface-for.html
* http://felipec.wordpress.com/2009/12/27/setting-up-qemu-with-a-nat/

No comments:

Post a Comment