1

I am running Gentoo Linux on an AMD64 laptop, and I am having an extremely hard time setting up host networking on KVM. I alreay have KVM, libvirtd, virt-manager, the kernel modules required to get virtualization working, and I already rebuilt my kernel with new configuration options according to this guide here, and I still cannot seem to be able to get host networking running.

I am able to create a VM using virt-manager, but I am unable to choose a network interface to connect my VM to, on virt-manager's final dialog under Advanced options, all the options on the drop-down box are disabled except "No networking" and "Specify shared device name". I cannot use bridge networking because my internet exit is through a wi-fi NIC.

I still can't get networking on KVM running. I do not want to use Oracle VM VirtualBox because I had a lot of problems with it in the past. Did I miss something?

0

I use a simple script to setup my qemu devices in a private bridge (without the internet exit) and masquerade the traffic on the host:

/usr/sbin/brctl addbr qemu1
NET=10.116.64 # any private address you like
GW=1
BASE=0
MASK=24
ip addr add $NET.$GW/$MASK dev qemu1
ip link set qemu1 up
if iptables -t nat -L POSTROUTING -n | grep ^MASQUERADE | awk '{print $4}' | cut -d/ -f1 | grep "$NET.$BASE" >/dev/null
then
  echo "IP masquerading already set up"
else
  echo "Setting up IP masquerading"
  iptables -t nat -A POSTROUTING -s "$NET.$BASE"/"$MASK" \! -d "$NET.$BASE"/"$MASK" -j MASQUERADE
fi
sysctl net.ipv4.ip_forward=1
exit 0

To setup for each machine I use another simple script use USER for the user who starts the vm

#!/bin/sh
BRCTL=/usr/sbin/brctl
regif=$($BRCTL show $2|awk '/^\t/ { print $1; }' |grep "$1")
if [ x"$3" = "xstop" ]
then if [ x"$regif" != "x" ]
then
        ip link set $1 down
        /usr/sbin/openvpn --rmtun --dev $1
fi
elif [ x"$regif" = "x" ]
then
        /usr/sbin/openvpn --mktun --dev $1 --user USER
        ip link set $1 promisc on
        ip link set $1 up
        $BRCTL addif $2 $1
elif [ x"$3" = "xrestart" ]
then
        $0 $1 $2 stop # recursive call
        $0 $1 $2 # recursive call
fi
exit 0

called as qemu-newif NAME_FOR_THE_TAP_DEVICE qemu1 to setup a tap device for each machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.