Adds a network "switch" so every LXC gets the right DNS servers based on the VLAN tag entered at install time — including when DHCP is used for the IP.
What's new
lib/networks.conf — a small data file mapping a VLAN tag → subnet + DNS servers. Adding a network is a one-line change:
# tag subnet dns
none 192.168.0.0/24 192.168.0.4,192.168.0.5
20 10.11.20.0/24 10.11.20.44,10.11.20.55
none is the key for the untagged network (empty VLAN prompt).
lib/build.func — new apply_network_profile() looks up the entered VLAN tag in that file and sets --nameserver accordingly. Wired into prompt_lxc_config.
profile match for the VLAN tag — uses its DNS (this is the new bit, and it applies to DHCP too)
static IP, no profile — falls back to the manual DNS prompt
DHCP, no profile — inherits from the PVE host (with a warning)
Comma-separated DNS in the file is normalised to space-separated for pct --nameserver.
Why
DHCP previously meant "inherit whatever DNS the lease hands out". With two networks (untagged 192.168.0.0/24 and VLAN 20 → 10.11.20.0/24) that's not what we want — each network has its own resolvers. Keying DNS off the VLAN tag fixes this centrally for all scripts (devpi, webapp, future), since the logic lives in the shared lib. No ct/ changes needed.
Validation
shellcheck clean (only the pre-existing SC1090/SC2034 from the curl-sourced lib pattern), bash -n passes, and the lookup was unit-tested against the data file:
VLAN tag
resolved subnet
DNS
(empty)
192.168.0.0/24
192.168.0.4 192.168.0.5
20
10.11.20.0/24
10.11.20.44 10.11.20.55
30 (unknown)
—
none (DHCP inherits)
Note
The profile file is fetched at runtime from main (same mechanism as build.func). For local testing, set NET_PROFILES_FILE=/path.
Adds a network "switch" so every LXC gets the right DNS servers based on the VLAN tag entered at install time — **including when DHCP is used for the IP**.
## What's new
- **`lib/networks.conf`** — a small data file mapping a VLAN tag → subnet + DNS servers. Adding a network is a one-line change:
```
# tag subnet dns
none 192.168.0.0/24 192.168.0.4,192.168.0.5
20 10.11.20.0/24 10.11.20.44,10.11.20.55
```
`none` is the key for the untagged network (empty VLAN prompt).
- **`lib/build.func`** — new `apply_network_profile()` looks up the entered VLAN tag in that file and sets `--nameserver` accordingly. Wired into `prompt_lxc_config`.
## Behaviour
DNS resolution now follows a clear precedence:
1. explicit `NAMESERVER=…` from env (even empty = "inherit") — respected as-is
2. profile match for the VLAN tag — uses its DNS (this is the new bit, and it applies to DHCP too)
3. static IP, no profile — falls back to the manual DNS prompt
4. DHCP, no profile — inherits from the PVE host (with a warning)
Comma-separated DNS in the file is normalised to space-separated for `pct --nameserver`.
## Why
DHCP previously meant "inherit whatever DNS the lease hands out". With two networks (untagged 192.168.0.0/24 and VLAN 20 → 10.11.20.0/24) that's not what we want — each network has its own resolvers. Keying DNS off the VLAN tag fixes this centrally for **all** scripts (devpi, webapp, future), since the logic lives in the shared lib. No `ct/` changes needed.
## Validation
shellcheck clean (only the pre-existing SC1090/SC2034 from the curl-sourced lib pattern), `bash -n` passes, and the lookup was unit-tested against the data file:
| VLAN tag | resolved subnet | DNS |
|---|---|---|
| *(empty)* | 192.168.0.0/24 | 192.168.0.4 192.168.0.5 |
| 20 | 10.11.20.0/24 | 10.11.20.44 10.11.20.55 |
| 30 (unknown) | — | none (DHCP inherits) |
## Note
The profile file is fetched at runtime from `main` (same mechanism as build.func). For local testing, set `NET_PROFILES_FILE=/path`.
Data file mapping a VLAN tag to its DNS servers and subnet, so build.func
can set the right resolvers from the tag entered at install time — even
with DHCP. New networks are a one-line addition here.
Adds apply_network_profile(), which looks up DNS servers for the entered
VLAN tag in lib/networks.conf and sets --nameserver accordingly — even
when IP is DHCP. Precedence: explicit env NAMESERVER > profile > static
prompt > inherit. Comma-separated DNS is normalised to spaces for pct.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Adds a network "switch" so every LXC gets the right DNS servers based on the VLAN tag entered at install time — including when DHCP is used for the IP.
What's new
lib/networks.conf— a small data file mapping a VLAN tag → subnet + DNS servers. Adding a network is a one-line change:noneis the key for the untagged network (empty VLAN prompt).lib/build.func— newapply_network_profile()looks up the entered VLAN tag in that file and sets--nameserveraccordingly. Wired intoprompt_lxc_config.Behaviour
DNS resolution now follows a clear precedence:
NAMESERVER=…from env (even empty = "inherit") — respected as-isComma-separated DNS in the file is normalised to space-separated for
pct --nameserver.Why
DHCP previously meant "inherit whatever DNS the lease hands out". With two networks (untagged 192.168.0.0/24 and VLAN 20 → 10.11.20.0/24) that's not what we want — each network has its own resolvers. Keying DNS off the VLAN tag fixes this centrally for all scripts (devpi, webapp, future), since the logic lives in the shared lib. No
ct/changes needed.Validation
shellcheck clean (only the pre-existing SC1090/SC2034 from the curl-sourced lib pattern),
bash -npasses, and the lookup was unit-tested against the data file:Note
The profile file is fetched at runtime from
main(same mechanism as build.func). For local testing, setNET_PROFILES_FILE=/path.