summaryrefslogtreecommitdiff
path: root/hosts/vidhar/network/default.nix
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-03-15 16:37:42 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2022-03-15 16:37:42 +0100
commit366cf64e848eebea98f9d9bb95e623597af74669 (patch)
tree949daf1e7b58ce2370b16663fb535ca10bc46bf1 /hosts/vidhar/network/default.nix
parent6dd45923b4bba68eb08b9d3ec43dc924734dd8c8 (diff)
downloadnixos-366cf64e848eebea98f9d9bb95e623597af74669.tar
nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.gz
nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.bz2
nixos-366cf64e848eebea98f9d9bb95e623597af74669.tar.xz
nixos-366cf64e848eebea98f9d9bb95e623597af74669.zip
vidhar: ddns
Diffstat (limited to 'hosts/vidhar/network/default.nix')
-rw-r--r--hosts/vidhar/network/default.nix152
1 files changed, 2 insertions, 150 deletions
diff --git a/hosts/vidhar/network/default.nix b/hosts/vidhar/network/default.nix
index 2d9a7b8f..85ddd4ef 100644
--- a/hosts/vidhar/network/default.nix
+++ b/hosts/vidhar/network/default.nix
@@ -1,6 +1,6 @@
1{ flake, config, lib, pkgs, ... }: 1{ ... }:
2{ 2{
3 imports = [ ./dsl.nix ./bifrost ]; 3 imports = [ ./dsl.nix ./bifrost ./dhcp ];
4 4
5 config = { 5 config = {
6 networking = { 6 networking = {
@@ -53,132 +53,6 @@
53 llmnr = "false"; 53 llmnr = "false";
54 }; 54 };
55 55
56 services.kea = {
57 dhcp4 = {
58 enable = true;
59 settings = {
60 valid-lifetime = 4000;
61 rebind-timer = 2000;
62 renew-timer = 1000;
63
64 interfaces-config = {
65 interfaces = [ "lan" "mgmt" ];
66 };
67
68 lease-database = {
69 name = "/var/lib/kea/dhcp4.leases";
70 persist = true;
71 type = "memfile";
72 };
73
74 client-classes = [
75 { name = "ipxe";
76 test = "option[77].hex == 'iPXE'";
77 next-server = "10.141.0.1";
78 boot-file-name = "netboot.ipxe";
79 only-if-required = true;
80 }
81 { name = "uefi-64";
82 test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00007' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00008' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00009'";
83 only-if-required = true;
84 option-data = [
85 { name = "tftp-server-name"; data = "10.141.0.1"; }
86 ];
87 boot-file-name = "ipxe.efi";
88 }
89 { name = "uefi-32";
90 test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00002' or substring(option[60].hex,0,20) == 'PXEClient:Arch:00006'";
91 only-if-required = true;
92 option-data = [
93 { name = "tftp-server-name"; data = "10.141.0.1"; }
94 ];
95 boot-file-name = "i386-ipxe.efi";
96 }
97 { name = "legacy";
98 test = "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'";
99 only-if-required = true;
100 option-data = [
101 { name = "tftp-server-name"; data = "10.141.0.1"; }
102 ];
103 boot-file-name = "undionly.kpxe";
104 }
105 ];
106
107 subnet4 = [
108 { subnet = "10.141.0.0/24";
109 option-data = [
110 { name = "domain-name-servers";
111 data = "10.141.0.1";
112 }
113 { name = "broadcast-address";
114 data = "10.141.0.255";
115 }
116 { name = "routers";
117 data = "10.141.0.1";
118 }
119 { name = "domain-name";
120 data = "yggdrasil";
121 }
122 ];
123 pools = [ { pool = "10.141.0.128 - 10.141.0.254"; } ];
124 reservations = [];
125 require-client-classes = ["ipxe" "uefi-64" "uefi-32" "legacy"];
126 }
127 { subnet = "10.141.1.0/24";
128 option-data = [
129 { name = "domain-name-servers";
130 data = "10.141.1.1";
131 }
132 { name = "broadcast-address";
133 data = "10.141.1.255";
134 }
135 ];
136 pools = [ { pool = "10.141.1.128 - 10.141.1.254"; } ];
137 reservations = [
138 { hostname = "switch01";
139 hw-address = "60:a4:b7:53:94:b5";
140 ip-address = "10.141.1.2";
141 }
142 { hostname = "ap01";
143 hw-address = "74:ac:b9:29:ad:9a";
144 ip-address = "10.141.1.4";
145 }
146 ];
147 }
148 { subnet = "10.141.2.0/24";
149 option-data = [
150 { name = "domain-name-servers";
151 data = "10.141.2.1";
152 }
153 { name = "broadcast-address";
154 data = "10.141.2.255";
155 }
156 { name = "routers";
157 data = "10.141.2.1";
158 }
159 ];
160 pools = [ { pool = "10.141.2.128 - 10.141.2.254"; } ];
161 reservations = [];
162 }
163 ];
164 };
165 };
166 dhcp6 = {
167 enable = true;
168 settings = {
169 interfaces-config = {
170 interfaces = [ "lan" ];
171 };
172
173 lease-database = {
174 name = "/var/lib/kea/dhcp6.leases";
175 persist = true;
176 type = "memfile";
177 };
178 };
179 };
180 };
181
182 systemd.network.networks = { 56 systemd.network.networks = {
183 "eno1" = { 57 "eno1" = {
184 matchConfig.Name = "eno1"; 58 matchConfig.Name = "eno1";
@@ -191,27 +65,5 @@
191 networkConfig.LinkLocalAddressing = "no"; 65 networkConfig.LinkLocalAddressing = "no";
192 }; 66 };
193 }; 67 };
194
195 systemd.services."installer-atftpd" = {
196 description = "TFTP Server for PXE Booting NixOS Installer";
197 after = [ "network.target" ];
198 wantedBy = [ "multi-user.target" ];
199 serviceConfig.ExecStart = let
200 installerBuild = flake.nixosConfigurations.installer-x86_64-linux-netboot.config.system.build;
201 ipxe = pkgs.ipxe.override {
202 additionalTargets = {
203 "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi";
204 };
205 };
206 tftpRoot = pkgs.runCommandLocal "installer-netboot" {} ''
207 mkdir -p $out
208 install -m 0444 -t $out \
209 ${installerBuild.netbootRamdisk}/initrd \
210 ${installerBuild.kernel}/bzImage \
211 ${installerBuild.netbootIpxeScript}/netboot.ipxe \
212 ${ipxe}/ipxe.efi ${ipxe}/i386-ipxe.efi ${ipxe}/undionly.kpxe
213 '';
214 in "${pkgs.atftp}/sbin/atftpd --daemon --no-fork --bind-address=10.141.0.1 ${tftpRoot}";
215 };
216 }; 68 };
217} 69}