feat: switch to new VLAN setup

This commit is contained in:
oddlama 2025-01-20 03:46:16 +01:00
parent 181819d2e6
commit 0f45dfcc1c
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
8 changed files with 171 additions and 115 deletions

View file

@ -1,7 +1,6 @@
{
lib,
globals,
utils,
...
}:
let
@ -37,42 +36,46 @@ in
service-sockets-max-retries = -1;
};
subnet4 = flip mapAttrsToList globals.net.home-lan.vlans (
vlanName: vlanCfg: [
{
inherit (vlanCfg) id;
interface = "me-${vlanName}";
subnet = vlanCfg.cidrv4;
pools = [
{
pool = "${net.cidr.host 20 vlanCfg.cidrv4} - ${net.cidr.host (-6) vlanCfg.cidrv4}";
}
];
option-data = [
vlanName: vlanCfg: {
inherit (vlanCfg) id;
interface = "me-${vlanName}";
subnet = vlanCfg.cidrv4;
pools = [
{
pool = "${net.cidr.host 20 vlanCfg.cidrv4} - ${net.cidr.host (-6) vlanCfg.cidrv4}";
}
];
option-data =
[
{
name = "routers";
data = vlanCfg.hosts.ward.ipv4; # FIXME: how to advertise v6 address also?
}
{
name = "domain-name-servers";
data = vlanCfg.hosts.ward-adguardhome.ipv4;
]
# Advertise DNS server for VLANS that have internet access
++
lib.optional
(lib.elem vlanName [
"services"
"home"
"devices"
"guests"
])
{
name = "domain-name-servers";
data = globals.net.home-lan.vlans.services.hosts.ward-adguardhome.ipv4;
};
reservations = lib.concatLists (
lib.forEach (builtins.attrValues vlanCfg.hosts) (
hostCfg:
lib.optional (hostCfg.mac != null) {
hw-address = hostCfg.mac;
ip-address = hostCfg.ipv4;
}
];
reservations = lib.concatLists (
lib.forEach (builtins.attrValues vlanCfg.hosts) (
hostCfg:
lib.optional (hostCfg.mac != null) {
hw-address = hostCfg.mac;
ip-address = hostCfg.ipv4;
}
)
);
}
]
)
);
}
);
};
};
systemd.services.kea-dhcp4-server.after = [
"sys-subsystem-net-devices-${utils.escapeSystemdPath "lan-self"}.device"
];
}