A bridge network is a means to connect/bridge different networks together to act as a single network. In this case, it allows any virtual connections to the bridge network to get their own internal IPs, as if plugged into the network directly.
sudo apt install bridge-utils
Find the network device to bridge
First we need to find the network device we want to bridge to the VMs.
You'll likely have a device called something similar to enp1s0, or eth0.
Create the bridge network
This will be familiar to those who have set a static ip on linux, as it's essentially the same, with a few additional lines related to bridging
Remove interface from interfaces file
First step is to remove any references to your network device from /etc/network/interfaces, if this file is untouched there will likely be two lines at the bottom.
sudo vim /etc/network/interfaces
Create a new bridge interface
Now create a file in the /etc/network/interfaces.d/ directory, with the name of your bridge (I like br0).
auto br0 iface br0 inet static # Name the same as your file (br0) address 192.168.0.100 broadcast 192.168.0.255 netmask 255.255.255.0 gateway 192.168.0.1 # Normally your router's IP dns-nameservers 192.168.0.1 184.108.40.206 220.127.116.11 # Don't set if resolveconf is installed, comment if internet borked bridge_ports enp1s0 # Your device name bridge_stp off # Disable Spanning Tree Protocol bridge_waitport 0 # No delay before a port becomes available bridge_fd 0 # No forwarding delay (Connects to network immediately)
iface br0 inet dhcp bridge_ports enp2s0
(Optional) Create Virtual Network
To make it easier to manage with VMs, this new bridge can also be made into a Virtual Network (Basically so you can select it from a dropdown).
Create XML file
Open up a text-editor, and create a file called br0.xml, named after the bridge itself.
Enter the following, then save
<network> <name>br0</name> <forward mode="bridge"/> <bridge name="br0"/> </network>
Create the virtual network
sudo virsh net-define br0.xml
Activate, and auto-start (on boot) the new network.
sudo virsh net-start br0
sudo virsh net-autostart br0
You can now remove the br0.xml file.
Reload the network
sudo systemctl restart networking
This may claim to have failed, but if checking with ip link shows the bridge, reboot. Essentially the bridge has been brought up, and it's trying to bring it up again (and can't), then throws an error.
Check it's there
Run some checks and you should now see br0, with an IP4 address.