1.7 KiB
1.7 KiB
Proxmox Config File Parsing for Inventory Mapping
LXC Containers (/etc/pve/lxc/<CTID>.conf)
Key fields to extract:
hostname: <name>— container hostnamememory: <MB>— RAM allocationcores: <N>— CPU coresnet0: ... ip=<IP>orip=dhcp— network config (may be multiple net lines)
Static IP parsing
grep -E '^net[0-9]+:' /etc/pve/lxc/135.conf | grep 'ip='
# → net0: ... ip=10.0.30.102/24,...
DHCP mapping
DHCP-assigned CTs do not show an IP in the config. Match by:
- Hostname from config → runtime
hostnamecollected via SSH - MAC address (
hwaddr=) from config → ARP table lookup - Or query Proxmox API:
pvesh get /nodes/<node>/lxc/<vmid>/config
QEMU VMs (/etc/pve/qemu-server/<VMID>.conf)
name: <name>— VM namenet0: ... bridge=vmbr0,tag=<VLAN>— network (usually DHCP, no static IP in config)
VM IPs are typically assigned by DHCP. To discover:
# From Proxmox node
arp -a | grep <MAC>
# Or via API
pvesh get /nodes/<node>/qemu/<vmid>/agent/network-get-interfaces
Cross-referencing SSH inventory with Proxmox configs
- Collect all CT configs → map
CTID → hostname → config_ip - Collect all VM configs → map
VMID → name → VLAN - For each accessible SSH host:
- Match
hostnameagainst CT/VM hostname - If match found → assign CT/VM ID
- If no match → mark as "unknown CT/VM or bare metal"
- Match
- Flag CTs/VMs in range that were NOT accessible (potential gap in scan)
Proxmox API alternative
If SSH to Proxmox node is available but direct file parsing is messy:
pvesh get /cluster/resources --output-format json | jq '.[] | select(.type=="lxc" or .type=="qemu") | {id, name, status, node}'