Linux Galaxy

Very Basic Qemu Bridge Networking in Slackware

Posted on Feb 10, 2019 by kingbeowulf



This is a very simple bridge example to allow your qemu quest to access your host's LAN and internet, as opposed to being isolated to access only the internet via NAT (the default), for a Slackware64 14.2 host and a Windows 10 guest. Note: in this case you will need to install the Windows 10 virtio drivers, otherwise you can just use one of the standard emulated qemu NICs. Create the ACL file to allow user access to the bridge. As root create '/etc/qemu/bridge.conf' with the lines:

1allow all
2allow br0

Then set permissions:

1# chown root:users bridge.conf
2# chmod 0640 bridge.conf
3# chmod u+s /usr/libexec/qemu-bridge-helper

This last setuid is needed if you didn't already do so when you built qemu. Now you can run qemu and access the br0 interface as an unprivileged user. This is the default if you installed qemu via Slackbuilds.org. Next, configure '/etc/rc.d/rc.inet1.conf' to set up the bridge interface at each boot:

 1...
 2# Example of how to configure a bridge:
 3...
 4IFNAME[0]="br0"
 5BRNICS[0]="eth0"
 6IPADDR[0]="192.168.1.6"
 7NETMASK[0]="255.255.255.0"
 8USE_DHCP[0]=""
 9DHCP_HOSTNAME[0]=""
10...

Now, run the network script to set it all up:

1# /etc/rc.d/rc.inet1 restart

The bridge should now be set up and linked to the host eth0 interface.

1# brctl show br0
2bridge name bridge id STP enabled interfaces
3br0 8000.d8cb8a384d54 no eth0

Logout of root, and as your local user you can now run the qemu VM. For example (legacy):

1$ qemu-system-x86_64 ... -net bridge,br=br0 -net nic,model=virtio-net-pci

Alternatively (modern), use

1$ qemu-system-x86_64 ... -netdev bridge,id=hn0 -device virtio-net-pci,netdev=hn0,id=nic1

Return to blog

King Beowulf's Linux Adventures


Contact:

  • kingbeowulf@linuxgalaxy.org
  • mumble.linuxgalaxy.org:64738
  • Libera.chat IRC
    • ##slackware, #slackbuilds, #linuxgalaxy

Screamin' and a-streamin' !

  • https://twitch.tv/kngbwlf
  • https://www.youtube.com/@mylinuxgalaxy

Advertisement

Try a nice upgrade from EVGA and get a discount!

Tired of Steam, Epic and other rip-off game "stores"? Check out Humble Bundle for your digital download needs! A portion of your hard-earned gaming cash goes to charity.

King Beowulf's Humble Bundle Referral Code

Citizen Science!