X86 build in KVM - Help with bridging

I have installed Ubuntu Server 24.04 onto my old hp compaq 8000 elite with an E5500 cpu, 8gb of memory, a 120gb main ssd. The machine has the motherboard gigabit ethernet port along with an expansion intel gigabit ethernet card. The expansion gigabit card has an id enp16s0. The motherboard ethernet port has an id of enp0s25. I want to run this in parallel with my existing network until I get it configured and tested. I have also installed Tailscale and OpenSSH and am currently doing most of this configuration from my remote office via ssh and tailscale.

Everything is going well until it isn't.

I installed OpenWRT in KVM on this machine. My ISP modem has an IP of 192.168.100.1 so I reserved that IP and my current wireless routers are at 192.168.1.1 and 192.168.1.254 so let's reserve those IPs as well. I was thinking I should have OpenWRT LAN be serving to 192.168.10.X as its pool.

After watching a few videos it all looked easy - So I asked ChatGPT and MS Copilot... This setup seems to be close to working. But the pc on the LAN can't see the internet.

Here is my current /etc/netplan/50-cloud-init.yaml file:
network:
version: 2
renderer: networkd
ethernets:
# Management NIC for SSH/Tailscale
enp0s25:
dhcp4: false
addresses: [192.168.1.190/24]
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]

# Physical NIC for LAN (laptop plugged here)
enp16s0:
  dhcp4: false

bridges:
# WAN bridge (purely virtual, VM NIC attaches here)
br-wan:
dhcp4: false
interfaces:

# LAN bridge (includes physical NIC enp16s0)
br-lan:
  dhcp4: false
  interfaces: [enp16s0]

And here is my current install command:

virt-install
--name OpenWRT
--os-variant ubuntu24.04
--ram 1024
--vcpus 1
--disk path=/var/lib/libvirt/images/OpenWRT/openwrt.qcow2,format=qcow2,bus=virtio
--import
--network bridge=br-wan,model=virtio,mac=52:54:00:aa:bb:01
--network bridge=br-lan,model=virtio,mac=52:54:00:aa:bb:02
--graphics none
--console pty,target_type=serial
--noautoconsole

For troubleshooting here is the results of brctl show =
bridge name bridge id STP enabled interfaces
br-lan 8000.b6bcb4ef5fa4 no vnet1
br-wan 8000.36befac6557d no vnet0
br0 8000.8e5e32b25d8e no enp16s0

I am remote currently via tailscale. I have a laptop plugged into the lan port on the OpenWRT machine and it is connected via wifi to the original network. But it is also connected via the LAN and not getting a working ip. (169.254.xxx.xxx)

Chat has sent me back and forth with various netplan.yaml files but nothing seems to be the answer.

Any answers or links to anything similar would be so appreciated.

Are you asking for KVM support?
Certainly 1st network card in the order of command line will be LAN with DHCP server, so swap the connections.

Thanks for the reply. I have to admit - I am in way over my skill set. It looked easy on youtube. I thought it was a great thing to ask ChatGPT about and here I am.

I can't find any other real mentions of building a netplan.yaml so I think I am just complicating it. I think the kvm is starting up fine and I can reach the OpenWRT console etc.

But - I really don't know much else.

Start with getting some admin GUI like gnome boxes or virt manager. As you noticed current system is far from being useful.

I am putting this here for those that follow - and especially me for when I forget how I finally got it working:

I continued on pressing AI for answers and troubleshooting. Today leaning on Gemini AI. I finally got it working. My layman’s commentary along with Gemini’s work follows:

So - the expansion card NIC you want inside the VM and owned by it completely. The second issue was OpenWRT was grabbing the expansion card by default as the WAN NIC.

So first – to hand over the expansion card nic to the VM
In Ubuntu you start in Grub
sudo nano /etc/default/grub

Modify the GRUB_CMDLINE_LINUX_DEFAULT Line:
for Intel: Add intel_iommu=on
for AMD: Add amd_iommu=on
For me I changed my line to:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash intel_iommu=on"

