[PR #60] [MERGED] fix(network): give --network=host containers a LAN NIC on PVE (#53) #59

Closed
opened 2026-10-15 12:51:42 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/games-on-whales/LXC2Docker/pull/60
Author: @JBailes
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/5/2026
Merged by: @JBailes

Base: main ← Head: fix/host-network-lan-nic


📝 Commits (1)

  • 3912c2d fix(network): give --network=host containers a LAN NIC on PVE (#53)

📊 Changes

5 files changed (+126 additions, -12 deletions)

View changed files

📝 deepdive.md (+4 -1)
📝 internal/lxc/manager.go (+4 -6)
📝 internal/lxc/network.go (+28 -0)
➕ internal/lxc/network_test.go (+87 -0)
📝 internal/lxc/pve_tarball.go (+3 -5)

📄 Description

Addresses the remaining open item in #53 (the host-networking failure paulzzh reported) — issue stays open for confirmation on their setup.

Problem

A Wolf container started with --network=host came up with no network configuration and no connectivity: the generated config had no NICs, and Wolf logged mDNS error: Failed to open any client sockets.

Root cause: a Proxmox CT cannot share the host's network namespace. The host-mode path emitted no lxc.net.* and relied on omitting net from lxc.namespace.clone to inherit the host netns — which pct does not honor, leaving the container in an empty, unreachable namespace.

The dual-NIC LAN mode already solves exactly this (a routable NIC on the physical bridge, where mDNS/Moonlight discovery and inbound traffic work), but it was gated behind a gow.lan=true label that a vanilla docker run --network=host … wolf never sets — so the feature existed but never triggered for the containers that need it.

Fix

When a LAN bridge is configured (--bridge), a --network=host container is automatically given the same dual-NIC LAN treatment instead of an unreachable namespace.

  • internal/lxc/network.go — new applyLANNetworking() helper consolidating the previously-duplicated LAN-fill logic; also converts host-mode → LAN NIC and clears NetworkMode so no futile host-netns namespace.clone is emitted.
  • internal/lxc/manager.go + internal/lxc/pve_tarball.go — both PVE create paths (pct clone and pct create from tarball, which Wolf uses) call the shared helper before IP allocation.
  • internal/lxc/network_test.go — covers the host-mode conversion, explicit-label path, no-bridge no-op, and plain-bridge skip; asserts the generated config has the LAN NIC and no namespace.clone.
  • deepdive.md — documents the host-mode → LAN behavior.

Notes / caveats

  • Triggers only when --bridge is configured (which paulzzh did in their last comment, and which the docs already require for Moonlight/mDNS discovery). Without a bridge, host mode is unchanged — a CT genuinely can't do host networking, so there is nothing better to convert it to.
  • Wolf ends up on a derived LAN IP (<prefix>.<vmid>) rather than literally the host IP — consistent with the existing dual-NIC design.
  • Not validated on real Proxmox from my side; the logic is unit-tested but a confirmation run on paulzzh's setup is the real check.

go build, go vet, and go test ./... all pass.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/games-on-whales/LXC2Docker/pull/60 **Author:** [@JBailes](https://github.com/JBailes) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@JBailes](https://github.com/JBailes) **Base:** `main` ← **Head:** `fix/host-network-lan-nic` --- ### 📝 Commits (1) - [`3912c2d`](https://github.com/games-on-whales/LXC2Docker/commit/3912c2d5003681a4fac9941212bf721e50d14e2a) fix(network): give --network=host containers a LAN NIC on PVE (#53) ### 📊 Changes **5 files changed** (+126 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `deepdive.md` (+4 -1) 📝 `internal/lxc/manager.go` (+4 -6) 📝 `internal/lxc/network.go` (+28 -0) ➕ `internal/lxc/network_test.go` (+87 -0) 📝 `internal/lxc/pve_tarball.go` (+3 -5) </details> ### 📄 Description Addresses the remaining open item in #53 (the host-networking failure paulzzh reported) — issue stays open for confirmation on their setup. ## Problem A Wolf container started with `--network=host` came up with **no network configuration and no connectivity**: the generated config had no NICs, and Wolf logged `mDNS error: Failed to open any client sockets`. **Root cause:** a Proxmox CT cannot share the host's network namespace. The host-mode path emitted no `lxc.net.*` and relied on omitting `net` from `lxc.namespace.clone` to *inherit* the host netns — which `pct` does not honor, leaving the container in an empty, unreachable namespace. The dual-NIC LAN mode already solves exactly this (a routable NIC on the physical bridge, where mDNS/Moonlight discovery and inbound traffic work), but it was gated behind a `gow.lan=true` label that a vanilla `docker run --network=host … wolf` never sets — so the feature existed but never triggered for the containers that need it. ## Fix When a LAN bridge is configured (`--bridge`), a `--network=host` container is automatically given the same dual-NIC LAN treatment instead of an unreachable namespace. - `internal/lxc/network.go` — new `applyLANNetworking()` helper consolidating the previously-duplicated LAN-fill logic; also converts host-mode → LAN NIC and clears `NetworkMode` so no futile host-netns `namespace.clone` is emitted. - `internal/lxc/manager.go` + `internal/lxc/pve_tarball.go` — both PVE create paths (`pct clone` and `pct create` from tarball, which Wolf uses) call the shared helper before IP allocation. - `internal/lxc/network_test.go` — covers the host-mode conversion, explicit-label path, no-bridge no-op, and plain-bridge skip; asserts the generated config has the LAN NIC and no `namespace.clone`. - `deepdive.md` — documents the host-mode → LAN behavior. ## Notes / caveats - Triggers **only when `--bridge` is configured** (which paulzzh did in their last comment, and which the docs already require for Moonlight/mDNS discovery). Without a bridge, host mode is unchanged — a CT genuinely can't do host networking, so there is nothing better to convert it to. - Wolf ends up on a derived LAN IP (`<prefix>.<vmid>`) rather than literally the host IP — consistent with the existing dual-NIC design. - Not validated on real Proxmox from my side; the logic is unit-tested but a confirmation run on paulzzh's setup is the real check. `go build`, `go vet`, and `go test ./...` all pass. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-15 12:51:42 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
games-on-whales/LXC2Docker#59
No description provided.