Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
proxmox [2025/06/14 12:55] jango [CLI] |
proxmox [2025/07/04 11:26] (aktuell) jango [Links] |
||
---|---|---|---|
Zeile 53: | Zeile 53: | ||
=====CLI===== | =====CLI===== | ||
- | |||
- | {{https:// | ||
<code bash> | <code bash> | ||
Zeile 77: | Zeile 75: | ||
qm create 2000 --name ubuntu-vm --memory 512 --cores 1 --net0 virtio, | qm create 2000 --name ubuntu-vm --memory 512 --cores 1 --net0 virtio, | ||
</ | </ | ||
+ | |||
+ | ====VM Managment==== | ||
+ | |||
+ | <code bash> | ||
+ | # list VMs | ||
+ | qm list | ||
+ | |||
+ | # Create or restore a virtual machine. | ||
+ | qm create < | ||
+ | |||
+ | # Create or restore a virtual machine with core, memory, disks specified. | ||
+ | qm create < | ||
+ | |||
+ | # start a VM | ||
+ | qm start < | ||
+ | |||
+ | # Suspend virtual machine. | ||
+ | qm suspend < | ||
+ | |||
+ | # shutdown a VM | ||
+ | qm shutdown < | ||
+ | |||
+ | # reboot a VM | ||
+ | qm reboot < | ||
+ | |||
+ | # reset a VM | ||
+ | qm reset < | ||
+ | |||
+ | # stop a VM | ||
+ | qm stop < | ||
+ | |||
+ | # Destroy the VM and all used/owned volumes. | ||
+ | # Removes any VM specific permissions and firewall rules | ||
+ | qm destroy < | ||
+ | |||
+ | # Enter Qemu Monitor interface. | ||
+ | qm monitor < | ||
+ | |||
+ | # Get the virtual machine configuration with both current and pending values. | ||
+ | qm pending < | ||
+ | |||
+ | # Send key event to virtual machine. | ||
+ | qm sendkey < | ||
+ | |||
+ | # Show command line which is used to start the VM (debug info). | ||
+ | qm showcmd < | ||
+ | |||
+ | # Unlock the VM. | ||
+ | qm unlock < | ||
+ | |||
+ | # Clone a VM | ||
+ | qm clone < | ||
+ | |||
+ | # Clone a VM in full clone mode and also set the name. | ||
+ | qm clone < | ||
+ | |||
+ | # Migrate a VM | ||
+ | qm migrate < | ||
+ | |||
+ | # Show VM status | ||
+ | qm status < | ||
+ | |||
+ | # Clean up resources for a VM | ||
+ | qm cleanup < | ||
+ | |||
+ | # Create a Template. | ||
+ | qm template < | ||
+ | |||
+ | # Set virtual machine options (synchrounous API) | ||
+ | qm set < | ||
+ | </ | ||
+ | |||
+ | ====Container Managment==== | ||
+ | |||
+ | <code bash> | ||
+ | # List containers | ||
+ | pct list | ||
+ | |||
+ | # Create or restore a container. | ||
+ | pct create < | ||
+ | |||
+ | # Start the container. | ||
+ | pct start < | ||
+ | |||
+ | # Create a container clone/copy | ||
+ | pct clone < | ||
+ | |||
+ | # Suspend the container. This is experimental. | ||
+ | pct suspend < | ||
+ | |||
+ | # Resume the container. | ||
+ | pct resume < | ||
+ | |||
+ | # Stop the container. | ||
+ | # This will abruptly stop all processes running in the container. | ||
+ | pct stop < | ||
+ | |||
+ | # Shutdown the container. | ||
+ | # This will trigger a clean shutdown of the container, see lxc-stop(1) for details. | ||
+ | pct shutdown < | ||
+ | |||
+ | # Destroy the container (also delete all uses files). | ||
+ | pct destroy < | ||
+ | |||
+ | # Show CT status. | ||
+ | pct status < | ||
+ | |||
+ | # Migrate the container to another node. Creates a new migration task. | ||
+ | pct migrate < | ||
+ | |||
+ | # Get container configuration. | ||
+ | pct config < | ||
+ | |||
+ | # Print the list of assigned CPU sets. | ||
+ | pct cpusets | ||
+ | |||
+ | # Get container configuration, | ||
+ | pct pending < | ||
+ | |||
+ | # Reboot the container by shutting it down, and starting it again. Applies pending changes. | ||
+ | pct reboot < | ||
+ | |||
+ | # Create or restore a container. | ||
+ | pct restore < | ||
+ | |||
+ | # Set container options. | ||
+ | pct set < | ||
+ | |||
+ | # Create a Template. | ||
+ | pct template < | ||
+ | |||
+ | # Unlock the VM. | ||
+ | pct unlock < | ||
+ | </ | ||
+ | |||
+ | {{https:// | ||
+ | =====API===== | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | # ===== KONFIGURATION ===== | ||
+ | PVE_HOST=" | ||
+ | PVE_USER=" | ||
+ | PVE_PASS=" | ||
+ | PVE_NODE=" | ||
+ | |||
+ | VMID=120 | ||
+ | HOSTNAME=" | ||
+ | TEMPLATE=" | ||
+ | MEMORY=512 | ||
+ | CORES=1 | ||
+ | DISK_SIZE=1 | ||
+ | BRIDGE=" | ||
+ | IP_CONFIG=" | ||
+ | ROOT_PASS=" | ||
+ | |||
+ | # ===== LOGIN (Ticket holen) ===== | ||
+ | echo "[*] Authentifiziere bei Proxmox API..." | ||
+ | AUTH_RESPONSE=$(curl -sk -d " | ||
+ | |||
+ | TICKET=$(echo " | ||
+ | CSRF=$(echo " | ||
+ | |||
+ | if [[ -z " | ||
+ | echo "[!] Fehler: Authentifizierung fehlgeschlagen." | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | # ===== LXC erstellen ===== | ||
+ | echo "[*] Erstelle LXC-Container $VMID auf Node $PVE_NODE..." | ||
+ | |||
+ | CREATE_RESPONSE=$(curl -sk -X POST https:// | ||
+ | -H " | ||
+ | -b " | ||
+ | -d vmid=$VMID \ | ||
+ | -d hostname=$HOSTNAME \ | ||
+ | -d ostemplate=$TEMPLATE \ | ||
+ | -d memory=$MEMORY \ | ||
+ | -d cores=$CORES \ | ||
+ | -d rootfs=" | ||
+ | -d unprivileged=1) | ||
+ | |||
+ | echo " | ||
+ | |||
+ | # ===== Container starten ===== | ||
+ | echo "[*] Starte Container $VMID..." | ||
+ | answer=$(curl -sk -X POST https:// | ||
+ | -H " | ||
+ | -b " | ||
+ | |||
+ | sleep 15 | ||
+ | |||
+ | ssh root@192.168.0.100 "pct exec $VMID -- bash -c ' | ||
+ | ssh root@192.168.0.100 "pct exec $VMID -- bash -c 'echo user: | ||
+ | ssh root@192.168.0.100 "pct set $VMID -net0 name=eth0, | ||
+ | |||
+ | echo "[✓] Container $VMID wurde erstellt und gestartet." | ||
+ | </ | ||
+ | |||
+ | =====Traffic Monitoring===== | ||
+ | |||
+ | Um den Traffic einzelner VMs/ | ||
=====Links===== | =====Links===== | ||
Zeile 83: | Zeile 284: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// |