Then update the changes
sudo update-grub
And reboot

Verify IOMMU is Active: After rebooting, check for IOMMU groups:
dmesg | grep -i iommu

and reading through there – it says “iommu enabled” = Success!

Next build a netplan.yaml file -
sudo /etc/netplan/netplan_config.yaml

for me with my motherboard nic named enp0s25 and my current default gateway and desired static ip my file became:

network:
  version: 2
  ethernets:
    enp0s25:
      dhcp4: false
      addresses: [192.168.1.190/24]
      routes:
        - to: default
          via: 192.168.1.1 # Gateway (Main Router)
      nameservers:
        addresses: [1.1.1.1, 8.8.8.8]

Save changes
Correct the permissions of the file
sudo chmod 600 /etc/netplan/netplan_config.yaml

Try the new netplan
sudo netplan try
If you get no errors you are safe to accept the changes or if you time out you can

Apply the new netplan:
sudo netplan apply

Revised virt-install Command

The VM now needs two network connections:

WAN Connection (Virtual): Use the existing network=default (NAT-based) provided by libvirt. This allows the VM to access the host's internet connection (enp0s25) and therefore reach the internet for its WAN duties (like pinging 8.8.8.8).

LAN Connection (Physical Passthrough): Use the --host-device flag to pass enp16s0 directly to the VM. This will be the VM's LAN port, managing your physical LAN traffic.

To passthrough the device you will need to find the PCI address. Replace enp16s0 with the device id of your adapter you want to passthrough. So in the host run:
realpath /sys/class/net/enp16s0/device

For me it returned:
/sys/devices/pci0000:00/0000:00:1c.4/0000:10:00.0

The last piece of the results from this command – is my pci address of my expansion card or ‘10:00.0’

Put your results in the “—host-device….” declaration below.

Revised virt-install Command:

virt-install \
  --name OpenWRT \
  --os-variant ubuntu24.04 \
  --ram 1024 \
  --vcpus 1 \
  --disk path=/var/lib/libvirt/images/OpenWRT/openwrt.qcow2,format=qcow2,bus=virtio \
  --import \
  --network network=default,model=virtio \
  --host-device=10:00.0 \
  --graphics none \
  --noautoconsole

But again I got errors when trying to virsh-install:

ERROR internal error: process exited while connecting to monitor: 2025-12-04T18:56:19.348605Z qemu-system-x86_64: -device {"driver":"vfio-pci","host":"0000:10:00.0","id":"hostdev0","bus":"pci.16","addr":"0x1"}: vfio 0000:10:00.0: failed to setup container for group 7: Failed to set iommu for container: Operation not permitted

So – Gemini AI says:
Your hardware/BIOS does not support Interrupt Remapping, which is a crucial security feature required by the VFIO (Virtual Function I/O) driver for safe device assignment. Without it, the kernel prevents the operation because allowing the device access could potentially allow the VM to interfere with other devices or the host system (hence, "unsafe interrupts").

The Solution: Allow Unsafe Interrupts

You need to create a configuration file that loads the vfio_iommu_type1 kernel module with the required parameter.

-Create a new configuration file for the VFIO modules
sudo nano /etc/modprobe.d/vfio.conf

Add the following line to the file:
options vfio_iommu_type1 allow_unsafe_interrupts=1

That is the only line in the file.
Save and close the file.

Reload the Initial Ramdisk and Reboot

sudo update-initramfs -u -k all

Reboot the system for the changes to take effect:

Re-run virt-install

At this point the VM is up and running and I can reach the OpenWRT console but still can not ping 8.8.8.8 from the console or update opkg.

Gemini says - Your current OpenWrt network configuration has the roles of your two NICs completely swapped. The solution is to edit the /etc/config/network file inside the OpenWRT console

sudo virsh console OpenWRT

First thing to do is set a password for OpenWRT
passwd

After that edit the /etc/config/network file with vi.
vi /etc/config/network

  • Just a couple of reminders if you don't use vi often:*
    i = insert
    esc = to accept changes and get to command
    :q! = quit without saving
    :wq = save and quit

