blob: bcaf9897befe07bf5b532a03f8f1db702538c096 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# https://skogsbrus.xyz/blog/2022/06/12/router/
# https://blog.fraggod.net/2017/04/27/wifi-hostapd-configuration-for-80211ac-networks.html
{ config, lib, pkgs, secrets, ... }:
let
cfg = config.personal.networking;
in {
imports = [ ./nat.nix ./services ];
options.personal.networking = {
interfaces = lib.mkOption {
type = with lib.types; attrsOf str;
description = "Reusable names for network devices.";
example = {
eth = "enp4s0";
};
};
subnets = lib.mkOption {
type = with lib.types; attrsOf str;
description = "Reusable names for subnets.";
example = {
private = "192.168.1";
};
};
};
config = {
personal.networking = {
enable = true;
ssh.enable = true;
interfaces = {
eth = "enp4s0";
wlp2ghz = "wlp5s0";
wlp5ghz = "wlp1s0";
};
subnets = {
public = "192.168.1";
private = "192.168.2";
iot = "192.168.3";
};
};
networking = {
hostName = "kerberos";
domain = "local";
defaultGateway = {
address = "${cfg.subnets.public}.1";
interface = cfg.interfaces.eth;
};
dhcpcd.enable = false;
interfaces = {
"${cfg.interfaces.eth}" = {
useDHCP = false;
ipv4.addresses = [{
address = "${cfg.subnets.public}.2";
prefixLength = 24;
}];
};
"${cfg.interfaces.wlp5ghz}" = {
useDHCP = false;
ipv4.addresses = [{
address = "${cfg.subnets.private}.1";
prefixLength = 24;
}];
};
"${cfg.interfaces.wlp2ghz}" = {
useDHCP = false;
ipv4.addresses = [{
address = "${cfg.subnets.iot}.1";
prefixLength = 24;
}];
};
};
};
};
}
|