KVM Guest: Shared Physical Network Device With Host (bridging configuration)

A KVM virtual machine can use a shared physical network device (also known as bridging) with the host in order to access the network directly, rather than through the host as in a NAT configuration. This allows the virtual machine to have its own IP address on the network, allowing it to communicate directly with other devices on the network.

Here’s how to set up a shared physical network device (bridging) for a KVM virtual machine on an Ubuntu host:

  1. Install the required packages:
sudo apt-get install bridge-utils
  1. Edit the network interface configuration file for the physical network device that you want to use for bridging:
sudo nano /etc/network/interfaces
  1. In the configuration file, add the following lines to set up a bridge:
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_stp off
bridge_fd 0
bridge_maxwait 0

Note: Replace eth0 with the name of the physical network device that you want to use for bridging.

  1. Save the changes and close the file.
  2. Restart the networking service to apply the changes:
sudo systemctl restart networking
  1. In your KVM virtual machine configuration, set the network interface to use the bridge you created (e.g., br0). This can typically be done in the virtual machine configuration file or through the virtual machine management tool you are using (e.g., virsh or virt-manager).
  2. Start the virtual machine.

After the virtual machine is started, it should be able to access the network directly and receive its own IP address from the network’s DHCP server. You can verify this by logging into the virtual machine and using the ifconfig command to check its network configuration.

Leave a Comment