Find the config device 'lan_dev' section and modify the config interface 'lan' and config interface 'wan' sections to match the desired mapping:

So my new file became:

config interface 'loopback'
	option device 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

config globals 'globals'
	option ula_prefix 'fd79:a557:f5sd::/48'

config device
	option name 'br-lan'
	option type 'bridge'
	list ports 'eth1'  #<--- I changed per note below

config interface 'lan'
    # Change 'br-lan' to use 'eth1' as the physical LAN device.
    # Note: If your OpenWrt image uses a 'config device' section for br-lan, 
    # make sure it lists 'eth1' (or whatever eth# is the passthrough)
    option device 'eth1' # <--- Set the physical Passthrough NIC as LAN
    option proto 'static'
    option ipaddr '192.168.10.1'
    option netmask '255.255.255.0'

config interface 'wan'
    # Set the virtual NAT NIC (eth0) as the WAN device.
    option device 'eth0' # <--- Set the Virtual NIC as WAN
    option proto 'dhcp'  # <--- Essential for getting IP from libvirt NAT
    option defaultroute '1'
    option peerdns '1'

config interface 'wan6'
	option device 'eth1'
	option proto 'dhcpv6'

save changes (esc : wq )
Then restart the network
/etc/init.d/network restart

I Tested Internet Connectivity:

   ping 8.8.8.8
   opkg update

All worked fine!! I hope this helps!!

Preamble - If you are here looking for steps I took before I got to my stumbling block - here are my install notes up to that point:

I have installed Ubuntu Server 24.04 onto my old hp compaq with an E5500 cpu, 8gb of memory, a 120gb main ssd. The machine has the motherboard gigabit ethernet port along with an expansion intel gigabit ethernet card. The expansion gigabit card has an id enp16s0. The motherboard ethernet port has an id of enp0s25 and an ip of 192.168.1.190. I want to run this in parallel with my existing network until I get it configured and tested. I have also installed Tailscale and OpenSSH and am currently doing this configuration from my remote office via ssh and tailscale. Caution must be taken when building the bridge since I can not lose connection and complete another command so we will have to wrap those commands into a script. I want to have this pc configured as a tailscale exit node when called upon as well. I would like to install OpenWRT in KVM on this machine. From the lan port I will go to a switch - I will connect via cat 5 to my 2 other wireless routers - later - and at that time they will have to be put in ap or bridge mode. But for testing we are ignoring all that for the moment. My ISP modem has an IP of 192.168.100.1 so let's reserve that IP. My current wireless routers are at 192.168.1.1 and 192.168.1.254 so let's reserve those IPs as well. I was thinking we should have OpenWRT LAN be serving to 192.168.10.X as its pool.

In bios - enable virtualization.

Starting with PC booting Ubuntu server v Ubuntu 24.04.3 LTS

sudo apt update

Install all the KVM and other necessary parts
sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager

sudo usermod -aG libvirt,$USER

newgrp libvirt

virsh list --all # should show no VMs yet, but no error

Let’s make a directory for the images:
mkdir -p ~/openwrt-images

Then move to that directory
cd ~/openwrt-images

Download the OpenWrt ext4 image – my pc is BIOS not UEFI based so chose accordingly.

wget https://downloads.openwrt.org/releases/24.10.4/targets/x86/64/openwrt-24.10.4-x86-64-generic-ext4-combined.img.gz

Unzip the file
gunzip openwrt-24.10.4-x86-64-generic-ext4-combined.img.gz

It replies – with something – but “trailing garbage” is fine.…

Resize the image to 1GB since we have the room
qemu-img resize openwrt-24.10.4-x86-64-generic-ext4-combined.img.gz 1G

Simplify the name
mv mv openwrt-24.10.4-x86-64-generic-ext4-combined.img openwrt-kvm.img

Convert the raw img to a qcow format
qemu-img convert -f raw -O qcow2 openwrt-kvm.img openwrt.qcow2

And from there you should be able to continue on with my previous post. Good Luck!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.