Skip to content

Instantly share code, notes, and snippets.

@gnat
Last active April 28, 2024 23:37
Show Gist options
  • Save gnat/44ca192ef145af1f30aaef9e01752655 to your computer and use it in GitHub Desktop.
Save gnat/44ca192ef145af1f30aaef9e01752655 to your computer and use it in GitHub Desktop.
VM Notes

Sane, modern setup

Bridge is a waste of time: Use the successor macvtap / macvlan "Direct Connect". The only downside is you cannot see the vm host from a vm.

Cockpit Setup for VM Host.

  1. Download your ubuntu iso and copy to /opt/. Cockpit will error if it's in your /home/.
  2. sudo apt install cockpit cockpit-machines
  3. Want to use Direct Attachment? (no bridge)
    • Prevent bridge device creation on startup. (Auto-generated by virsh)
      • virsh net-destroy default
      • virsh net-undefine default
    • Direct Attachment has best performance: Downside is host machine and VM's cannot see each other on LAN.
      • This is okay anyway for security.
      • Host machine can still use VM tools for access.
  4. Cockpit: localhost:9090
  5. ⚠️ Remember to use your firewall to block 9090!
  6. Virtual Machines ➡️ Create VM ➡️ Immediately Start VM: OFF
  7. Click on VM. ➡️ Delete default network interface. ➡️ Add networking interface. ➡️ Direct Attachment. ➡️ Source main device. ➡️ Add.
  8. Install.

Recommended Cockpit Add-ons

  • Navigator
    • wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.10/cockpit-navigator_0.5.10-1focal_all.deb
    • sudo apt install ./cockpit-navigator_0.5.10-1focal_all.deb
  • sudo apt install cockpit-podman

Legacy Notes

https://www.youtube.com/watch?v=6435eNKpyYw

  • Bridge is just a virtual switch.
  • Bridge becomes the new main interface.
  • All VM's and the host itself use the Bridge.

Auto Setup Using systemd

  • sudo su
  • cd /etc/systemd/network/
  • nano br.netdev
[NetDev]
Name=br0
Kind=bridge
  • nano 1-br0-bind.network
[Match]
Name=en*
[Network]
Bridge=br0
  • nano 2-br0-dhcp.network
[Match]
Name=br0
[Network]
DHCP=ipv4
  • systemctl enable systemd-networkd --now
  • ip link set eno1 down
  • ip a
  • journalctl -f -u systemd-networkd

For netplan: https://github.com/canonical/netplan/blob/main/examples/bridge.yaml

Random Notes

General ip command notes.

* Add a device: `ip link add ...`
* Remove a device: `ip link delete dev ...`
* Set ipv4 address for device: `ip -4 address add x.x.x.x/32 dev ...`

Backing up KVM data.

* /var/lib/libvirt/qemu/snapshot
* /var/lib/libvirt/images

Not cockpit, such as virt-manager or other kvm thing

* Bridge Network
	1. sudo ip link add name br0 type bridge
	2. sudo ip link set dev br0 up
	3. sudo ip link set eno1 master br0; sudo dhclient br0
* VM Manager
	* sudo apt install virt-manager
	* sudo ip link del name virbr0
		* Removes default virt-manager bridge (uses 192...)
* Survive Reboot
	* systemd: https://wiki.archlinux.org/title/Systemd-networkd#Bridge_interface
	* Or, put the above in a startup script.
* Notes
	* https://wiki.archlinux.org/title/network_bridge
	* https://man7.org/linux/man-pages/man8/ip-link.8.html
* Remove
	* sudo ip link set dev eno1 nomaster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment