1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat(adguardhome): bind only external interface

This commit is contained in:
oddlama 2023-07-06 02:34:07 +02:00
parent 31ef29569d
commit 3f6286ef31
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
7 changed files with 122 additions and 59 deletions

77
hosts/ward/kea.nix Normal file
View file

@ -0,0 +1,77 @@
{
config,
lib,
utils,
nodes,
...
}: let
inherit
(lib)
flip
mapAttrsToList
mkOption
net
types
;
lanCidrv4 = "192.168.100.0/24";
dnsIp = net.cidr.host 2 lanCidrv4;
in {
# TODO make meta.kea module?
# TODO reserve by default using assignIps algo?
options.networking.dhcp4Reservations = mkOption {
default = {};
type = types.attrsOf (types.net.ipv4-in lanCidrv4);
description = "Maps MAC addresses to their reserved ipv4 address.";
};
config = {
services.kea.dhcp4 = {
enable = true;
settings = {
lease-database = {
name = "/var/lib/kea/dhcp4.leases";
persist = true;
type = "memfile";
};
valid-lifetime = 4000;
renew-timer = 1000;
rebind-timer = 2000;
interfaces-config = {
# XXX: why does this bind other macvtaps?
interfaces = ["lan-self"];
service-sockets-max-retries = -1;
};
option-data = [
{
name = "domain-name-servers";
data = dnsIp;
}
];
subnet4 = [
{
interface = "lan-self";
subnet = lanCidrv4;
pools = [
{pool = "${net.cidr.host 20 lanCidrv4} - ${net.cidr.host (-6) lanCidrv4}";}
];
option-data = [
{
name = "routers";
data = net.cidr.host 1 lanCidrv4;
}
];
reservations = [
{
hw-address = nodes.ward-adguardhome.config.lib.microvm.mac;
ip-address = dnsIp;
}
];
}
];
};
};
systemd.services.kea-dhcp4-server.after = ["sys-subsystem-net-devices-${utils.escapeSystemdPath "lan-self"}.device"];
};
}