1 { pkgs, lib, config, hostName, hosts, ... }:
4 inherit (config) networking users;
6 netIPv4 = "80.67.180.129";
7 netIPv4Gateway = "80.67.180.134";
8 #netIPv6 = "2001:912:400:104::35";
9 #netIPv6Gateway = "2001:912:400:104::1";
11 lanIPv4 = "192.168.1.214";
12 lanNet = "192.168.1.0/24";
13 lanIPv4Gateway = "192.168.1.1";
17 networking/nftables.nix
19 networking/wireguard.nix
22 _module.args.ipv4 = netIPv4;
24 /* WARNING: using ipconfig (the ip= kernel parameter) IS NOT RELIABLE:
25 a 91.216.110.35/32 becomes a 91.216.110.35/8
26 boot.kernelParams = map
27 (ip: "ip=${ip.clientIP}:${ip.serverIP}:${ip.gatewayIP}:${ip.netmask}:${ip.hostname}:${ip.device}:${ip.autoconf}")
28 [ { clientIP = netIPv4; serverIP = "";
29 gatewayIP = networking.defaultGateway.address;
30 netmask = "255.255.255.255";
31 hostname = ""; device = networking.defaultGateway.interface;
34 { clientIP = lanIPv4; serverIP = "";
36 netmask = "255.255.255.0";
37 hostname = ""; device = "${lanIface}";
42 /* DIY network config, but a right one */
43 boot.initrd.preLVMCommands = ''
47 ip link set ${netIface} up
48 ip address add ${netIPv4}/32 dev ${netIface}
49 ip route add ${netIPv4Gateway} dev ${netIface}
50 ip route add default via ${netIPv4Gateway} dev ${netIface}
53 ip link set ${lanIface} up
54 ip address add ${lanIPv4}/32 dev ${lanIface}
55 ip route add ${lanIPv4Gateway} dev ${lanIface}
56 ip route add ${lanNet} dev ${lanIface} src ${lanIPv4} proto kernel
57 # NOTE: ${lanIPv4}/24 would not work with initrd's ip, hence ${lanNet}
60 #ip -6 address add ''${netIPv6} dev ${netIface}
61 #ip -6 route add ''${netIPv6Gateway} dev ${netIface}
62 #ip -6 route add default via ''${netIPv6Gateway} dev ${netIface}
71 # Since boot.initrd.network's preLVMCommands won't set hasNetwork=1
72 # we have to run the postCommands ourselves.
73 ${config.boot.initrd.network.postCommands}
76 # Workaround https://github.com/NixOS/nixpkgs/issues/56822
77 # TODO: the issue is now closed
78 #boot.initrd.kernelModules = [ "ipv6" ];
80 # Useless without an out-of-band access, and unsecure
81 # (though / may still be encrypted at this point).
82 # boot.kernelParams = [ "boot.shell_on_fail" ];
84 # Disable IPv6 entirely until it's available
85 boot.kernel.sysctl = {
86 "net.ipv6.conf.${netIface}.disable_ipv6" = 1;
89 services.knot.extraConfig = lib.mkBefore ''
97 domain = "sourcephile.fr";
101 address = netIPv4Gateway;
102 interface = "${netIface}";
106 address = netIPv6Gateway;
107 interface = "${netIface}";
111 nftables.ruleset = lib.mkAfter ''
114 iifname ${netIface} goto input-net
115 iifname ${lanIface} goto input-lan
118 oifname ${netIface} jump output-net
119 oifname ${netIface} log level warn prefix "output-net: " counter drop
120 oifname ${lanIface} goto output-lan
124 interfaces.${netIface} = {
126 ipv4.addresses = [ { address = netIPv4; prefixLength = 32; } ];
127 ipv4.routes = [ { address = networking.defaultGateway.address; prefixLength = 32; } ];
130 ipv6.addresses = [ { address = netIPv6; prefixLength = 64; }
131 { address = "fe80::1"; prefixLength = 10; }
133 ipv6.routes = [ { address = networking.defaultGateway6.address; prefixLength = 64; } ];
136 interfaces.${lanIface} = {
138 ipv4.addresses = [ { address = lanIPv4; prefixLength = 24; } ];
140 # FIXME: remove this /1 hack when the host will be racked at PTT
141 ipv4.routes = [ { address = "0.0.0.0"; prefixLength = 1; via = "192.168.1.1"; }
142 { address = "128.0.0.0"; prefixLength = 1; via = "192.168.1.1"; }
146 ipv6.addresses = [ { address = "fe80::1"; prefixLength = 10; } ];
150 interfaces.enp3s0 = {