Title: Configure network options
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Currently libvirt (another name for KVM) does not support bridged networking over wifi.  A bridged network allows a virtual machine to have an IP address on the same physical lan as the host computer.  This is desirable when virtual machines need to boot from a PXE server or they need to have a presence on the physical network.

By default libvirt provides a Network Address Translation (NAT) network which is virtualized in the kernel and uses the host's physical networks.  A nat network will function correctly over host wifi connections, and a DHCP server will provide IP addresses for virtual machines.  This is ideal for laptops using wifi connections.

For either type of networking, IP forwarding needs to be allowed.

sed -i 's/^\(net.ipv4.ip_forward =\).*/\1 1/' /etc/sysctl.conf

sysctl -p

If using a nat network, the system is completely configured.  If a bridged network is desired, run the following commands.

yum uninstall NetworkManager

service network restart
cp -p /etc/sysconfig/network-scripts/ifcfg-{eth0,br0}
sed -i '/HWADDR/d;/UUID/d;s/eth0/br0/;s/Ethernet/Bridge/' \
/etc/sysconfig/network-scripts/ifcfg-br0
echo DELAY=0 >> /etc/sy*/net*s/ifcfg-br0
echo 'BOOTPROTO="none"' >> /etc/sy*/net*s/ifcfg-eth0
echo BRIDGE=br0 >> /etc/sy*/net*s/ifcfg-eth0
service network restart
brctl show

The last two commands should not have any errors and show that br0 exists.

virsh net-destroy default

virsh net-undefine default
service libvirtd restart
virsh net-list

The last command should show that there is one network, named default.