forked from mirrors_public/oddlama_nix-config
feat: switch to new VLAN setup
This commit is contained in:
parent
181819d2e6
commit
0f45dfcc1c
8 changed files with 171 additions and 115 deletions
|
@ -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"
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue