add virsh networking notes
All checks were successful
Podman DDNS Image / build-and-push-ddns (push) Successful in 1m50s
All checks were successful
Podman DDNS Image / build-and-push-ddns (push) Successful in 1m50s
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
<name>dual-stack</name>
|
||||
<forward mode="nat"/>
|
||||
<domain name="dual-stack"/>
|
||||
<ip address="192.168.100.1" netmask="255.255.255.0">
|
||||
<ip address="192.168.123.1" netmask="255.255.255.0">
|
||||
<dhcp>
|
||||
<range start="192.168.100.2" end="192.168.100.254"/>
|
||||
<range start="192.168.123.2" end="192.168.123.99"/>
|
||||
</dhcp>
|
||||
</ip>
|
||||
<ip family="ipv6" address="fd4d:58e7:17f6:1::1" prefix="64"/>
|
||||
|
||||
@@ -8,6 +8,8 @@ Virtual Machine Management
|
||||
- [Virsh Networking](#virsh-networking)
|
||||
- [Create a Virtual Network](#create-a-virtual-network)
|
||||
- [Attach a New Virtual Network](#attach-a-new-virtual-network)
|
||||
- [Detach a Virtual Network](#detach-a-virtual-network)
|
||||
- [Destroy a Virtual Network](#destroy-a-virtual-network)
|
||||
- [Set a Static IP](#set-a-static-ip)
|
||||
- [Creating VMs](#creating-vms)
|
||||
- [Create VM with No Graphics and use an Existing QCOW2 Disk](#create-vm-with-no-graphics-and-use-an-existing-qcow2-disk)
|
||||
@@ -56,10 +58,10 @@ virsh shutdown <domain>
|
||||
virsh destroy <domain>
|
||||
|
||||
# Remove a VM
|
||||
virsh undefine <domain>
|
||||
virsh undefine --nvram <domain>
|
||||
|
||||
# Remove a VM including storage
|
||||
virsh undefine <domain> --remove-all-storage
|
||||
virsh undefine <domain> --nvram --remove-all-storage
|
||||
```
|
||||
|
||||
## Virsh Networking
|
||||
@@ -118,27 +120,42 @@ virsh attach-interface \
|
||||
--domain ${VM_NAME}
|
||||
```
|
||||
|
||||
### Detach a Virtual Network
|
||||
|
||||
```bash
|
||||
# List mac addresses of connected interfaces'
|
||||
export VM_NAME=my_vm
|
||||
virsh domiflist --domain $VM_NAME
|
||||
virsh detach-interface --domain k0s-worker0 --type bridge --mac "52:54:00:f6:b9:83" --live
|
||||
```
|
||||
|
||||
### Destroy a Virtual Network
|
||||
|
||||
```bash
|
||||
export NETWORK_NAME=mynetwork
|
||||
virsh net-undefine --network $NETWORK_NAME
|
||||
virsh net-destroy --network $NETWORK_NAME
|
||||
```
|
||||
|
||||
### Set a Static IP
|
||||
|
||||
To set a static IP, run `virsh net-edit default` and add the following between `<dhcp>` and `</dhcp>`
|
||||
|
||||
```xml
|
||||
<host mac='xx:xx:0x:xx:xx:1x' name='virtual_machine' ip='1xx.1xx.1xx.xx'/>
|
||||
```
|
||||
|
||||
Then run
|
||||
|
||||
```bash
|
||||
# `--location /path/to/image.iso` supplies a disk installer. (Remove `--import`)
|
||||
# `--import` skips the installation process.
|
||||
# `--graphics spice --video qxl --channel spicevmc` installs graphics
|
||||
# `--console pty,target.type=virtio` adds a console connection
|
||||
# For any command, use `virt-install --arg=?` to see all available options
|
||||
virsh net-destroy default
|
||||
virsh net-start default
|
||||
virsh shutdown virtual_machine
|
||||
systemctl restart libvirtd
|
||||
virsh start virtual_machine
|
||||
# Add a host
|
||||
virsh net-update default add-last ip-dhcp-host \
|
||||
'<host mac="52:54:00:6f:78:f3" ip="192.168.122.222"/>' \
|
||||
--live --config --parent-index 0
|
||||
|
||||
# Modify a host
|
||||
virsh net-update default modify ip-dhcp-host \
|
||||
'<host mac="52:54:00:6f:78:f3" ip="192.168.122.222"/>' \
|
||||
--live --config --parent-index 0
|
||||
|
||||
# Delete a host
|
||||
virsh net-update default delete ip-dhcp-host \
|
||||
'<host mac="52:54:00:6f:78:f3" ip="192.168.122.222"/>' \
|
||||
--live --config --parent-index 0
|
||||
```
|
||||
|
||||
## Creating VMs
|
||||
@@ -153,7 +170,9 @@ installation process altogether.
|
||||
```bash
|
||||
sudo systemctl start osbuild-composer.socket
|
||||
composer-cli compose list
|
||||
composer-cli compose image --filename /var/lib/libvirt/images/fedora-42-test.qcow2 image-uuid
|
||||
export IMAGE_UUID=
|
||||
export VM_DISK_PATH=/var/lib/libvirt/images/fedora43-test.qcow2
|
||||
composer-cli compose image --filename ${VM_DISK_PATH} ${IMAGE_UUID}
|
||||
```
|
||||
|
||||
### Create VM with No Graphics and use an Existing QCOW2 Disk
|
||||
@@ -162,17 +181,21 @@ composer-cli compose image --filename /var/lib/libvirt/images/fedora-42-test.qco
|
||||
# Start the default network if it isn't already
|
||||
virsh net-start --network default
|
||||
|
||||
export VM_NAME="fedora43-test"
|
||||
export VM_DISK_PATH=/var/lib/libvirt/images/fedora43-test.qcow2
|
||||
|
||||
# OPTIONAL: export your qcow2 disk now if using osbuild
|
||||
export IMAGE_UUID=
|
||||
composer-cli compose image --filename ${VM_DISK_PATH} ${IMAGE_UUID}
|
||||
|
||||
# Install
|
||||
# `--location /path/to/image.iso` supplies a disk installer. (Remove `--import`)
|
||||
# `--import` skips the installation process.
|
||||
# `--graphics spice --video qxl --channel spicevmc` installs graphics
|
||||
# `--graphics spice --video qxl,model.ram=131072,model.vram=131072,model.vgamem=131072 --channel spicevmc` installs graphics
|
||||
# `--console pty,target.type=virtio` adds a console connection
|
||||
# For any command, use `virt-install --arg=?` to see all available options
|
||||
export VM_NAME="fedora42-test"
|
||||
export VM_DESCRIPTION="Test VM with Fedora42"
|
||||
export VM_DISK_PATH="/var/lib/libvirt/images/fedora-42-test.qcow2"
|
||||
virt-install \
|
||||
--name "${VM_NAME}" \
|
||||
--description "${DESCRIPTION}" \
|
||||
--boot uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no \
|
||||
--cpu host-passthrough --vcpus sockets=1,cores=8,threads=2 \
|
||||
--ram=8192 \
|
||||
@@ -192,18 +215,16 @@ virt-install \
|
||||
# `--console pty,target.type=virtio` adds a console connection
|
||||
# For any command, use `virt-install --arg=?` to see all available options
|
||||
export VM_NAME="fedora43-kinoite-test"
|
||||
export VM_DESCRIPTION="Test VM with Fedora43 Kinoite"
|
||||
export VM_DISK_PATH="/var/lib/libvirt/images/fedora-43-kinoite.qcow2"
|
||||
export VM_ISO_PATH="/var/lib/libvirt/iso/Fedora-Kinoite-ostree-x86_64-43-1.6.iso"
|
||||
export VM_ISO_PATH=/var/lib/libvirt/iso/
|
||||
export VM_DISK_PATH=/var/lib/libvirt/images/
|
||||
virt-install \
|
||||
--name "${VM_NAME}" \
|
||||
--description "${DESCRIPTION}" \
|
||||
--boot uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no \
|
||||
--cpu host-passthrough --vcpus sockets=1,cores=8,threads=2 \
|
||||
--ram=8192 \
|
||||
--os-variant=fedora41 \
|
||||
--network bridge:virbr0 \
|
||||
--graphics spice --video qxl --channel spicevmc \
|
||||
--graphics spice --video virtio --channel spicevmc \
|
||||
--cdrom ${VM_ISO_PATH} \
|
||||
--disk "path=${VM_DISK_PATH},size=64,bus=virtio,format=qcow2"
|
||||
```
|
||||
@@ -218,10 +239,8 @@ virt-install \
|
||||
# `--hostdev 0x1234:0x5678` adds a block storage device
|
||||
# For any command, use `virt-install --arg=?` to see all available options
|
||||
export VM_NAME="usb-linux"
|
||||
export VM_DESCRIPTION="Linux running 0x13fe:0x6500 as the boot drive"
|
||||
virt-install \
|
||||
--name "${VM_NAME}" \
|
||||
--description "${DESCRIPTION}" \
|
||||
--boot uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no \
|
||||
--import \
|
||||
--cpu host-passthrough --vcpus sockets=1,cores=8,threads=2 \
|
||||
|
||||
Reference in New Issue
Block a user