Forum › Forums › Official Releases › antiX-21/22 “Grup Yorum” › CONTRIBUTION: bridge interface for kvm or virt-manager
Tagged: bridge, kvm, QEMU, Virt-Manager
- This topic has 3 replies, 2 voices, and was last updated Apr 27-5:04 pm by techore.
-
AuthorPosts
-
April 24, 2023 at 8:44 pm #105378Member
techore
A default bridge, virbr0, is created by virt-manager and the user after its initial launch or using virsh. This “default” bridge is fine for most use cases but a bridge bound to physical interface may be wanted or needed for other use cases.
This solution is but one of half-dozen solution to create a bridge, but I prefer to manage the bridge directly in /etc/network/interfaces.
1. Install package bridge-utils
2. Identify physical interface (port), eth0
3. Determine bridge name, bridge0
4. If using connman, update /etc/connman/main.conf blacklist to include eth0 and bridge0
5. Update /etc/network/interfaces to define eth0 and bridge0
6. RebootAfter reboot, virtual machines may be configured to use bridge0.
I have an install script that you may find useful as a reference. Recommend checking the git repo for updates.
git repo: https://gitlab.com/techore/antix-dwm/-/blob/main/install/inst-bridge.sh
#!/usr/bin/env bash # Location: /usr/local/src/antix-dwm/install/inst-bridge.sh # Dependency: bridge-utils # Description: update /etc/network/interfaces to create bridge # sourced by inst-virtmanager.sh # Usage: sudo inst-bridge.sh if test $EUID -gt 0; then printf "\n Must be root or using sudo!\n\n" exit 1 fi # Bridge # Using bridge instead of virbr to distinguish from virsh created bridges. read -p "Enter bridge name [bridge0]: " BRIDGE BRIDGE=${BRIDGE:-bridge0} printf "\n=========> Assign $BRIDGE as bridge name.\n\n" read -p "ENTER to continue or CTRL+c to exit." printf "\n" # Bridge port read -p "Enter bridge port name [eth0]: " BPORT BPORT=${BPORT:-eth0} printf "\n=========> Assign $BPORT as bridge port.\n\n" read -p "ENTER to continue or CTRL+c to exit." printf "\n" # Install dependency printf "\n========> Install bridge-utils for bridge support.\n\n" apt -y install bridge-utils # Backup files # Backup main.conf printf "\n========> Backup /etc/connman/main.conf.\n\n" cp /etc/connman/main.conf "/etc/connman/main.conf.$(date '+%Y%m%d%H%M').bak" ls -l /etc/connman/*.bak # Backup interfaces printf "\n========> Backup /etc/network/interfaces.\n\n" cp /etc/network/interfaces "/etc/network/interface.$(date '+%Y%m%d%H%M').bak" ls -l /etc/network/*.bak # Update /etc/connman/main.conf to blacklist bridge and bridge port printf "\n Add $BRIDGE and $BPORT to connman blacklist\n\n" # Blacklist bridge sed -i 's/^# NetworkInterfaceBlacklist/NetworkInterfaceBlacklist/' /etc/connman/main.conf if ! grep -q "^NetworkInterfaceBlacklist.*$BRIDGE" /etc/connman/main.conf; then sed -i "s/^NetworkInterfaceBlacklist = /NetworkInterfaceBlacklist = $BRIDGE,/" /etc/connman/main.conf fi # Blacklist bridge port if ! grep -q "^NetworkInterfaceBlacklist.*$BPORT" /etc/connman/main.conf; then sed -i "s/^NetworkInterfaceBlacklist = /NetworkInterfaceBlacklist = $BPORT,/" /etc/connman/main.conf fi grep NetworkInterfaceBlacklist /etc/connman/main.conf # Update /etc/network/interface printf "\n Configure $BRIDGE and $BPORT in /etc/network/interfaces\n\n" # $BPORT if ! grep -q "$BPORT" /etc/network/interfaces; then printf "\nauto $BPORT\niface $BPORT inet manual\n" >> /etc/network/interfaces else printf "\n=========> $BPORT found in /etc/network/interfaces!" printf "\n=========> Manual update for $BPORT may be needed.\n\n" fi # $BRIDGE if ! grep -q "$BRIDGE" /etc/network/interfaces; then printf "\nauto $BRIDGE\niface $BRIDGE inet dhcp\n bridge_ports $BPORT\n bridge_stp off\n bridge_fd 0\n bridge_maxwait 0\n " >> /etc/network/interfaces else printf "\n=========> $BRIDGE found in /etc/network/interfaces!" printf "\n=========> Manual update for $BRIDGE may be needed.\n\n" fi cat /etc/network/interfaces printf "\n\n=========> Done!\n\n"@olsztyn, hope this helps.
- This topic was modified 2 weeks ago by techore.
- This topic was modified 1 week, 6 days ago by techore.
- This topic was modified 1 week, 6 days ago by techore.
April 24, 2023 at 8:53 pm #105379Memberolsztyn
::@olsztyn, hope this helps.
Thank you @techore for developing this process. Greatly appreciate.
Hopefully I will find some time before my travel to Europe to implement following your guide.Live antiX Boot Options (Previously posted by Xecure):
https://antixlinuxfan.miraheze.org/wiki/Table_of_antiX_Boot_ParametersApril 24, 2023 at 10:28 pm #105386Member
techore
::and, I meant to provide the resulting /etc/network/interfaces file.
$ cat /etc/network/interfaces #------------------------------------------------------------------------------ # /etc/network/interfaces # # interfaces(5) file used by ifup(8) and ifdown(8) # Used by ceni but not by connman #------------------------------------------------------------------------------ auto lo iface lo inet loopback auto eth0 iface eth0 inet manual auto bridge0 iface bridge0 inet dhcp bridge_ports eth0 bridge_stp off bridge_fd 0 bridge_maxwait 0April 27, 2023 at 5:04 pm #105544Member
techore
::I wish that I could edit my original post..
Step 4 is updated to blacklist virtual machine nic (vnet) from connman.
4. If using connman, update /etc/connman/main.conf blacklist to include vnet, eth0, and bridge0Shell script inst-bridge.sh updated on gitlab.com
If you do not blacklist the virtual machine network interfaces, connman will attempt to manage them and creates additional default and 0.0.0.0 gateways resulting with the virtual machines working but host routing breaks.
Testing continues. I am confident there will further issues.. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.