Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
proxmox [2025/06/14 13:02] jango [CLI] |
proxmox [2025/07/04 11:26] (aktuell) jango [Links] |
||
---|---|---|---|
Zeile 211: | Zeile 211: | ||
{{https:// | {{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 216: | Zeile 284: | ||
* [[https:// | * [[https:// | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// |