[Bug] LXC Replication fails to resolve hostname and MAC ID of source container
[!CAUTION] API Limitation with certain feature flags In the course of testing this bug I found out that LXC containers with any feature flags other than
nesting=1will still fail at the config step regardless of this fix, due to a separate Proxmox API restriction. Apparently, feature flagsmknod,keyctl,fuse,mount,nfs,cifs, or similar capability flags are restricted from being configured via API. Additional bug report on this issue specifically is forthcoming.
Describe the bug
After a successful cross-cluster LXC replication, the replica on the target cluster is not a functionally equivalent drop-in replacement for the source container. Two critical properties are not preserved:
-
Hostname — The replica retains the temporary clone name (
xcrepl-{vmid}-tmp) instead of the original container hostname. When Site Recovery triggers a failover and starts the replica, it announces itself on the network with the wrong hostname, breaking DNS and service discovery. -
MAC address — Proxmox assigns a new MAC address to clones by default. The replica gets a different MAC, which means DHCP assigns it a different IP. When the replica starts during failover, it is unreachable at the expected address. Any service, device, or client pointing at the original IP will fail to connect.
Both issues make Site Recovery auto-failover non-functional for LXC containers in practice, the failover "succeeds" in that the container starts, but the service it hosts is broken because it has the wrong identity on the network.
[!TIP] Architectural question: Would it be more feasible to replace the current clone+migrate approach with
vzdump+pct restore --unique 0? This would natively preserve hostname, MAC addresses, AND solve the feature flags restriction issue, in a single operation, because the restore runs as root directly on the target node, bypassing the API token restriction that blocks feature flag restoration. The patches in this report and the forthcoming feature flags bug report are surgical fixes for the current architecture, but the restore path appears to solve all identity and permission issues cleanly. Curious if there's a reason clone+migrate was chosen over this approach?
Steps to Reproduce
- Configure a cross-cluster replication job for an LXC container (no feature flags)
- Let the replication complete successfully
- On the target cluster, check the replica config:
pct config {vmid} | grep -E "hostname|net0"
- Compare against source — hostname will be
xcrepl-{vmid}-tmpand MAC will differ
Expected behavior
The replica on the target cluster should be a drop-in replacement for the source container:
- Hostname matches the source container hostname
- MAC address matches the source container MAC address
- When started during failover, DHCP assigns the same IP and the container is reachable at the expected address
Proof
Source CT config:
hostname: LXC-Service
net0: name=eth0,bridge=vmbr0,hwaddr=AA:BB:CC:DD:EE:FF,ip=dhcp,type=veth
Replica on target before fix — different hostname, different MAC, different IP:
hostname: xcrepl-102-tmp
net0: name=eth0,bridge=vmbr0,hwaddr=11:22:33:44:55:66,ip=dhcp,type=veth
Container IP after starting replica before fix:
inet 10.0.0.95/24 ← different IP, service unreachable at expected address
Replica on target after fix — identical hostname, MAC, and IP:
hostname: LXC-Service
net0: name=eth0,bridge=vmbr0,hwaddr=AA:BB:CC:DD:EE:FF,ip=dhcp,type=veth
Fix
In pegaprox/api/vms.py, in _execute_replication, read the source CT config before migration to capture the original hostname and network interfaces. After successful migration, restore both on the target using PUT /nodes/{node}/lxc/{vmid}/config.
Step 1 — Capture original config before migration (add after source_node is resolved):
original_hostname = None
original_net_config = {}
if vm_type == 'lxc':
try:
cfg_url = f"https://{source_mgr.host}:{source_mgr.api_port}/api2/json/nodes/{source_node}/{vm_type}/{vmid}/config"
cfg_resp = source_mgr._api_get(cfg_url)
if cfg_resp.status_code == 200:
cfg_data = cfg_resp.json().get('data', {})
original_hostname = cfg_data.get('hostname')
for key, val in cfg_data.items():
if key.startswith('net'):
original_net_config[key] = val
except Exception as e:
logging.warning(f"[XCREPL] Job {job_id}: could not read source config for hostname/MAC: {e}")
Step 2 — Restore hostname and MAC after successful migration (add after migration complete log):
if vm_type == 'lxc' and original_hostname:
try:
rename_url = f"https://{target_mgr.host}:{target_mgr.api_port}/api2/json/nodes/{target_node}/{vm_type}/{vmid}/config"
rename_resp = target_mgr._api_put(rename_url, data={'hostname': original_hostname})
if rename_resp.status_code == 200:
logging.info(f"[XCREPL] Job {job_id}: renamed CT {vmid} to '{original_hostname}' on target")
else:
logging.warning(f"[XCREPL] Job {job_id}: rename failed: {rename_resp.text[:200]}")
except Exception as e:
logging.warning(f"[XCREPL] Job {job_id}: could not rename CT on target: {e}")
if vm_type == 'lxc' and original_net_config:
try:
net_url = f"https://{target_mgr.host}:{target_mgr.api_port}/api2/json/nodes/{target_node}/{vm_type}/{vmid}/config"
net_resp = target_mgr._api_put(net_url, data=original_net_config)
if net_resp.status_code == 200:
logging.info(f"[XCREPL] Job {job_id}: restored {len(original_net_config)} network interface(s) with original MACs on target")
else:
logging.warning(f"[XCREPL] Job {job_id}: MAC restore failed: {net_resp.text[:200]}")
except Exception as e:
logging.warning(f"[XCREPL] Job {job_id}: could not restore network config on target: {e}")
Both patches were tested live and confirmed working — replica came up with correct hostname, correct MAC, and correct DHCP-assigned IP matching the source container.
Environment
- PegaProx Version: v0.9.11
- Installation Method: Docker
- OS: Arch Linux ARM64 (PiKVM, Raspberry Pi 4)
- Browser: Chrome
- Behind Reverse Proxy? No
- UI: Modern Layout
Logs
[XCREPL] Job xxxxxxxx: captured original hostname 'LXC-Service' for post-migration rename
[XCREPL] Job xxxxxxxx: captured 1 network interface(s) for MAC restore
[XCREPL] Job xxxxxxxx: migration complete
[XCREPL] Job xxxxxxxx: renamed CT 102 to 'LXC-Service' on target
[XCREPL] Job xxxxxxxx: restored 1 network interface(s) with original MACs on target
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
@DarmokNoob — fixed on Testing in d0bec84.
The xcrepl flow now captures the source hostname (LXC) / name (QEMU) plus each NIC's MAC before the clone overwrites them, and re-applies both to the target replica after remote-migrate completes. MAC swap preserves the bridge / VLAN-tag / rate / firewall tokens that the migration set — only the MAC token itself is replaced, so the replica inherits the network shape you chose during migration setup while presenting the source identity on DHCP.
Re your architectural question — yeah, vzdump + pct restore --unique 0 does solve hostname / MAC / feature-flag in one operation. Original clone+migrate was picked for the live-snapshot story on the source side plus the well-trodden remote_migrate path, but worth a separate discussion before any rewrite. Surgical fix unblocks DR-failover today. Closing — file the feature-flag ticket whenever you're ready.
— Marcus
@mkellermann97 that's part of why i made a notation instead of reporting it as another bug... the bigger problem is Proxmox' s lack of support for additional LXC feature flags via API.
The backup and restore would fix that issue as well as the naming and Mac ID issue, I'm testing a potential work around but it's a hard coded problem built in to their internal auth requirements. It's been reported to Proxmox directly already. I was trying to find an alternative solution because its not a bug in your product its a flaw in theirs. So the solution may have to be a feature or some other methodology to handle this restriction.
Either way no one can sync an LXC that has any feature flags other than nesting via API. Don't know if they can get away with it by making the container privileged (it would be incredibly stupid of Proxmox if that is the fix) because I haven't tested it yet.
[!TIP] In any event, it maybe worth adding a check on features for LXCs so the user knows it wont work instead of letting them fail and find out the hard way or send you a bug report for a problem that isn't any fault of PegaProx.
@DarmokNoob the thing about it. Exactly Proxmox Lack of Support.
Proxmox needs to act here there is nothing that we can actively really do about it. Sure we can build workarounds but the initial work needs to be done from proxmox.
@DarmokNoob — picking this back up: the workaround portion landed in v0.9.12 (hostname/MAC resolution improvements on the cross-cluster LXC replication path so the source-side identity actually carries over). Per @MrMasterbay's earlier note, the deeper limitation sits in Proxmox's LXC tooling and isn't really ours to close, but the workaround is real and live.
Closing this against what we shipped. If you hit a fresh failure mode on v0.9.12+ that the workaround doesn't cover, a new ticket with the bundle would be cleaner than reopening.
PegaProx runs on volunteer hours — opencollective.com/pegaprox helps cover the next sprint if it's saving you any.
— Marcus