From 9a04ca03a395855de7c61bbb979bcca4cdec97e5 Mon Sep 17 00:00:00 2001 From: Fabrice Bellamy <12b@distrilab.fr> Date: Fri, 13 Dec 2024 10:49:36 +0100 Subject: [PATCH] add documentation for running VM with bridged network in NAT mode --- how-to-run-a-vm-with-nat-bridged-network.md | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 how-to-run-a-vm-with-nat-bridged-network.md diff --git a/how-to-run-a-vm-with-nat-bridged-network.md b/how-to-run-a-vm-with-nat-bridged-network.md new file mode 100644 index 0000000..cd331da --- /dev/null +++ b/how-to-run-a-vm-with-nat-bridged-network.md @@ -0,0 +1,47 @@ +create a bridge configuration file, /tmp/virbro.xml : +```xml + + default + 9014424a-8422-40ec-94d1-9f593b98cb7a + + + + + + + + + +``` + +apply bridge configuration : +```sh +virsh net-define /tmp/virbr0.xml +virsh net-start virbr0 +``` + +optionnaly, make it to auto start : +```sh +virsh net-autostart virbr0 +``` + + +copy the VM start script +```sh +cp /nix/store/iim2hsbfj7kbxfygn741ica52fka6xk3-nixos-vm/bin/run-hedgedoc-vm ./run-vm-2 +``` + +change network options : +```sh +< -net nic,netdev=user.0,model=virtio -netdev user,id=user.0,"$QEMU_NET_OPTS" \ +--- +> -net nic,netdev=user.0,model=virtio -netdev bridge,br=virbr0,id=user.0,"$QEMU_NET_OPTS" \ +``` + + + +run the VM : +```sh +QEMU_NET_OPTS=helper=/run/wrappers/bin/qemu-bridge-helper ./run-vm-2 +``` +