summaryrefslogtreecommitdiff
path: root/router.nix
diff options
context:
space:
mode:
authorMathias Magnusson <mathias@magnusson.space>2025-10-10 18:42:56 +0200
committerMathias Magnusson <mathias@magnusson.space>2025-10-19 15:25:56 +0200
commitfd69ebbaad366cca94f13489723ce003bea69c36 (patch)
tree40c77de69928cae1aba88202674964353216c125 /router.nix
downloadoden-fd69ebbaad366cca94f13489723ce003bea69c36.tar.gz
Initial commit
Diffstat (limited to 'router.nix')
-rw-r--r--router.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/router.nix b/router.nix
new file mode 100644
index 0000000..ad58ba8
--- /dev/null
+++ b/router.nix
@@ -0,0 +1,50 @@
+{ ... }:
+let
+ lanInterface = "enp5s0f0u2";
+in
+{
+ boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true;
+ networking.nftables.enable = true;
+ networking.firewall.filterForward = true;
+ networking.nat = {
+ enable = true;
+ externalInterface = "enp8s0";
+ internalInterfaces = [ lanInterface ];
+ forwardPorts = [{
+ sourcePort = 1234;
+ destination = "10.69.0.2:12345";
+ }];
+ };
+ networking.interfaces.${lanInterface}.ipv4.addresses = [{
+ address = "10.69.0.1";
+ prefixLength = 16;
+ }];
+ services.kea.dhcp4 = {
+ enable = true;
+ settings = {
+ interfaces-config = {
+ interfaces = [ lanInterface ];
+ service-sockets-max-retries = 200000;
+ service-sockets-retry-wait-time = 5000;
+ };
+ lease-database = {
+ name = "/var/lib/kea/dhcp4-leases.csv";
+ type = "memfile";
+ };
+ valid-lifetime = 4000;
+ renew-timer = 2000;
+ rebind-timer = 3500;
+ subnet4 = [{
+ id = 1;
+ subnet = "10.69.0.0/16";
+ pools = [{
+ pool = "10.69.0.2 - 10.69.0.254";
+ }];
+ option-data = [
+ { name = "routers"; data = "10.69.0.1"; }
+ { name = "domain-name-servers"; data = "1.1.1.1, 1.0.0.1"; }
+ ];
+ }];
+ };
+ };
+}