Marcio Cunha

How to set up a KVM network bridge for local IPs

Learn step by step how to create a bridge network interface in Linux so your KVM virtual machines receive direct IP addresses from your local physical network.

Marcio Cunha•5 min
Also available in:EspañolPortuguês
Summary
  • Standard KVM virtualization isolates guest machines behind an internal NAT invisible to the rest of the physical network.
  • Creating a bridge interface merges the host's physical network card with a shared virtual switch.
  • Virtual machines start requesting IP addresses directly from the physical router via DHCP, making external access easier.
  • Netplan or NetworkManager adjustments ensure the bridge persists and works reliably after system reboots.
  • Traffic isolation and firewall rules remain essential to protect both the host and the connected VMs.

Why your KVM virtual machines need a network bridge

When you install KVM (Kernel-based Virtual Machine, a native Linux technology that turns your operating system into a complete hypervisor), the default configuration creates an isolated internal network called NAT. In practice, this means your virtual machines can access the internet, but the rest of your local physical network cannot see them directly. They remain hidden behind the main computer, as if sitting in a secret room.

For anyone running servers at home or in a corporate environment to host services accessed by other devices, this barrier becomes quite inconvenient. The solution is to create a bridge interface, technically known as a bridge. A network bridge acts as a virtual switch, uniting your server's physical network card with a shared channel that distributes real IP addresses to all virtual machines.

Before proceeding with deep changes to your system's network layer, it is worth remembering the importance of maintaining environment security, something we discuss by detailing how to configure UFW on Linux to secure your server. With the bridge active, your VMs gain full autonomy on the local network, receiving their own IP directly from your main router and simplifying integrations such as how to configure Wake-on-LAN on Linux to turn on PC when managing remote hardware accurately.

How to plan the bridge migration on Linux

Changing how Linux handles network packets requires care to avoid losing remote access to the server during the process. If you are connected via SSH (Secure Shell, the secure protocol for accessing computers remotely via command line) and make a mistake in a network command, the connection will drop immediately, requiring physical access to the machine to fix the error.

The secret to a safe transition is temporarily disabling the default network manager and creating the bridge using modern tools like Netplan or NetworkManager, depending on your Linux distribution. The goal is to take your current physical card, for example eth0 or enp3s0, and turn it into a slave of a new virtual interface called br0.

This new br0 interface takes over the IP address that previously belonged to the physical card, ensuring the server remains accessible without interruptions. Meanwhile, KVM is configured to point to this bridge instead of the default NAT network, allowing guest systems to actively participate in your home or business local traffic.

Step-by-step guide to creating the network bridge with Netplan

If you use modern Debian or Ubuntu-based distributions, Netplan is the standard tool for managing network configurations via simple YAML text files. The first step is to find the exact name of your physical network card by running the command below in the terminal:

ip a

Locate the active interface holding your current IP address and note its name, such as enp2s0. Next, open the Netplan configuration directory and open the existing YAML file with your preferred text editor, like nano:

sudo nano /etc/netplan/01-netcfg.yaml

Modify the file contents to disable direct addressing on the physical card and create the br0 bridge structure. Replace enp2s0 with your actual card name and adjust the IP addresses according to your current local network:

network:  version: 2  renderer: networkd  ethernets:    enp2s0:      dhcp4: no  bridges:    br0:      interfaces: [enp2s0]      dhcp4: yes      parameters:        stp: true        forward-delay: 4

After saving the file, apply the new network settings safely using Netplan's test command, which automatically reverts changes if any connectivity loss occurs:

sudo netplan try

Integrating the newly created bridge into KVM and libvirt

With the br0 interface running on the main operating system, the next step is teaching KVM to use it. The virtualization management utility, called libvirt, uses XML files to define how each virtual machine connects to the outside world. You can create a temporary XML network definition file to inform the system that the new bridge is available.

Create a file named bridge-network.xml in your home folder using a text editor and insert the following structured content:

<network>  <name>br-lan</name>  <forward mode='bridge'/>  <bridge name='br0'/></network>

This small file tells KVM that any virtual machine connected to the network named br-lan must be sent directly to the br0 bridge, bypassing any NAT address translation. To register and activate this new rule in the virtualization system, run the manager control commands:

sudo virsh net-define bridge-network.xmlsudo virsh net-start br-lansudo virsh net-autostart br-lan

From this moment on, when creating or editing a virtual machine using graphical tools like virt-manager or command line instructions, simply select the br-lan network. The guest system will initialize its network stack and request an IP directly from your physical router.

Validating connectivity and troubleshooting common issues

After completing the bridge configuration and restarting the virtual machines, the ultimate test is accessing the VM terminal and checking which IP address it received. Run the IP check command inside the virtual machine and confirm if the numeric range matches your physical local network exactly:

ip a

If the virtual machine received a valid IP and can browse the internet, but other computers in your house still cannot reach it, the issue might be related to restrictive rules in the host firewall or router security policies. In some corporate environments, managed switches block extra ports when detecting multiple MAC addresses on a single physical port, requiring specific infrastructure adjustments.

Another important detail involves wireless traffic. Traditional Wi-Fi network cards generally do not support bridge mode in Linux due to wireless authentication protocol limitations. If you are trying to set up a bridge on a laptop connected via Wi-Fi, the procedure will likely fail, and using a wired connection is strictly recommended. To explore these architectural concepts further in production, see our related technical analysis on How to test open SMD inductors on board with multimeter.

Final thoughts on KVM network bridges

Setting up a network bridge in KVM radically transforms the utility of your virtual machines, eliminating artificial barriers and seamlessly integrating guest systems into your physical infrastructure. Although it requires initial attention to system configuration files and correct interface manipulation, the gain in operational flexibility widely outweighs the technical effort.

Keeping the infrastructure organized, monitoring resource consumption, and ensuring security rules remain active guarantees a stable environment ready to run file servers, databases, or complex test benches. With the network transparently configured, your VMs operate exactly as if they were independent physical computers connected to your switch or router.