After you install the packages, log out and back in so that the automatic
addition of your user to the libvirtd group is certain to be made effective.
By default, any operating system you install as a guest using KVM has access
to network services but is not visible to other machines on the network. It is
able to download software updates and browse the web, for example, but it
cannot run as a server accessible by other systems. By default, VMs receive
an IP address in the 10.0.2.0/24 range, and hosts are reachable from within a
VM by using 10.0.2.2. This should be adequate for simple uses such as testing
other operating systems, copying files back and forth using scp, or making
virtual private network (VPN) connections from a host to a guest.
BRIDGED NETWORKING
If you want to change the network settings to enable the use of a VM as an
outside-accessible server, you need bridged networking. This enables VMs
to use a physical interface to connect to the outside network, making them
appear to the rest of the network as any other typical server. Note that to do
this you must not use the default Network Manager to control the hardware
being bridged. Also, this works only with wired, not wireless, hardware.
See Chapter 18, “Networking,” if you need help understanding the
concepts mentioned here.
To start, install libcap2-bin. Next, you need to grant QEMU the ability
to administer networking by setting cap_net_admin. If you have a 64-
bit system, use the following:
Click here to view code image
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu-
system-x86_64
If you have a 32-bit system, use this:
Click here to view code image
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu
Then create a bridge interface called br0 in
/etc/network/interfaces by adding these lines to use DHCP or
your network settings if you want to configure it yourself:
Click here to view code image
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0