The simplest and more effective way I found out for me was this.
In summary, on the host:
tunctl -u <username>
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 ping your host.