How To Setup Bridge Network in QEMU/KVM

 

Unlocking Seamless Networking: A Guide to Setting up Bridge Connections in QEMU/KVM

 

Closing the gap between virtual machines (VMs) and the physical network is crucial in the world of virtualization. You've made a wise decision if you're running your virtual environments with QEMU/KVM. For Linux virtualization, QEMU/KVM is a strong and adaptable platform that gives you unparalleled control over your virtual machines. Also, you must set up a bridge connection in order to take full advantage of its features and allow your VMs to communicate with the external networks (The internet).

This blog will give you clear, detailed instructions and best practices for setting up bridge connections, regardless of your level of experience with virtualization or whether you're just dipping your toes into the world of QEMU/KVM. With our in-depth guide, get ready to unlock a new level of networking freedom and maximize the potential of your virtual machines.


What is bridge network

In the context of computer networking, a bridge network acts as a device or software element that joins two or more network segments or LANs. Filtering and forwarding network traffic between these parts is a bridge's main purpose. Usually, bridges look at the MAC (Media Access Control) addresses of packets to determine whether they should be forwarded or filtered out at the data connection layer (Layer 2 of the OSI model, same as Switches).

Bridges assist in segmenting and managing network traffic in this way, which can enhance network security and performance. They are frequently used to establish virtual LANs (VLANs) for logical network segmentation within a single physical network or to connect various physical LANs, such as cable and wireless networks.


How bridge network work in QEMU/KVM

A bridge connection is a crucial networking element used to give virtual machines (VMs) access to the external network in the context of KVM (Kernel-based Virtual Machine). A type-1 hypervisor called KVM enables you to construct and control many virtual machines (VMs) on a single physical host. In essence, a bridge connection on KVM serves as a link between these VMs' virtual network adapters and the host's actual network interface. As a result, virtual machines (VMs) can interact with external networks' devices and resources, exactly like physical machines. 

The KVM hypervisor configures and maintains the bridge connection, ensuring that each VM has its own distinct existence on the network and upholding network isolation and security. The ability for virtual machines (VMs) to effortlessly connect to and communicate with the larger network infrastructure is essential for the effective operation of virtualized environments, and a bridge connection on KVM is a core networking component that plays a crucial part in this process.


Step-By-Step guide: how to set up Bridge Network in QEMU/KVM

Setting up Bridge Network in QEMU/KVM involves several steps, including installing QEMU/KVM, connect the Host machine to the internet using wired connection (Ethernet connection, because Bridge network in QEMU/KVM doesn't work with wireless connection), nmtui Text user interface for controlling Network Manager (already installed on most Linux distros), Then connect a VM to the Bridge Network to check the internet connection of the Bridge Network. The process can look complex, but following a step-by-step guide will simplify the task.


Here is a brief overview of the steps required to set up a Bridge Network:

  1. Install QEMU/KVM, if you want to learn how to install it, visit my blog How to install QEMU/KVM on Debian based Distros,

  2. Connect Host machine to Router using Ethernet cable.

  3. Use nmtui utility to create a new Bridge Network, Then assign the Ethernet connection to it as (Slave connection).

  4.  Use any Virtual Machine on QEMU/KVM to check the Bridge Network connection, In this blog I will use Windows 10, if you want to learn how to set up Windows Virtual Machine on QEMU/KVM, Visit my blog Here.


Step-1 : Run nmtui utility to create new Bridge Network 

Open your terminal, type this command:

nmtui












 

nmtui Interface will open, it looks like this :













 

Step-2 : Start setting up the Bridge Network using nmtui utility

Deactivate wired connection to be able to assign it to the Bridge Network later in the steps, this is done by :

Navigate using arrows to Activate a connection option, then press Enter :











 

 

Choose Your Ethernet connection (at my end it's named as Ethernet connection 1), then navigate using arrows to Deactivate up on the right up corner, then press Enter : 










 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Press Esc to go back to the Main Window, navigate up using arrows to Edit connection option, then press Enter :










 

 

 

 Navigate using arrows to Add option on the right up corner, then press Enter










 

 

 

Navigate down using arrows to Bridge, then press Enter :  












 

Now, change the Bridge Name, then navigate using arrows to Add option and press Enter :











 

 

Now, choose Ethernet and press Enter :













Leave every thing as Default, then navigate using arrows to Ok on the right down corner and press Enter :










 

 


Also, Leave every thing as Default, then navigate using arrows to Ok in the right down corner and press Enter











 


Delete the Old Ethernet connection by choose it, then navigate using arrows to Delete option in the right sidebar, then press Enter













Now, you will be prompted with Delete Confirmation Pop-up, choose Delete, then press Enter :













Press Esc to go back, then navigate using arrows to Activate a connection option, then press Enter













Navigate to the Bridge connection (New Bridge), you will see <Deactivate> option in the right up corner, that means it's Active, Now press Esc multiple times to back to the terminal :













Open Virtual Machine Manager, choose your Virtual Machine, Click on Open (In the Left up corner) : 














Click on the ! Sign in the left up corner, Or choose Details from View Option in tools bar :














Choose NIC option from the right sidebar : 














Change Network source to Bridge option :













 

You need to enter the New Bridge Network (Adapter) Name, if you forgot its name, you can use this command on the terminal to get the Active Bridges and Their names :

brctl show












Now, add the New Bridge Name to Device name box in Virtual Machine Manager, then click on Apply on the right down corner :












 

 

Refresh your network adapters, by restart Network Manager using this command  : 

sudo systemctl restart NetworkManager


 

 

 

 

 

 

 

 

 

 

 

In your Toolbar, the Network Adapter Sign will look like this: 



The following screenshots show the Virtual Machine connected to the internet :

(Note: You must wait for a couple of minutes before the Bridge Network be activated)











 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Conclusion

In a world where networking can be as tangled as a plate of spaghetti, a bridge connection in KVM is like the ultimate untangler, it straightens things out with virtual finesse! Your virtual machines become the network's cool party crashers, effortlessly mingling with the physical crowd. They don't just knock on the door; they strut right in and join the conversation. No more virtual wallflowers, these VMs know how to socialize! So, if you're tired of your VMs feeling like they're stuck in a digital bubble, set up a bridge connection in KVM and watch them become the life of the virtual party. It's networking, but with a touch of virtual swagger! πŸŽ‰πŸ•ΊπŸ’»







Comments