Netplan is the default network configuration tool on Ubuntu 24.04, sitting as a front-end that generates configuration for either Network Manager or systemd-networkd as its backend renderer. For KVM hosts running Ubuntu, Netplan provides a clean YAML-based approach to setting up bridge interfaces. This guide walks through creating a bridge with Netplan on Ubuntu 24.04, configuring it with static and DHCP addressing, and attaching KVM virtual machines to the bridge.
Prerequisites
- Ubuntu 24.04 Server or Desktop with KVM installed
- Root or sudo access
- Physical Ethernet interface available (e.g.,
enp3s0) - Console or out-of-band access recommended for remote servers
Step 1 – Identify Your Network Interface
Before writing any configuration, confirm the name of your physical network interface.
ip link show
Look for the Ethernet interface – it will be something like enp3s0, ens18, or eth0 depending on your hardware and firmware. Also check the current Netplan configuration.
ls /etc/netplan/
You will likely see a file like 01-netcfg.yaml or 50-cloud-init.yaml. Back it up before making changes.
sudo cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.bak
Step 2 – Configure Bridge with Static IP
Edit your Netplan configuration file to define the bridge. Replace the existing content with the following, adjusting the interface name and IP settings to match your environment.
sudo nano /etc/netplan/01-netcfg.yaml
Add this configuration.
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: false
dhcp6: false
bridges:
br0:
interfaces:
- enp3s0
addresses:
- 192.168.1.100/24
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
search:
- example.com
parameters:
stp: false
forward-delay: 0
Key points about this configuration:
- The
ethernetssection disables DHCP on the physical interface since the bridge takes ownership of it - The
bridgessection createsbr0withenp3s0as a member - Static IP, gateway, and DNS are all assigned to the bridge, not the physical interface
- STP is disabled and forward-delay set to 0 for faster convergence in simple topologies
Step 3 – Alternative DHCP Configuration
If you prefer DHCP on the bridge (useful for lab environments), use this configuration instead.
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: false
dhcp6: false
bridges:
br0:
interfaces:
- enp3s0
dhcp4: true
parameters:
stp: false
forward-delay: 0
With DHCP, the bridge will request an IP address from your network’s DHCP server at boot time.
Step 4 – Validate and Apply the Configuration
Before applying, check the YAML syntax. Netplan is strict about indentation – use spaces, never tabs.
sudo netplan generate
If there are no errors, do a trial run that will automatically revert after 120 seconds if you lose connectivity.
sudo netplan try
If the network works and you can confirm (press Enter to accept), the changes become permanent. This is a lifesaver when configuring remote servers – if you mess something up, the old config comes back automatically.
Once you have confirmed the configuration works, apply it permanently.
sudo netplan apply
Step 5 – Verify the Bridge
Run through the standard checks to confirm the bridge is functioning correctly.
Check that the bridge interface exists and has the correct IP.
ip addr show br0
Expected output:
5: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
inet 192.168.1.100/24 brd 192.168.1.255 scope global br0
Confirm the physical interface is a bridge member.
bridge link show
Test connectivity.
ping -c 3 192.168.1.1
ping -c 3 google.com
Check the routing table.
ip route show
You should see the default route going through br0.
Step 6 – Attach a VM to the Bridge with virsh
When creating a new VM, specify the bridge directly with virt-install.
virt-install \
--name ubuntu-vm \
--ram 2048 \
--vcpus 2 \
--disk size=20 \
--os-variant ubuntu24.04 \
--network bridge=br0,model=virtio \
--cdrom /var/lib/libvirt/images/ubuntu-24.04.iso
For an existing VM, use virsh to attach a new bridge-based interface or modify the existing one.
To attach a new interface on-the-fly.
virsh attach-interface --domain ubuntu-vm --type bridge --source br0 --model virtio --persistent
To edit the VM XML directly and change the existing interface.
virsh edit ubuntu-vm
Locate the <interface> block and update it.
<interface type='bridge'>
<source bridge='br0'/>
<model type='virtio'/>
</interface>
Restart the VM for changes to take effect.
virsh shutdown ubuntu-vm
virsh start ubuntu-vm
Verify the VM got an IP from the physical network.
virsh domifaddr ubuntu-vm
Common Netplan Mistakes to Avoid
- Using tabs instead of spaces – YAML requires spaces for indentation
- Assigning an IP to both the physical interface and the bridge – only the bridge should have an address
- Forgetting to disable DHCP on the physical interface when using static IP on the bridge
- Leaving the old Netplan file in place alongside a new one – conflicting files cause unpredictable results
Summary
Netplan makes bridge configuration on Ubuntu 24.04 clean and readable. The YAML format is straightforward – define the physical interface, create a bridge, assign the physical interface as a member, and configure IP settings on the bridge. Using netplan try before committing changes gives you a safety net that automatically reverts bad configurations. Once the bridge is active, VMs connected to it appear on the same network as the host, making them directly accessible from other machines without NAT or port forwarding.






























































