본문 바로가기

Programming

QEMU NAT configuration

Solution

The simplest approach is to use a NAT. Here are the steps:

As root in the host, create and setup your tap0 device (192.168.100.0 will be our NAT network, and felipec our user):
tunctl -u [root 등 사용자명] -t tap0
ifconfig tap0 192.168.100.1 up

Update: You need to run your guest like this:
qemu-kvm -hda winxp.cow -m 512 -net nic -net tap,ifname=tap0,script=no

In your guest:
ip addr: 192.168.100.2
gateway: 192.168.100.1
dns: 8.8.8.8

note: I found some problems on my Windows XP guest; I had to disable the firewall
note: I’m using Google’s DNS, if you want to use the one in your host check /etc/resolv.conf

NAT

As root in the host:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o [eth0 과 같은 host 네트워크 인터페이스명] -j MASQUERADE
iptables -I FORWARD 1 -i tap0 -j ACCEPT
iptables -I FORWARD 1 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT

That’s it. Now you should be able to use ping back-and-forth between the guest and the host, and both should be able to access the Internet :)



qemu port forwarding 설정

-redir tcp:22:10.0.2.15:22

'Programming' 카테고리의 다른 글

Preemptive kernel vs Non-preemptive kernel  (0) 2013.10.14
Linux kernel memory allocation  (0) 2013.09.25
Windows PE Structure  (0) 2013.09.12
Linux vmarea structure  (0) 2013.09.11
IDA FLIRT Symbol Recovery  (0) 2013.09.10