To configure a network bridge for virtual machines on Ubuntu, you can follow these steps:
- Install the bridge-utils package:sudo apt-get update
sudo apt-get install bridge-utils
- Open the /etc/network/interfaces file using a text editor:sudo nano /etc/network/interfaces
- Comment out any existing network configuration settings for the interface that will be used for the bridge. For example, if your interface is eth0, comment out any lines that start with "auto eth0", "iface eth0", "address", "netmask", and "gateway".
- Add the following lines to the end of the file to configure the bridge:auto br0
iface br0 inet dhcp
The "auto br0" line specifies that the bridge should be brought up automatically at boot time.The "iface br0 inet dhcp" line specifies that the bridge should get its IP address via DHCP.The "bridge_ports eth0" line specifies that the physical interface eth0 should be bridged.The "bridge_stp off" line disables the Spanning Tree Protocol (STP) for the bridge.The "bridge_fd 0" line specifies that the bridge should forward packets immediately, with no delay.
- Save and close the file.
- Restart the networking service to apply the changes:sudo systemctl restart networking
- Configure your virtual machine to use the bridge interface.
That's it! Your virtual machines should now be able to connect to the network through the bridge interface.