Proxmox Virtual Environment (VE) ist ein [[Virtualisierung#Hypervisor|Typ 1 Hypervisor]] auf dem Debian GNU/[[Linux]]-Betriebssystem basiert. Es bietet eine umfassende Lösung für die Bereitstellung und Verwaltung von virtuellen Maschinen (VMs) und [[container|Containern]]. Proxmox VE integriert KVM (Kernel-based Virtual Machine) für die Virtualisierung auf der Hardwareebene und [[lxc|LXC (Linux Containers)]] für leichte, isolierte Container.
Die Installation von Proxmox VE erfolgt über ein bootfähiges Installationsmedium, das auf einem physischen Server gestartet wird. Das **Webinterface ist auf Port 8006 erreichbar**.
Während der Installation WIFI Adapter deaktivieren oder Ethernet Adapter als Managment wählen weil man keine Zugangsdaten eingeben kann
Proxmox VE besteht aus mehreren Hauptkomponenten:
* Proxmox VE-Host: Der Host ist der physische Server, auf dem Proxmox VE installiert ist. Er verwaltet die Ressourcen und bietet eine Plattform für die Ausführung von virtuellen Maschinen und Containern.
* Proxmox VE-Manager: Der Manager ist die webbasierte Benutzeroberfläche zur Verwaltung von Proxmox VE. Benutzer können über den Manager virtuelle Maschinen erstellen, konfigurieren und überwachen, sowie Speicher und Netzwerke verwalten.
* KVM/QEMU: Proxmox VE verwendet den KVM-Hypervisor in Verbindung mit QEMU für die Hardware-Virtualisierung. Dies ermöglicht die Ausführung von virtuellen Maschinen mit nahezu nativer Geschwindigkeit.
* LXC: Proxmox VE unterstützt auch Linux-Container (LXC), die eine leichte und effiziente Virtualisierungstechnologie bieten. Container teilen den Kernel des Host-Betriebssystems und sind daher ressourcenschonender als vollständige VMs.
=====VM Managment=====
Die Verwaltung von virtuellen Maschinen erfolgt über den Proxmox VE-Manager. Folgende Aufgaben können durchgeführt werden:
* Erstellung von virtuellen Maschinen: Erstellen Sie neue virtuelle Maschinen mit benutzerdefinierten Konfigurationen für CPU, RAM, Festplattenspeicher usw.
* Import/Export von VMs: Importieren Sie vorhandene virtuelle Maschinen aus anderen Plattformen oder exportieren Sie VMs zur Sicherung oder Migration.
* Snapshots: Erstellen Sie Snapshots von virtuellen Maschinen, um ihren Zustand zu sichern oder um Testumgebungen zu erstellen.
* Überwachung und Leistungsanalyse: Überwachen Sie die Leistung von virtuellen Maschinen und analysieren Sie Ressourcenauslastung und Auslastung.
=====HA=====
Proxmox VE bietet Mechanismen zur Verbesserung der Hochverfügbarkeit von virtuellen Maschinen.
====Live-Migration====
Verschieben von laufenden virtuellen Maschinen zwischen Hosts, ohne dass es zu Unterbrechungen für Benutzer kommt.
====Clustering====
Proxmox VE-Cluster, um virtuelle Maschinen automatisch zwischen verfügbaren Hosts zu migrieren und Ausfallsicherheit zu gewährleisten.
=====TUN Adapter=====
In der Container Konfiguration (auf Proxmox pve) unter /etc/pve/lxc/.conf
diese Zeilen einfügen.
lxc.cgroup2.devices.allow = c 10:200 rwm
lxc.mount.entry = /dev/net/tun dev/net/tun none bind,create=file
=====APPArmor=====
AppArmor deaktivieren. In der Container Konfiguration (auf Proxmox pve) unter /etc/pve/lxc/.conf
diese Zeilen einfügen.
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop:
=====CLI=====
# create container
# dhcp
pct create 999 local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst -storage local-lvm -hostname apitest -memory 512 -net0 name=eth0,bridge=vmbr0,ip=dhcp -password s3cr3t
# static ip
pct create 999 local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst -storage local-lvm -hostname apitest -memory 512 -net0 name=eth0,bridge=vmbr0,ip=192.168.0.50/24,gw=192.168.0.1 -password s3cr3t
# manage container
pct start 999
pct console 999
pct exec 999 -- ip a
pct exec 999 -- ping 1.1.1.1
pct exec 999 -- ping google.de
pct exec 999 -- bash -c "echo 'root:geheim123' | chpasswd"
vzdump 999 --storage local --mode stop # sichern
pct stop 999
pct destroy 999
# create vm
qm create 2000 --name ubuntu-vm --memory 512 --cores 1 --net0 virtio,bridge=vmbr0 --cdrom local:iso/ubuntu-22.04.5-live-server-amd64.iso --scsihw virtio-scsi-pci --scsi0 local-lvm:32 --boot order="scsi0;ide2" --ostype l26
====VM Managment====
# 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 --name --cores --memory --scsi0 file=: --cdrom local: --net0 virtio,bridge=
# 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 [OPTIONS]
# Show command line which is used to start the VM (debug info).
qm showcmd [OPTIONS]
# Unlock the VM.
qm unlock
# Clone a VM
qm clone
# Clone a VM in full clone mode and also set the name.
qm clone --full --name
# Migrate a VM
qm migrate
# Show VM status
qm status
# Clean up resources for a VM
qm cleanup
# Create a Template.
qm template [OPTIONS]
# Set virtual machine options (synchrounous API)
qm set [OPTIONS]
====Container Managment====
# List containers
pct list
# Create or restore a container.
pct create [OPTIONS]
# Start the container.
pct start [OPTIONS]
# Create a container clone/copy
pct clone [OPTIONS]
# 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 [OPTIONS]
# Shutdown the container.
# This will trigger a clean shutdown of the container, see lxc-stop(1) for details.
pct shutdown [OPTIONS]
# Destroy the container (also delete all uses files).
pct destroy [OPTIONS]
# Show CT status.
pct status [OPTIONS]
# Migrate the container to another node. Creates a new migration task.
pct migrate [OPTIONS]
# Get container configuration.
pct config [OPTIONS]
# Print the list of assigned CPU sets.
pct cpusets
# Get container configuration, including pending changes.
pct pending
# Reboot the container by shutting it down, and starting it again. Applies pending changes.
pct reboot [OPTIONS]
# Create or restore a container.
pct restore [OPTIONS]
# Set container options.
pct set [OPTIONS]
# Create a Template.
pct template
# Unlock the VM.
pct unlock
{{https://sweworld.net/cheatsheets/proxmox/|CheatSheet}}
=====API=====
#!/bin/bash
# ===== KONFIGURATION =====
PVE_HOST="192.168.0.100" # IP oder Hostname deines Proxmox-Servers
PVE_USER="root@pam" # API-Benutzer (z. B. root@pam oder apiuser@pve)
PVE_PASS="Lunikoff0310#" # Passwort oder API-Token
PVE_NODE="pve" # Name des Proxmox-Nodes (z. B. pve)
VMID=120
HOSTNAME="myct"
TEMPLATE="local:vztmpl/ubuntu-22.04-standard_22.04-1_amd64.tar.zst"
MEMORY=512 # MB
CORES=1
DISK_SIZE=1 # GB
BRIDGE="vmbr0"
IP_CONFIG="ip=dhcp"
ROOT_PASS="lunikoff"
# ===== LOGIN (Ticket holen) =====
echo "[*] Authentifiziere bei Proxmox API..."
AUTH_RESPONSE=$(curl -sk -d "username=$PVE_USER&password=$PVE_PASS" https://$PVE_HOST:8006/api2/json/access/ticket)
TICKET=$(echo "$AUTH_RESPONSE" | jq -r '.data.ticket')
CSRF=$(echo "$AUTH_RESPONSE" | jq -r '.data.CSRFPreventionToken')
if [[ -z "$TICKET" || -z "$CSRF" ]]; then
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://$PVE_HOST:8006/api2/json/nodes/$PVE_NODE/lxc \
-H "CSRFPreventionToken: $CSRF" \
-b "PVEAuthCookie=$TICKET" \
-d vmid=$VMID \
-d hostname=$HOSTNAME \
-d ostemplate=$TEMPLATE \
-d memory=$MEMORY \
-d cores=$CORES \
-d rootfs="local-lvm:${DISK_SIZE}" \
-d unprivileged=1)
echo "$CREATE_RESPONSE" | jq
# ===== Container starten =====
echo "[*] Starte Container $VMID..."
answer=$(curl -sk -X POST https://$PVE_HOST:8006/api2/json/nodes/$PVE_NODE/lxc/$VMID/status/start \
-H "CSRFPreventionToken: $CSRF" \
-b "PVEAuthCookie=$TICKET" | jq)
sleep 15
ssh root@192.168.0.100 "pct exec $VMID -- bash -c 'useradd -m user -G sudo -s /bin/bash'"
ssh root@192.168.0.100 "pct exec $VMID -- bash -c 'echo user:$ROOT_PASS | chpasswd'"
ssh root@192.168.0.100 "pct set $VMID -net0 name=eth0,bridge=vmbr0,ip=192.168.0.120/24,gw=192.168.0.1"
echo "[✓] Container $VMID wurde erstellt und gestartet."
=====Traffic Monitoring=====
Um den Traffic einzelner VMs/Container verlässlich zu monitoren braucht man zusätzliche Tools wie z.B [[vnstat]].
=====Links=====
* [[https://www.youtube.com/watch?v=zx5LFqyMPMU|Proxmox Networking]]
* [[https://www.youtube.com/watch?v=ITYMeRE455g|How to create and settings a NAT network on a single IP address]]
* [[https://homelabtopia.com/roxmox-fail2ban/|Proxmox Fail2Ban]]
* [[https://www.youtube.com/watch?v=VcTGKBHcqmk|OPNSense Router]]