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.

I'm trying to ping from guest to my host network without success.

qemu-system-x86_64 -hda debian_squeeze_amd64_standard.qcow2 -netdev user,id=user.0 -device e1000,netdev=user.0

I try to ping a random machine:

$ ping 10.0.2.21
Destination Host Unreachable

In the guest I'm only able to ping the host 10.0.2.2 (DHCP server).

share|improve this question
    
Attach it to a tap device and attach the tap device & your network device to the bridge –  Ulrich Dangel Jun 10 '13 at 22:29
add comment

2 Answers 2

From QEMU wiki, QEMU doesn't support ICMP on the SLIRP backend.

User Networking (SLIRP)

This is the default networking backend and generally is the easiest to use. It does not require root / Administrator privileges. It has the following limitations:

  • there is a lot of overhead so the performance is poor
  • ICMP traffic does not work (so you cannot use ping within a guest)
  • the guest is not directly accessible from the host or the external network

For ICMP work you'll need use TAP, VDE or Socket.

More information: QEMU Wiki - Networking and alo the Wikibooks QEMU networking section

Recommended also: advanced guide for dealing with VLANs

share|improve this answer
    
There's a good overview on the networking options here as well: en.wikibooks.org/wiki/QEMU/Networking, and also an advanced guide for dealing with VLANs –  slm Jun 11 '13 at 2:47
    
@slm Ty. added your links in answer ;) –  Victor Aurélio Jun 11 '13 at 16:06
add comment

The simplest and more effective I found out for me was this.

In summary:

tunctl -u maiko

echo 1 > /proc/sys/net/ipv4/ip_forward
echo 1 > /proc/sys/net/ipv4/conf/wlan0/proxy_arp
echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp

ip link set tap0 up
route add -host 192.168.0.20 dev tap0   <-- to be changed by you.

and for the guest, just run it with:

kvm -hda ~/fedora.qcow2 -net nic -net tap,ifname=tap0,script=no -usb

or

qemu -hda ~/fedora.qcow2 -net nic -net tap,ifname=tap0,script=no -usb 

You just have to configure a tap device, owned by your user, enable arp proxying and configure a route between your host and guest.

The author (and myself) used that to deal with the problem of bridging to a wlan0 device, which is not supported by the Linux kernel. But it works as well with a wired connection. In the arp configuration, just change wlan0 to eth0.

The guest IP address must be set by you, as DHCP doesn't work.

And you can already pint your host.

share|improve this answer
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.