diff options
Diffstat (limited to 'hosts/vidhar')
| -rw-r--r-- | hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml | 6 | ||||
| -rw-r--r-- | hosts/vidhar/default.nix | 6 | ||||
| -rw-r--r-- | hosts/vidhar/kimai/default.nix | 89 | ||||
| -rw-r--r-- | hosts/vidhar/kimai/ruleset.nft | 149 | ||||
| -rw-r--r-- | hosts/vidhar/network/default.nix | 8 | ||||
| -rw-r--r-- | hosts/vidhar/network/pap-secrets | 26 | ||||
| -rw-r--r-- | hosts/vidhar/network/pppoe.nix (renamed from hosts/vidhar/network/gpon.nix) | 87 | ||||
| -rw-r--r-- | hosts/vidhar/network/ruleset.nft | 78 | ||||
| -rw-r--r-- | hosts/vidhar/prometheus/default.nix | 71 | ||||
| -rw-r--r-- | hosts/vidhar/prometheus/zte_dsl01.mgmt.yggdrasil | 26 |
10 files changed, 427 insertions, 119 deletions
diff --git a/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml b/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml index a5319e38..42920069 100644 --- a/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml +++ b/hosts/vidhar/audiobookshelf/abs-podcast-autoplaylist-gkleen.toml | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | { | 1 | { |
| 2 | "data": "ENC[AES256_GCM,data:60OmHwuLC7RJVNNn8lsCFjIFrtDlmmT3yAm3DYn/K2b8OJB/lzKBhMUCyPpoI2lfMm6y47/DMwXI3ExH3QwfgGRf4i/Tcv7p6FCkjFgDc0RhAM7cXNSnh1gKTff8QYtPoNIzmycFCThNr7iZsPsf2/1npVaVHTnt9nTc+cmDLc+lELlvjSE00JOXch/if7KPwFww9K83XlrFmoRvwybfXR0unJqxK2XLvj+dQuKD4Bhyb88iSgu4dX1yw2uBSZBD16S4Io0DaZ+as5Yw4Kon7WMj3Jd5kz8ZxK+0NCy1CVJHOfJIwgYl0SVPp4DpbAPtJO4R/ciXyDQ/XGpoLtHjxnKXaJlJoSiA7FhuSEk+jB/peLHrYV1obdIRE5Dstly01S5cydKlfQ+A0TSjxFSWBYMEiD89sD09Br3iSJX5FejOoS8d2IQJ5faVzgQl4T5aBKsxCNNwmYrEe8m9HN7o2eer8nTKMln5IxZi3ZWhnjgJfrJ4QTXFndxCb78jo8HroN3+7VhoM136UZkqH1OMrIgAH/XSlW08G8m9MRamKsAWklq9aVflcEsPWTHmYW7rjAapQYf+jyK6BbfHcYmyKM82TFZ5iNB60Pth6EJgb2V8PZiChGvDzQvFYYOO3p9a/J8bVqsnPZBXXYcIBt42ZuRPvyyUTfM+75V1eYE9ZGFML+QlofwNCAg+/Rnl+RRy4z+8xQxd8Dn06geDpHsr4yND72FRUTKLbjxF5xfbzBRcZEXjGkyFdEAF7rB78I8xIqii+n6Yt8uEURmd4geI9KWXRQnwofTz9pklaAnRbER8zy/BJIiIYy8zecUHJn9v/DPnsnksfL6RRmG4tHaRBDbpAag0kVkCrpO/flK6dZOl/wvoVVVqT2O69a9/RpHLSV2f//ZS6L9s6vaYe4pXL0M6QymgA22sNHaws6XggJlTxVOFGRejMGYrKqVWtC+2UNbnel+/J0N1qj4luWfQaf9+1j+fq7vyLSzXYFCiyOLAznpqOhzKu6VWy2IbR0UnCoL5ZbhIba9e2MXM7Czy9Yee4xc=,iv:M0GbtFFl1XUeq+y9H+MiD+9z/ASB9hsd06KhpPzSwEo=,tag:vTLIIf+CeZN6DU25CSP8tw==,type:str]", | 2 | "data": "ENC[AES256_GCM,data:7STcG1J3zLHzlHi2LZgSa+pmKlYU6X1eLvjXcx7gvCuHFkXwa/ldrHdzaBXAMrQ+C+DWM4+cyhdal3ypxXueBuBEvH3P7/KofPP2A519sdZo1vDkXCzYRD3Ow74M+hX5ej6hL1mv21HayrRMPnYfH8HUWk1kd/y69EjpjvDHyCpQuw1WG5M4FDUaTd4Vh51QRCSG/Is29dEkvQowhIvNqnAR4KW9PpfjlbUPHauZ6PQLnlJmI9QCcAGJ8hHtp5T+xctTym82GAlXugTJpHnkqcxnGteu9H7UuiDMQ3aKKGYzZCpWkNHrbD1IRhzPzSjVlN2nIX3Ydp8ENNf61EGOrp5hzmV0MhwRHKfz5rE1FRVuyHcwhwBdJzfhzrL9zXZYzn9Zuf9KWwsF+1+58i9u9hPym63r4c1+RbMjNKzHc1/yhhsRDCrTwvMd/Hc6KfUi3H1wW/r02Va2bOCkYrOkWIQpBdx4ThMgkTaHr94DBMqT8n3Fzhc7+uaUsl6I9gMwTn8QCV3g4U7Mp3+/gnQLOdsCTgKr69x1iPfp7jzzbC29MWhIk+2aig+iWRMVT0n4AWIxooc3cYnfOJNtCdJwKuPUl4xNlZ22NK3XQfxBURSw0pi5KyDO1wgTVRoRJMnXZyin3bZ10OU8QKBqLp22FXpG/+mHrm3Y6yLkqfIP5ry+b86Rb7nWJlxDTwTGSoGi8sJzwNb+H9ioG7LjaSmvr7V+2aSq0+72WopAkIFSBq/yIWX3J/rNZuia6jKMY/8bSLDJz3V/YuzeUJ5feUkOS4KW1J1UkaYd6XxZ9Y8szCS/B7Ocz0YiV8fHmOzZKRn8BTmmXUIoyxO07MmwQ1shYfiVCwXjdjq2f3/CZbXNVOPvhGBYOcutUztftu3H9DRDTKrVae1TnztCVSkBSk1o52uSj0r8t6f4l1r7UG1TviOnVLVh1/6iiJVQey0m8G6ugw22zxfhI0Uea/rB70i+2UuoxrmsOfg+TgnvKBuakEBifp4rx0S5wyz05RYXkBLJTIwi2fVGmulqjZuCQNQnI3cfPI+oGcykob9IQqdo/Dwd118hNPVAwdDHyaiGXGh8eu8N2OCLQxlGZDtkVUveaEasJaZ0WWWaK97FUeoNJfUnB7Y3lNjv5u2rzviZyk4=,iv:jT21FNnHod6btDlBa3UflK3au5VmcsABs5OTMXF6oFA=,tag:Oh8cOL+edT5Wp0I1L5+vwg==,type:str]", |
| 3 | "sops": { | 3 | "sops": { |
| 4 | "age": [ | 4 | "age": [ |
| 5 | { | 5 | { |
| @@ -11,8 +11,8 @@ | |||
| 11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBiRWFqSHNlY1IvMkkwaEto\ncHZHa2p1Y25SakFkS2JYMlRFcFhnZGY1dVRFCkxSWmxvcHZMampQKzdKRHI0ZVMx\nUTFtR0pHbzFaQ0xQUFA2ZERDSWpwS0UKLS0tIFBaSGczY3VWdy9TKzRDZWZ2SElY\nbVQ4dDNhQllmVmViWGs5c3V4TmNscjQKeugevQJFAN/8JrzeAm4hm2JsQGb26BCb\n3dKYnN1kJU7oVHr1aVfXwMpELNYt9poX6WTY2h9lsdHuRlqoFXAA5Q==\n-----END AGE ENCRYPTED FILE-----\n" | 11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBiRWFqSHNlY1IvMkkwaEto\ncHZHa2p1Y25SakFkS2JYMlRFcFhnZGY1dVRFCkxSWmxvcHZMampQKzdKRHI0ZVMx\nUTFtR0pHbzFaQ0xQUFA2ZERDSWpwS0UKLS0tIFBaSGczY3VWdy9TKzRDZWZ2SElY\nbVQ4dDNhQllmVmViWGs5c3V4TmNscjQKeugevQJFAN/8JrzeAm4hm2JsQGb26BCb\n3dKYnN1kJU7oVHr1aVfXwMpELNYt9poX6WTY2h9lsdHuRlqoFXAA5Q==\n-----END AGE ENCRYPTED FILE-----\n" |
| 12 | } | 12 | } |
| 13 | ], | 13 | ], |
| 14 | "lastmodified": "2025-05-10T10:25:15Z", | 14 | "lastmodified": "2025-08-11T07:08:36Z", |
| 15 | "mac": "ENC[AES256_GCM,data:dhj7e+vF3uiR6I22PR5tdNdM8EyrWmGGTIqjj8H7IdNIsZBHzjeHlBDFOwN7z/JMO0BVwIi4DmhApg2BSPGsQZGDQZ28UTCC8TDtd1zmfGtSP8R8AFHADYdLK/desMtHg6BZTnLv5tpba34WWdflMNOQpwgWPZsIk/DkLaoXdvk=,iv:qkoAZngTz2sfWdxDs+h8Mb2IrkF8gqnQoR5iRoeKjbY=,tag:zXrkBJmPM4ItJxMnX8IDxQ==,type:str]", | 15 | "mac": "ENC[AES256_GCM,data:ZL/dOz+NC8sr8vPBsux+gFOWxUhQqMSmG1az7udhB0ckmOXtnrPBzMM1gs+5pwXLvfLux0m4xzT87+o87axIECnCq35FSuMjtEBK24OUJXsLG/q/tDv5dfRBy/976dM5W7YkBVX/uc03p8CLKf5w4XYNeRKnSwjLvWGd9runDOU=,iv:9ZIeJ5aDVVPHi3/oHqWkWtEfeivV/nFFyQ1lJWJwMu8=,tag:TfkHaopMa+Z0zk38A6/NTA==,type:str]", |
| 16 | "unencrypted_suffix": "_unencrypted", | 16 | "unencrypted_suffix": "_unencrypted", |
| 17 | "version": "3.10.2" | 17 | "version": "3.10.2" |
| 18 | } | 18 | } |
diff --git a/hosts/vidhar/default.nix b/hosts/vidhar/default.nix index c9470ee9..1c60ed22 100644 --- a/hosts/vidhar/default.nix +++ b/hosts/vidhar/default.nix | |||
| @@ -4,7 +4,7 @@ with lib; | |||
| 4 | 4 | ||
| 5 | { | 5 | { |
| 6 | imports = with flake.nixosModules.systemProfiles; [ | 6 | imports = with flake.nixosModules.systemProfiles; [ |
| 7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest ./postgresql.nix ./immich.nix ./paperless ./hledger ./audiobookshelf | 7 | ./zfs.nix ./network ./samba.nix ./dns ./prometheus ./borg ./pgbackrest ./postgresql.nix ./immich.nix ./paperless ./hledger ./audiobookshelf ./kimai |
| 8 | tmpfs-root zfs | 8 | tmpfs-root zfs |
| 9 | initrd-all-crypto-modules default-locale openssh rebuild-machines | 9 | initrd-all-crypto-modules default-locale openssh rebuild-machines |
| 10 | build-server | 10 | build-server |
| @@ -136,7 +136,7 @@ with lib; | |||
| 136 | wantedBy = ["basic.target"]; | 136 | wantedBy = ["basic.target"]; |
| 137 | serviceConfig = { | 137 | serviceConfig = { |
| 138 | ExecStart = pkgs.writeShellScript "limit-pstate-start" '' | 138 | ExecStart = pkgs.writeShellScript "limit-pstate-start" '' |
| 139 | echo 50 > /sys/devices/system/cpu/intel_pstate/max_perf_pct | 139 | echo 40 > /sys/devices/system/cpu/intel_pstate/max_perf_pct |
| 140 | ''; | 140 | ''; |
| 141 | RemainAfterExit = true; | 141 | RemainAfterExit = true; |
| 142 | ExecStop = pkgs.writeShellScript "limit-pstate-stop" '' | 142 | ExecStop = pkgs.writeShellScript "limit-pstate-stop" '' |
| @@ -157,8 +157,6 @@ with lib; | |||
| 157 | recommendedProxySettings = true; | 157 | recommendedProxySettings = true; |
| 158 | recommendedTlsSettings = true; | 158 | recommendedTlsSettings = true; |
| 159 | commonHttpConfig = '' | 159 | commonHttpConfig = '' |
| 160 | ssl_ecdh_curve X25519:prime256v1:secp521r1:secp384r1; | ||
| 161 | |||
| 162 | log_format main | 160 | log_format main |
| 163 | '$remote_addr "$remote_user" ' | 161 | '$remote_addr "$remote_user" ' |
| 164 | '"$host" "$request" $status $bytes_sent ' | 162 | '"$host" "$request" $status $bytes_sent ' |
diff --git a/hosts/vidhar/kimai/default.nix b/hosts/vidhar/kimai/default.nix new file mode 100644 index 00000000..0258697b --- /dev/null +++ b/hosts/vidhar/kimai/default.nix | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | { flake, config, ... }: | ||
| 2 | |||
| 3 | { | ||
| 4 | config = { | ||
| 5 | boot.enableContainers = true; | ||
| 6 | boot.kernel.sysctl = { | ||
| 7 | "net.netfilter.nf_log_all_netns" = true; | ||
| 8 | }; | ||
| 9 | |||
| 10 | containers."kimai" = { | ||
| 11 | autoStart = true; | ||
| 12 | ephemeral = true; | ||
| 13 | bindMounts = { | ||
| 14 | "/var/lib/kimai" = { | ||
| 15 | hostPath = "/var/lib/kimai/state"; | ||
| 16 | isReadOnly = false; | ||
| 17 | }; | ||
| 18 | "/var/lib/mysql" = { | ||
| 19 | hostPath = "/var/lib/kimai/mysql"; | ||
| 20 | isReadOnly = false; | ||
| 21 | }; | ||
| 22 | }; | ||
| 23 | privateNetwork = true; | ||
| 24 | # forwardPorts = [ | ||
| 25 | # { containerPort = 80; | ||
| 26 | # hostPort = 28983; | ||
| 27 | # } | ||
| 28 | # ]; | ||
| 29 | hostAddress = "192.168.52.113"; | ||
| 30 | localAddress = "192.168.52.114"; | ||
| 31 | hostAddress6 = "2a03:4000:52:ada:6::1"; | ||
| 32 | localAddress6 = "2a03:4000:52:ada:6::2"; | ||
| 33 | config = let hostConfig = config; in { config, pkgs, lib, ... }: { | ||
| 34 | system.stateVersion = lib.mkIf hostConfig.containers."kimai".ephemeral config.system.nixos.release; | ||
| 35 | system.configurationRevision = lib.mkIf (flake ? rev) flake.rev; | ||
| 36 | nixpkgs.pkgs = hostConfig.nixpkgs.pkgs; | ||
| 37 | |||
| 38 | services.kimai.sites."kimai.yggdrasil.li" = { | ||
| 39 | database.socket = "/run/mysqld/mysqld.sock"; | ||
| 40 | }; | ||
| 41 | |||
| 42 | networking = { | ||
| 43 | useDHCP = false; | ||
| 44 | useNetworkd = true; | ||
| 45 | useHostResolvConf = false; | ||
| 46 | firewall.enable = false; | ||
| 47 | nftables = { | ||
| 48 | enable = true; | ||
| 49 | rulesetFile = ./ruleset.nft; | ||
| 50 | }; | ||
| 51 | }; | ||
| 52 | |||
| 53 | services.resolved.fallbackDns = [ | ||
| 54 | "9.9.9.10#dns10.quad9.net" | ||
| 55 | "149.112.112.10#dns10.quad9.net" | ||
| 56 | "2620:fe::10#dns10.quad9.net" | ||
| 57 | "2620:fe::fe:10#dns10.quad9.net" | ||
| 58 | ]; | ||
| 59 | |||
| 60 | systemd.network = { | ||
| 61 | networks.upstream = { | ||
| 62 | name = "eth0"; | ||
| 63 | matchConfig = { | ||
| 64 | Name = "eth0"; | ||
| 65 | }; | ||
| 66 | linkConfig = { | ||
| 67 | RequiredForOnline = true; | ||
| 68 | }; | ||
| 69 | networkConfig = { | ||
| 70 | Address = [ "192.168.52.114/32" "2a03:4000:52:ada:6::2/128" ]; | ||
| 71 | LLMNR = false; | ||
| 72 | MulticastDNS = false; | ||
| 73 | }; | ||
| 74 | routes = [ | ||
| 75 | { Destination = "192.168.52.113/32"; } | ||
| 76 | { Destination = "2a03:4000:52:ada:6::1/128"; } | ||
| 77 | { Destination = "0.0.0.0/0"; | ||
| 78 | Gateway = "192.168.52.113"; | ||
| 79 | } | ||
| 80 | { Destination = "::/0"; | ||
| 81 | Gateway = "2a03:4000:52:ada:6::1"; | ||
| 82 | } | ||
| 83 | ]; | ||
| 84 | }; | ||
| 85 | }; | ||
| 86 | }; | ||
| 87 | }; | ||
| 88 | }; | ||
| 89 | } | ||
diff --git a/hosts/vidhar/kimai/ruleset.nft b/hosts/vidhar/kimai/ruleset.nft new file mode 100644 index 00000000..ad4db6d5 --- /dev/null +++ b/hosts/vidhar/kimai/ruleset.nft | |||
| @@ -0,0 +1,149 @@ | |||
| 1 | define icmp_protos = {ipv6-icmp, icmp, igmp} | ||
| 2 | |||
| 3 | table arp filter { | ||
| 4 | limit lim_arp { | ||
| 5 | rate over 50 mbytes/second burst 50 mbytes | ||
| 6 | } | ||
| 7 | |||
| 8 | counter arp-rx {} | ||
| 9 | counter arp-tx {} | ||
| 10 | |||
| 11 | counter arp-ratelimit-rx {} | ||
| 12 | counter arp-ratelimit-tx {} | ||
| 13 | |||
| 14 | chain input { | ||
| 15 | type filter hook input priority filter | ||
| 16 | policy accept | ||
| 17 | |||
| 18 | limit name lim_arp counter name arp-ratelimit-rx drop | ||
| 19 | |||
| 20 | counter name arp-rx | ||
| 21 | } | ||
| 22 | |||
| 23 | chain output { | ||
| 24 | type filter hook output priority filter | ||
| 25 | policy accept | ||
| 26 | |||
| 27 | limit name lim_arp counter name arp-ratelimit-tx drop | ||
| 28 | |||
| 29 | counter name arp-tx | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | table inet filter { | ||
| 34 | limit lim_reject { | ||
| 35 | rate over 1000/second burst 1000 packets | ||
| 36 | } | ||
| 37 | |||
| 38 | limit lim_icmp { | ||
| 39 | rate over 50 mbytes/second burst 50 mbytes | ||
| 40 | } | ||
| 41 | |||
| 42 | counter invalid-fw {} | ||
| 43 | counter fw-lo {} | ||
| 44 | |||
| 45 | counter reject-ratelimit-fw {} | ||
| 46 | counter reject-fw {} | ||
| 47 | counter reject-tcp-fw {} | ||
| 48 | counter reject-icmp-fw {} | ||
| 49 | |||
| 50 | counter drop-fw {} | ||
| 51 | |||
| 52 | counter invalid-rx {} | ||
| 53 | |||
| 54 | counter rx-lo {} | ||
| 55 | counter invalid-local4-rx {} | ||
| 56 | counter invalid-local6-rx {} | ||
| 57 | |||
| 58 | counter icmp-ratelimit-rx {} | ||
| 59 | counter icmp-rx {} | ||
| 60 | |||
| 61 | counter kimai-rx {} | ||
| 62 | |||
| 63 | counter established-rx {} | ||
| 64 | |||
| 65 | counter reject-ratelimit-rx {} | ||
| 66 | counter reject-rx {} | ||
| 67 | counter reject-tcp-rx {} | ||
| 68 | counter reject-icmp-rx {} | ||
| 69 | |||
| 70 | counter drop-rx {} | ||
| 71 | |||
| 72 | counter tx-lo {} | ||
| 73 | |||
| 74 | counter icmp-ratelimit-tx {} | ||
| 75 | counter icmp-tx {} | ||
| 76 | |||
| 77 | counter kimai-tx {} | ||
| 78 | |||
| 79 | counter tx {} | ||
| 80 | |||
| 81 | chain forward { | ||
| 82 | type filter hook forward priority filter | ||
| 83 | policy drop | ||
| 84 | |||
| 85 | |||
| 86 | ct state invalid log level debug prefix "kimai: drop invalid forward: " counter name invalid-fw drop | ||
| 87 | |||
| 88 | |||
| 89 | iifname lo counter name fw-lo accept | ||
| 90 | |||
| 91 | |||
| 92 | limit name lim_reject log level debug prefix "kimai: drop forward: " counter name reject-ratelimit-fw drop | ||
| 93 | log level debug prefix "kimai: reject forward: " counter name reject-fw | ||
| 94 | meta l4proto tcp ct state new counter name reject-tcp-fw reject with tcp reset | ||
| 95 | ct state new counter name reject-icmp-fw reject | ||
| 96 | |||
| 97 | |||
| 98 | counter name drop-fw | ||
| 99 | } | ||
| 100 | |||
| 101 | chain input { | ||
| 102 | type filter hook input priority filter | ||
| 103 | policy drop | ||
| 104 | |||
| 105 | |||
| 106 | ct state invalid log level debug prefix "kimai: drop invalid input: " counter name invalid-rx drop | ||
| 107 | |||
| 108 | |||
| 109 | iifname lo counter name rx-lo accept | ||
| 110 | iif != lo ip daddr 127.0.0.1/8 counter name invalid-local4-rx reject | ||
| 111 | iif != lo ip6 daddr ::1/128 counter name invalid-local6-rx reject | ||
| 112 | |||
| 113 | |||
| 114 | meta l4proto $icmp_protos limit name lim_icmp counter name icmp-ratelimit-rx drop | ||
| 115 | meta l4proto $icmp_protos counter name icmp-rx accept | ||
| 116 | |||
| 117 | |||
| 118 | tcp dport 80 counter name kimai-rx accept | ||
| 119 | |||
| 120 | |||
| 121 | ct state { established, related } counter name established-rx accept | ||
| 122 | |||
| 123 | |||
| 124 | limit name lim_reject log level debug prefix "kimai: drop input: " counter name reject-ratelimit-rx drop | ||
| 125 | log level debug prefix "kimai: reject input: " counter name reject-rx | ||
| 126 | meta l4proto tcp ct state new counter name reject-tcp-rx reject with tcp reset | ||
| 127 | ct state new counter name reject-icmp-rx reject | ||
| 128 | |||
| 129 | |||
| 130 | counter name drop-rx | ||
| 131 | } | ||
| 132 | |||
| 133 | chain output { | ||
| 134 | type filter hook output priority filter | ||
| 135 | policy accept | ||
| 136 | |||
| 137 | |||
| 138 | oifname lo counter name tx-lo accept | ||
| 139 | |||
| 140 | meta l4proto $icmp_protos limit name lim_icmp counter name icmp-ratelimit-tx drop | ||
| 141 | meta l4proto $icmp_protos counter name icmp-tx accept | ||
| 142 | |||
| 143 | |||
| 144 | tcp sport 80 counter name kimai-tx | ||
| 145 | |||
| 146 | |||
| 147 | counter name tx | ||
| 148 | } | ||
| 149 | } | ||
diff --git a/hosts/vidhar/network/default.nix b/hosts/vidhar/network/default.nix index 92d755f3..6fcef9d8 100644 --- a/hosts/vidhar/network/default.nix +++ b/hosts/vidhar/network/default.nix | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | { pkgs, lib, ... }: | 1 | { pkgs, lib, config, ... }: |
| 2 | 2 | ||
| 3 | with lib; | 3 | with lib; |
| 4 | 4 | ||
| 5 | { | 5 | { |
| 6 | imports = [ ./gpon.nix ./bifrost ./dhcp ]; | 6 | imports = [ ./pppoe.nix ./bifrost ./dhcp ]; |
| 7 | 7 | ||
| 8 | config = { | 8 | config = { |
| 9 | networking = { | 9 | networking = { |
| @@ -61,7 +61,9 @@ with lib; | |||
| 61 | firewall.enable = false; | 61 | firewall.enable = false; |
| 62 | nftables = { | 62 | nftables = { |
| 63 | enable = true; | 63 | enable = true; |
| 64 | rulesetFile = ./ruleset.nft; | 64 | rulesetFile = pkgs.replaceVars ./ruleset.nft { |
| 65 | inherit (config.networking) pppInterface; | ||
| 66 | }; | ||
| 65 | }; | 67 | }; |
| 66 | 68 | ||
| 67 | resolvconf = { | 69 | resolvconf = { |
diff --git a/hosts/vidhar/network/pap-secrets b/hosts/vidhar/network/pap-secrets deleted file mode 100644 index 3516de6c..00000000 --- a/hosts/vidhar/network/pap-secrets +++ /dev/null | |||
| @@ -1,26 +0,0 @@ | |||
| 1 | { | ||
| 2 | "data": "ENC[AES256_GCM,data:BOyWdys7Oja54Ijv5j+kqufdokQe0onnqw/gVxpNOMf+YI/LlzJscaEtGqPh3ehVtYoSWGumCBPrjdq/zhYq4VV/PCtdeu3MnX1CH2B5bH0mFs0eXcqeGK6NErz/b5nEglv4Z19ig2CUDlbvi8h1zZAEjxTNKhT16ItCtJnBCsIoiMl2QcTTWMyh4a02v3wA1UrOQZvFuCgCHmRoBE6vpREyB23gQdrdKLk7D1LLw5C1aZnzQOhFsgs7bVjOcBnmwTao8ntXxw==,iv:X5FgYkl3DGA/lkRsoc+5XrK3Nlp/ldnFigpXpYNfSJE=,tag:qUH7m9NzuVNnOfr3rRgaOg==,type:str]", | ||
| 3 | "sops": { | ||
| 4 | "kms": null, | ||
| 5 | "gcp_kms": null, | ||
| 6 | "azure_kv": null, | ||
| 7 | "hc_vault": null, | ||
| 8 | "age": [ | ||
| 9 | { | ||
| 10 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
| 11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAwYTFaTDZRbDd6cFBRSTNN\nVk1kcFJXRG9TT21IMDZsVmtoZjBTNDNjeDFzCkhxNEI2Ujd6SW1STG43eE5EdzZa\nS3phenJZN0RxajBXQ1BnbUhTa3htdFEKLS0tIGVlT3lReHJSQ2UvQ1FST0M0RzVP\nNmxWNzJmNlFPclJTeDUycDJiUzA4Yk0K4JHtkEPY49TGnKPZzEoEZ131RxeQEWkR\nK1ftH2ilr2tUhiErhpqxoTqfAm33xvruqTsePxh1uC7svzKtKBlS2g==\n-----END AGE ENCRYPTED FILE-----\n" | ||
| 12 | } | ||
| 13 | ], | ||
| 14 | "lastmodified": "2021-11-15T08:30:09Z", | ||
| 15 | "mac": "ENC[AES256_GCM,data:TAgZ4ktdN9sZPMo1UtwjKdTM2QBjLorcm84HYXTGYNNEorPoqrXAWOvyWRLjx+zxzpRuDLBPQHCkjwkVO2CctxnTaWPMwITbYtQqj/5ZxACuAeX8MaSximB8s5MJK2faCuVXEnFehbnnPr5Fs8ZsgHwu2iH6DU8ScLEkgckzGV0=,iv:keUbKwWfoIIBsp5Rsm2lEba1ZHAozQY2YpA6p5qDBiU=,tag:1llGytMGvOjSVYKJXGUmXg==,type:str]", | ||
| 16 | "pgp": [ | ||
| 17 | { | ||
| 18 | "created_at": "2023-01-30T10:58:50Z", | ||
| 19 | "enc": "-----BEGIN PGP MESSAGE-----\n\nhF4DXxoViZlp6dISAQdA+cwEt6Gv5oKvym4ceJek+J/5guNpmsLLXWIY5CCCSXUw\npXyQpqxm7LQnasIqYNNsNCVbB1mAu6WU6MKn0BG03YWjr8buLB+7PpwZcxeZzRfD\n0l4BAsl+vKwa2YSMCR+EWYSfeEzEVHqoGBJ60dYXuiFiNZInCik+g69PdhsGygNH\nRtIcRiCB8t94GkvdWySTq5ohi1wKOe224l9evbt4zXntVngCHxixuufLrr3Cj+EE\n=3lw4\n-----END PGP MESSAGE-----\n", | ||
| 20 | "fp": "30D3453B8CD02FE2A3E7C78C0FB536FB87AE8F51" | ||
| 21 | } | ||
| 22 | ], | ||
| 23 | "unencrypted_suffix": "_unencrypted", | ||
| 24 | "version": "3.7.1" | ||
| 25 | } | ||
| 26 | } \ No newline at end of file | ||
diff --git a/hosts/vidhar/network/gpon.nix b/hosts/vidhar/network/pppoe.nix index 1628159c..5cc84862 100644 --- a/hosts/vidhar/network/gpon.nix +++ b/hosts/vidhar/network/pppoe.nix | |||
| @@ -8,7 +8,7 @@ in { | |||
| 8 | options = { | 8 | options = { |
| 9 | networking.pppInterface = mkOption { | 9 | networking.pppInterface = mkOption { |
| 10 | type = types.str; | 10 | type = types.str; |
| 11 | default = "gpon"; | 11 | default = "ppp"; |
| 12 | }; | 12 | }; |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| @@ -26,14 +26,14 @@ in { | |||
| 26 | nodefaultroute | 26 | nodefaultroute |
| 27 | ifname ${pppInterface} | 27 | ifname ${pppInterface} |
| 28 | lcp-echo-adaptive | 28 | lcp-echo-adaptive |
| 29 | lcp-echo-failure 5 | 29 | lcp-echo-failure 10 |
| 30 | lcp-echo-interval 1 | 30 | lcp-echo-interval 1 |
| 31 | maxfail 0 | 31 | maxfail 0 |
| 32 | mtu 1492 | 32 | mtu 1492 |
| 33 | mru 1492 | 33 | mru 1492 |
| 34 | plugin pppoe.so | 34 | plugin pppoe.so |
| 35 | name telekom | 35 | user congstar |
| 36 | user 002576900250551137425220#0001@t-online.de | 36 | password congstar |
| 37 | nic-telekom | 37 | nic-telekom |
| 38 | debug | 38 | debug |
| 39 | +ipv6 | 39 | +ipv6 |
| @@ -43,62 +43,55 @@ in { | |||
| 43 | stopIfChanged = true; | 43 | stopIfChanged = true; |
| 44 | 44 | ||
| 45 | serviceConfig = { | 45 | serviceConfig = { |
| 46 | Type = lib.mkForce "notify"; | ||
| 47 | ExecStart = lib.mkForce "${getBin config.services.pppd.package}/sbin/pppd call telekom up_sdnotify nolog"; | ||
| 46 | PIDFile = "/run/pppd/${pppInterface}.pid"; | 48 | PIDFile = "/run/pppd/${pppInterface}.pid"; |
| 47 | }; | 49 | }; |
| 48 | restartTriggers = with config; [ | 50 | restartTriggers = with config; [ |
| 49 | environment.etc."ppp/ip-pre-up".source | 51 | environment.etc."ppp/ip-pre-up".source |
| 50 | environment.etc."ppp/ip-up".source | 52 | environment.etc."ppp/ip-up".source |
| 51 | environment.etc."ppp/ip-down".source | 53 | environment.etc."ppp/ip-down".source |
| 52 | # sops.secrets."pap-secrets".sopsFile | ||
| 53 | ]; | 54 | ]; |
| 54 | }; | 55 | }; |
| 55 | sops.secrets."pap-secrets" = { | ||
| 56 | format = "binary"; | ||
| 57 | sopsFile = ./pap-secrets; | ||
| 58 | path = "/etc/ppp/pap-secrets"; | ||
| 59 | }; | ||
| 60 | 56 | ||
| 61 | environment.etc = { | 57 | environment.etc = { |
| 62 | "ppp/ip-pre-up".source = let | 58 | "ppp/ip-pre-up".source = pkgs.resholve.writeScript "ip-pre-up" { |
| 63 | app = pkgs.writeShellApplication { | 59 | interpreter = pkgs.runtimeShell; |
| 64 | name = "ip-pre-up"; | 60 | inputs = [ pkgs.iproute2 pkgs.ethtool ]; |
| 65 | runtimeInputs = with pkgs; [ iproute2 ethtool ]; | 61 | execer = [ |
| 66 | text = '' | 62 | "cannot:${lib.getExe' pkgs.iproute2 "ip"}" |
| 67 | ethtool -K telekom tso off gso off gro off | 63 | "cannot:${lib.getExe' pkgs.iproute2 "tc"}" |
| 64 | ]; | ||
| 65 | } '' | ||
| 66 | ethtool -K telekom tso off gso off gro off | ||
| 68 | 67 | ||
| 69 | ip link del "ifb4${pppInterface}" || true | 68 | ip link del "ifb4${pppInterface}" || true |
| 70 | ip link add name "ifb4${pppInterface}" type ifb | 69 | ip link add name "ifb4${pppInterface}" type ifb |
| 71 | ip link set "ifb4${pppInterface}" up | 70 | ip link set "ifb4${pppInterface}" up |
| 72 | 71 | ||
| 73 | tc qdisc del dev "ifb4${pppInterface}" root || true | 72 | tc qdisc del dev "ifb4${pppInterface}" root || true |
| 74 | tc qdisc del dev "${pppInterface}" ingress || true | 73 | tc qdisc del dev "${pppInterface}" ingress || true |
| 75 | tc qdisc del dev "${pppInterface}" root || true | 74 | tc qdisc del dev "${pppInterface}" root || true |
| 76 | 75 | ||
| 77 | tc qdisc add dev "${pppInterface}" handle ffff: ingress | 76 | tc qdisc add dev "${pppInterface}" handle ffff: ingress |
| 78 | tc filter add dev "${pppInterface}" parent ffff: basic action ctinfo dscp 0x0000003f 0x00000040 action mirred egress redirect dev "ifb4${pppInterface}" | 77 | tc filter add dev "${pppInterface}" parent ffff: basic action ctinfo dscp 0x0000003f 0x00000040 action mirred egress redirect dev "ifb4${pppInterface}" |
| 79 | tc qdisc replace dev "ifb4${pppInterface}" root cake memlimit 128Mb overhead 35 mpu 74 regional diffserv4 bandwidth 285mbit | 78 | tc qdisc replace dev "ifb4${pppInterface}" root cake memlimit 128Mb overhead 35 mpu 74 regional diffserv4 bandwidth ${toString (builtins.floor (177968 * 0.95))}kbit |
| 80 | tc qdisc replace dev "${pppInterface}" root cake memlimit 128Mb overhead 35 mpu 74 regional nat diffserv4 wash bandwidth 143mbit | 79 | tc qdisc replace dev "${pppInterface}" root cake memlimit 128Mb overhead 35 mpu 74 regional nat diffserv4 wash bandwidth ${toString (builtins.floor (41216 * 0.95))}kbit |
| 81 | ''; | 80 | ''; |
| 82 | }; | 81 | "ppp/ip-up".source = pkgs.resholve.writeScript "ip-up" { |
| 83 | in "${app}/bin/${app.meta.mainProgram}"; | 82 | interpreter = pkgs.runtimeShell; |
| 84 | "ppp/ip-up".source = let | 83 | inputs = [ pkgs.iproute2 ]; |
| 85 | app = pkgs.writeShellApplication { | 84 | execer = [ "cannot:${lib.getExe' pkgs.iproute2 "ip"}" ]; |
| 86 | name = "ip-up"; | 85 | } '' |
| 87 | runtimeInputs = with pkgs; [ iproute2 ]; | 86 | ip route add default via "$5" dev "${pppInterface}" metric 512 |
| 88 | text = '' | 87 | ''; |
| 89 | ip route add default via "$5" dev "${pppInterface}" metric 512 | 88 | "ppp/ip-down".source = pkgs.resholve.writeScript "ip-down" { |
| 90 | ''; | 89 | interpreter = pkgs.runtimeShell; |
| 91 | }; | 90 | inputs = [ pkgs.iproute2 ]; |
| 92 | in "${app}/bin/${app.meta.mainProgram}"; | 91 | execer = [ "cannot:${lib.getExe' pkgs.iproute2 "ip"}" ]; |
| 93 | "ppp/ip-down".source = let | 92 | } '' |
| 94 | app = pkgs.writeShellApplication { | 93 | ip link del "ifb4${pppInterface}" |
| 95 | name = "ip-down"; | 94 | ''; |
| 96 | runtimeInputs = with pkgs; [ iproute2 ]; | ||
| 97 | text = '' | ||
| 98 | ip link del "ifb4${pppInterface}" | ||
| 99 | ''; | ||
| 100 | }; | ||
| 101 | in "${app}/bin/${app.meta.mainProgram}"; | ||
| 102 | }; | 95 | }; |
| 103 | 96 | ||
| 104 | systemd.network.networks.${pppInterface} = { | 97 | systemd.network.networks.${pppInterface} = { |
diff --git a/hosts/vidhar/network/ruleset.nft b/hosts/vidhar/network/ruleset.nft index 6b0ac9fc..dd750394 100644 --- a/hosts/vidhar/network/ruleset.nft +++ b/hosts/vidhar/network/ruleset.nft | |||
| @@ -5,15 +5,15 @@ table arp filter { | |||
| 5 | limit lim_arp_local { | 5 | limit lim_arp_local { |
| 6 | rate over 50 mbytes/second burst 50 mbytes | 6 | rate over 50 mbytes/second burst 50 mbytes |
| 7 | } | 7 | } |
| 8 | limit lim_arp_gpon { | 8 | limit lim_arp_ppp { |
| 9 | rate over 7500 kbytes/second burst 7500 kbytes | 9 | rate over 7500 kbytes/second burst 7500 kbytes |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | counter arp-rx {} | 12 | counter arp-rx {} |
| 13 | counter arp-tx {} | 13 | counter arp-tx {} |
| 14 | 14 | ||
| 15 | counter arp-ratelimit-gpon-rx {} | 15 | counter arp-ratelimit-ppp-rx {} |
| 16 | counter arp-ratelimit-gpon-tx {} | 16 | counter arp-ratelimit-ppp-tx {} |
| 17 | 17 | ||
| 18 | counter arp-ratelimit-local-rx {} | 18 | counter arp-ratelimit-local-rx {} |
| 19 | counter arp-ratelimit-local-tx {} | 19 | counter arp-ratelimit-local-tx {} |
| @@ -22,8 +22,8 @@ table arp filter { | |||
| 22 | type filter hook input priority filter | 22 | type filter hook input priority filter |
| 23 | policy accept | 23 | policy accept |
| 24 | 24 | ||
| 25 | iifname != gpon limit name lim_arp_local counter name arp-ratelimit-local-rx drop | 25 | iifname != @pppInterface@ limit name lim_arp_local counter name arp-ratelimit-local-rx drop |
| 26 | iifname gpon limit name lim_arp_gpon counter name arp-ratelimit-gpon-rx drop | 26 | iifname @pppInterface@ limit name lim_arp_ppp counter name arp-ratelimit-ppp-rx drop |
| 27 | 27 | ||
| 28 | counter name arp-rx | 28 | counter name arp-rx |
| 29 | } | 29 | } |
| @@ -32,8 +32,8 @@ table arp filter { | |||
| 32 | type filter hook output priority filter | 32 | type filter hook output priority filter |
| 33 | policy accept | 33 | policy accept |
| 34 | 34 | ||
| 35 | oifname != gpon limit name lim_arp_local counter name arp-ratelimit-local-tx drop | 35 | oifname != @pppInterface@ limit name lim_arp_local counter name arp-ratelimit-local-tx drop |
| 36 | oifname gpon limit name lim_arp_gpon counter name arp-ratelimit-gpon-tx drop | 36 | oifname @pppInterface@ limit name lim_arp_ppp counter name arp-ratelimit-ppp-tx drop |
| 37 | 37 | ||
| 38 | counter name arp-tx | 38 | counter name arp-tx |
| 39 | } | 39 | } |
| @@ -47,11 +47,11 @@ table inet filter { | |||
| 47 | limit lim_icmp_local { | 47 | limit lim_icmp_local { |
| 48 | rate over 50 mbytes/second burst 50 mbytes | 48 | rate over 50 mbytes/second burst 50 mbytes |
| 49 | } | 49 | } |
| 50 | limit lim_icmp_gpon { | 50 | limit lim_icmp_ppp { |
| 51 | rate over 7500 kbytes/second burst 7500 kbytes | 51 | rate over 7500 kbytes/second burst 7500 kbytes |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | counter icmp-ratelimit-gpon-fw {} | 54 | counter icmp-ratelimit-ppp-fw {} |
| 55 | counter icmp-ratelimit-local-fw {} | 55 | counter icmp-ratelimit-local-fw {} |
| 56 | 56 | ||
| 57 | counter icmp-fw {} | 57 | counter icmp-fw {} |
| @@ -59,7 +59,8 @@ table inet filter { | |||
| 59 | counter invalid-fw {} | 59 | counter invalid-fw {} |
| 60 | counter fw-lo {} | 60 | counter fw-lo {} |
| 61 | counter fw-lan {} | 61 | counter fw-lan {} |
| 62 | counter fw-gpon {} | 62 | counter fw-ppp {} |
| 63 | counter fw-kimai {} | ||
| 63 | 64 | ||
| 64 | counter fw-cups {} | 65 | counter fw-cups {} |
| 65 | 66 | ||
| @@ -74,7 +75,7 @@ table inet filter { | |||
| 74 | counter invalid-local4-rx {} | 75 | counter invalid-local4-rx {} |
| 75 | counter invalid-local6-rx {} | 76 | counter invalid-local6-rx {} |
| 76 | 77 | ||
| 77 | counter icmp-ratelimit-gpon-rx {} | 78 | counter icmp-ratelimit-ppp-rx {} |
| 78 | counter icmp-ratelimit-local-rx {} | 79 | counter icmp-ratelimit-local-rx {} |
| 79 | counter icmp-rx {} | 80 | counter icmp-rx {} |
| 80 | 81 | ||
| @@ -95,6 +96,7 @@ table inet filter { | |||
| 95 | counter paperless-rx {} | 96 | counter paperless-rx {} |
| 96 | counter hledger-rx {} | 97 | counter hledger-rx {} |
| 97 | counter audiobookshelf-rx {} | 98 | counter audiobookshelf-rx {} |
| 99 | counter kimai-rx {} | ||
| 98 | 100 | ||
| 99 | counter established-rx {} | 101 | counter established-rx {} |
| 100 | 102 | ||
| @@ -106,7 +108,7 @@ table inet filter { | |||
| 106 | 108 | ||
| 107 | counter tx-lo {} | 109 | counter tx-lo {} |
| 108 | 110 | ||
| 109 | counter icmp-ratelimit-gpon-tx {} | 111 | counter icmp-ratelimit-ppp-tx {} |
| 110 | counter icmp-ratelimit-local-tx {} | 112 | counter icmp-ratelimit-local-tx {} |
| 111 | counter icmp-tx {} | 113 | counter icmp-tx {} |
| 112 | 114 | ||
| @@ -127,15 +129,16 @@ table inet filter { | |||
| 127 | counter paperless-tx {} | 129 | counter paperless-tx {} |
| 128 | counter hledger-tx {} | 130 | counter hledger-tx {} |
| 129 | counter audiobookshelf-tx {} | 131 | counter audiobookshelf-tx {} |
| 132 | counter kimai-tx {} | ||
| 130 | 133 | ||
| 131 | counter tx {} | 134 | counter tx {} |
| 132 | 135 | ||
| 133 | 136 | ||
| 134 | chain forward_icmp_accept { | 137 | chain forward_icmp_accept { |
| 135 | oifname { gpon, bifrost } limit name lim_icmp_gpon counter name icmp-ratelimit-gpon-fw drop | 138 | oifname { @pppInterface@, bifrost } limit name lim_icmp_ppp counter name icmp-ratelimit-ppp-fw drop |
| 136 | iifname { gpon, bifrost } limit name lim_icmp_gpon counter name icmp-ratelimit-gpon-fw drop | 139 | iifname { @pppInterface@, bifrost } limit name lim_icmp_ppp counter name icmp-ratelimit-ppp-fw drop |
| 137 | oifname != { gpon, bifrost } limit name lim_icmp_local counter name icmp-ratelimit-local-fw drop | 140 | oifname != { @pppInterface@, bifrost } limit name lim_icmp_local counter name icmp-ratelimit-local-fw drop |
| 138 | iifname != { gpon, bifrost } limit name lim_icmp_local counter name icmp-ratelimit-local-fw drop | 141 | iifname != { @pppInterface@, bifrost } limit name lim_icmp_local counter name icmp-ratelimit-local-fw drop |
| 139 | counter name icmp-fw accept | 142 | counter name icmp-fw accept |
| 140 | } | 143 | } |
| 141 | chain forward { | 144 | chain forward { |
| @@ -148,10 +151,15 @@ table inet filter { | |||
| 148 | 151 | ||
| 149 | iifname lo counter name fw-lo accept | 152 | iifname lo counter name fw-lo accept |
| 150 | 153 | ||
| 151 | oifname { lan, gpon, bifrost } meta l4proto $icmp_protos jump forward_icmp_accept | 154 | oifname { lan, @pppInterface@, bifrost } meta l4proto $icmp_protos jump forward_icmp_accept |
| 152 | iifname lan oifname { gpon, bifrost } counter name fw-lan accept | 155 | iifname lan oifname { @pppInterface@, bifrost } counter name fw-lan accept |
| 156 | iifname ve-kimai oifname @pppInterface@ counter name fw-kimai accept | ||
| 153 | 157 | ||
| 154 | iifname gpon oifname lan ct state { established, related } counter name fw-gpon accept | 158 | iifname @pppInterface@ oifname lan ct state { established, related } counter name fw-ppp accept |
| 159 | iifname @pppInterface@ oifname ve-kimai ct state { established, related } counter name fw-kimai accept | ||
| 160 | |||
| 161 | iifname bifrost oifname ve-kimai tcp dport 80 ip6 saddr $bifrost_surtr ip6 daddr 2a03:4000:52:ada:6::2 counter name kimai-rx accept | ||
| 162 | iifname ve-kimai oifname bifrost tcp sport 80 ip6 saddr 2a03:4000:52:ada:6::2 ip6 daddr $bifrost_surtr counter name kimai-tx accept | ||
| 155 | 163 | ||
| 156 | 164 | ||
| 157 | limit name lim_reject log level debug prefix "drop forward: " counter name reject-ratelimit-fw drop | 165 | limit name lim_reject log level debug prefix "drop forward: " counter name reject-ratelimit-fw drop |
| @@ -172,22 +180,22 @@ table inet filter { | |||
| 172 | iif != lo ip daddr 127.0.0.1/8 counter name invalid-local4-rx reject | 180 | iif != lo ip daddr 127.0.0.1/8 counter name invalid-local4-rx reject |
| 173 | iif != lo ip6 daddr ::1/128 counter name invalid-local6-rx reject | 181 | iif != lo ip6 daddr ::1/128 counter name invalid-local6-rx reject |
| 174 | 182 | ||
| 175 | iifname { bifrost, gpon } meta l4proto $icmp_protos limit name lim_icmp_gpon counter name icmp-ratelimit-gpon-rx drop | 183 | iifname { bifrost, @pppInterface@ } meta l4proto $icmp_protos limit name lim_icmp_ppp counter name icmp-ratelimit-ppp-rx drop |
| 176 | iifname != { bifrost, gpon } meta l4proto $icmp_protos limit name lim_icmp_local counter name icmp-ratelimit-local-rx drop | 184 | iifname != { bifrost, @pppInterface@ } meta l4proto $icmp_protos limit name lim_icmp_local counter name icmp-ratelimit-local-rx drop |
| 177 | meta l4proto $icmp_protos counter name icmp-rx accept | 185 | meta l4proto $icmp_protos counter name icmp-rx accept |
| 178 | 186 | ||
| 179 | iifname { lan, mgmt, gpon, yggdrasil, bifrost } tcp dport 22 counter name ssh-rx accept | 187 | iifname { lan, mgmt, @pppInterface@, yggdrasil, bifrost } tcp dport 22 counter name ssh-rx accept |
| 180 | iifname { lan, mgmt, gpon, yggdrasil, bifrost } udp dport 60000-61000 counter name mosh-rx accept | 188 | iifname { lan, mgmt, @pppInterface@, yggdrasil, bifrost } udp dport 60000-61000 counter name mosh-rx accept |
| 181 | 189 | ||
| 182 | iifname { lan, mgmt, wifibh, yggdrasil } meta l4proto { tcp, udp } th dport 53 counter name dns-rx accept | 190 | iifname { lan, mgmt, wifibh, yggdrasil } meta l4proto { tcp, udp } th dport 53 counter name dns-rx accept |
| 183 | 191 | ||
| 184 | iifname { lan, yggdrasil } tcp dport 2049 counter name nfs-rx accept | 192 | iifname { lan, yggdrasil } tcp dport 2049 counter name nfs-rx accept |
| 185 | 193 | ||
| 186 | iifname { lan, mgmt, gpon } meta protocol ip udp dport 51820 counter name wg-rx accept | 194 | iifname { lan, mgmt, @pppInterface@ } meta protocol ip udp dport 51820 counter name wg-rx accept |
| 187 | iifname { lan, mgmt, gpon } meta protocol ip6 udp dport 51821 counter name wg-rx accept | 195 | iifname { lan, mgmt, @pppInterface@ } meta protocol ip6 udp dport 51821 counter name wg-rx accept |
| 188 | iifname "yggdrasil-wg-*" meta l4proto gre counter name yggdrasil-gre-rx accept | 196 | iifname "yggdrasil-wg-*" meta l4proto gre counter name yggdrasil-gre-rx accept |
| 189 | 197 | ||
| 190 | iifname gpon meta protocol ip6 udp dport 546 udp sport 547 counter name ipv6-pd-rx accept | 198 | iifname @pppInterface@ meta protocol ip6 udp dport 546 udp sport 547 counter name ipv6-pd-rx accept |
| 191 | 199 | ||
| 192 | iifname mgmt udp dport 123 counter name ntp-rx accept | 200 | iifname mgmt udp dport 123 counter name ntp-rx accept |
| 193 | 201 | ||
| @@ -223,8 +231,8 @@ table inet filter { | |||
| 223 | 231 | ||
| 224 | oifname lo counter name tx-lo accept | 232 | oifname lo counter name tx-lo accept |
| 225 | 233 | ||
| 226 | oifname { bifrost, gpon } meta l4proto $icmp_protos limit name lim_icmp_gpon counter name icmp-ratelimit-gpon-tx drop | 234 | oifname { bifrost, @pppInterface@ } meta l4proto $icmp_protos limit name lim_icmp_ppp counter name icmp-ratelimit-ppp-tx drop |
| 227 | oifname != { bifrost, gpon } meta l4proto $icmp_protos limit name lim_icmp_local counter name icmp-ratelimit-local-tx drop | 235 | oifname != { bifrost, @pppInterface@ } meta l4proto $icmp_protos limit name lim_icmp_local counter name icmp-ratelimit-local-tx drop |
| 228 | meta l4proto $icmp_protos counter name icmp-tx accept | 236 | meta l4proto $icmp_protos counter name icmp-tx accept |
| 229 | 237 | ||
| 230 | 238 | ||
| @@ -265,28 +273,28 @@ table inet filter { | |||
| 265 | } | 273 | } |
| 266 | 274 | ||
| 267 | table inet nat { | 275 | table inet nat { |
| 268 | counter gpon-nat {} | 276 | counter ppp-nat {} |
| 269 | # counter container-nat {} | 277 | counter kimai-nat {} |
| 270 | 278 | ||
| 271 | chain postrouting { | 279 | chain postrouting { |
| 272 | type nat hook postrouting priority srcnat | 280 | type nat hook postrouting priority srcnat |
| 273 | policy accept | 281 | policy accept |
| 274 | 282 | ||
| 275 | 283 | ||
| 276 | meta nfproto ipv4 oifname gpon counter name gpon-nat masquerade | 284 | meta nfproto ipv4 oifname @pppInterface@ counter name ppp-nat masquerade |
| 277 | # iifname ve-* oifname gpon counter name container-nat masquerade | 285 | iifname ve-kimai oifname @pppInterface@ counter name kimai-nat masquerade |
| 278 | } | 286 | } |
| 279 | } | 287 | } |
| 280 | 288 | ||
| 281 | table inet mss_clamp { | 289 | table inet mss_clamp { |
| 282 | counter gpon-mss-clamp {} | 290 | counter ppp-mss-clamp {} |
| 283 | 291 | ||
| 284 | chain postrouting { | 292 | chain postrouting { |
| 285 | type filter hook postrouting priority mangle | 293 | type filter hook postrouting priority mangle |
| 286 | policy accept | 294 | policy accept |
| 287 | 295 | ||
| 288 | 296 | ||
| 289 | oifname gpon tcp flags & (syn|rst) == syn counter name gpon-mss-clamp tcp option maxseg size set rt mtu | 297 | oifname @pppInterface@ tcp flags & (syn|rst) == syn counter name ppp-mss-clamp tcp option maxseg size set rt mtu |
| 290 | } | 298 | } |
| 291 | } | 299 | } |
| 292 | 300 | ||
| @@ -421,7 +429,7 @@ table inet dscpclassify { | |||
| 421 | chain postrouting { | 429 | chain postrouting { |
| 422 | type filter hook postrouting priority filter + 1; policy accept | 430 | type filter hook postrouting priority filter + 1; policy accept |
| 423 | 431 | ||
| 424 | oifname != gpon return | 432 | oifname != @pppInterface@ return |
| 425 | 433 | ||
| 426 | ip dscp cs0 goto ct_set_cs0 | 434 | ip dscp cs0 goto ct_set_cs0 |
| 427 | ip dscp lephb goto ct_set_lephb | 435 | ip dscp lephb goto ct_set_lephb |
diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix index d368ad52..df135b58 100644 --- a/hosts/vidhar/prometheus/default.nix +++ b/hosts/vidhar/prometheus/default.nix | |||
| @@ -26,7 +26,8 @@ in { | |||
| 26 | enable = true; | 26 | enable = true; |
| 27 | 27 | ||
| 28 | extraFlags = [ | 28 | extraFlags = [ |
| 29 | "--enable-feature=remote-write-receiver" | 29 | "--web.enable-remote-write-receiver" |
| 30 | "--storage.tsdb.retention.size=35GB" | ||
| 30 | ]; | 31 | ]; |
| 31 | 32 | ||
| 32 | exporters = { | 33 | exporters = { |
| @@ -144,6 +145,17 @@ in { | |||
| 144 | ]; | 145 | ]; |
| 145 | scrape_interval = "15s"; | 146 | scrape_interval = "15s"; |
| 146 | } | 147 | } |
| 148 | { job_name = "zte"; | ||
| 149 | static_configs = [ | ||
| 150 | { targets = ["localhost:9900"]; } | ||
| 151 | ]; | ||
| 152 | relabel_configs = [ | ||
| 153 | { replacement = "dsl01"; | ||
| 154 | target_label = "instance"; | ||
| 155 | } | ||
| 156 | ]; | ||
| 157 | scrape_interval = "15s"; | ||
| 158 | } | ||
| 147 | { job_name = "unbound"; | 159 | { job_name = "unbound"; |
| 148 | static_configs = [ | 160 | static_configs = [ |
| 149 | { targets = ["localhost:${toString config.services.prometheus.exporters.unbound.port}"]; } | 161 | { targets = ["localhost:${toString config.services.prometheus.exporters.unbound.port}"]; } |
| @@ -287,6 +299,22 @@ in { | |||
| 287 | } | 299 | } |
| 288 | ]; | 300 | ]; |
| 289 | } | 301 | } |
| 302 | { name = "dsl-disconnects"; | ||
| 303 | rules = [ | ||
| 304 | { record = "dsl_uptime_seconds:resets_per_hour"; | ||
| 305 | expr = "resets(dsl_uptime_seconds[1h])"; | ||
| 306 | } | ||
| 307 | { record = "dsl_uptime_seconds:resets_per_day"; | ||
| 308 | expr = "resets(dsl_uptime_seconds[1d])"; | ||
| 309 | } | ||
| 310 | { record = "dsl_uptime_seconds:resets_per_week"; | ||
| 311 | expr = "resets(dsl_uptime_seconds[1w])"; | ||
| 312 | } | ||
| 313 | { record = "dsl_uptime_seconds:avg_resets_per_day"; | ||
| 314 | expr = "avg_over_time(dsl_uptime_seconds:resets_per_day[1w])"; | ||
| 315 | } | ||
| 316 | ]; | ||
| 317 | } | ||
| 290 | ]; | 318 | ]; |
| 291 | }) | 319 | }) |
| 292 | ]; | 320 | ]; |
| @@ -424,6 +452,47 @@ in { | |||
| 424 | }; | 452 | }; |
| 425 | }; | 453 | }; |
| 426 | 454 | ||
| 455 | systemd.services."prometheus-zte-exporter@dsl01.mgmt.yggdrasil" = { | ||
| 456 | wantedBy = [ "multi-user.target" ]; | ||
| 457 | after = [ "network.target" ]; | ||
| 458 | serviceConfig = { | ||
| 459 | Restart = "always"; | ||
| 460 | PrivateTmp = true; | ||
| 461 | WorkingDirectory = "/tmp"; | ||
| 462 | DynamicUser = true; | ||
| 463 | CapabilityBoundingSet = [""]; | ||
| 464 | DeviceAllow = [""]; | ||
| 465 | LockPersonality = true; | ||
| 466 | MemoryDenyWriteExecute = true; | ||
| 467 | NoNewPrivileges = true; | ||
| 468 | PrivateDevices = true; | ||
| 469 | ProtectClock = true; | ||
| 470 | ProtectControlGroups = true; | ||
| 471 | ProtectHome = true; | ||
| 472 | ProtectHostname = true; | ||
| 473 | ProtectKernelLogs = true; | ||
| 474 | ProtectKernelModules = true; | ||
| 475 | ProtectKernelTunables = true; | ||
| 476 | ProtectSystem = "strict"; | ||
| 477 | RemoveIPC = true; | ||
| 478 | RestrictAddressFamilies = [ "AF_INET" "AF_INET6" ]; | ||
| 479 | RestrictNamespaces = true; | ||
| 480 | RestrictRealtime = true; | ||
| 481 | RestrictSUIDSGID = true; | ||
| 482 | SystemCallArchitectures = "native"; | ||
| 483 | UMask = "0077"; | ||
| 484 | |||
| 485 | Type = "simple"; | ||
| 486 | ExecStart = "${pkgs.zte-prometheus-exporter}/bin/zte-prometheus-exporter"; | ||
| 487 | Environment = "ZTE_BASEURL=http://10.141.1.3 ZTE_HOSTNAME=localhost ZTE_PORT=9900"; | ||
| 488 | EnvironmentFile = config.sops.secrets."zte_dsl01.mgmt.yggdrasil".path; | ||
| 489 | }; | ||
| 490 | }; | ||
| 491 | sops.secrets."zte_dsl01.mgmt.yggdrasil" = { | ||
| 492 | format = "binary"; | ||
| 493 | sopsFile = ./zte_dsl01.mgmt.yggdrasil; | ||
| 494 | }; | ||
| 495 | |||
| 427 | services.nginx = { | 496 | services.nginx = { |
| 428 | upstreams.prometheus = { | 497 | upstreams.prometheus = { |
| 429 | servers = { "localhost:${toString config.services.prometheus.port}" = {}; }; | 498 | servers = { "localhost:${toString config.services.prometheus.port}" = {}; }; |
diff --git a/hosts/vidhar/prometheus/zte_dsl01.mgmt.yggdrasil b/hosts/vidhar/prometheus/zte_dsl01.mgmt.yggdrasil new file mode 100644 index 00000000..1c9c1fe0 --- /dev/null +++ b/hosts/vidhar/prometheus/zte_dsl01.mgmt.yggdrasil | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | { | ||
| 2 | "data": "ENC[AES256_GCM,data:nAsn7dhfDr0+V1cJjpqWn/kJQt2zGjlfQKi3n5speroJkL3IvMG/9fsTaXJQZSi2gPlrN8GbxKQ=,iv:9g0V3xRBC+sa/JPP2bUZMfg//VuKT5qI7ua9iU4QRCg=,tag:fzwih9OHUBLmx8dxL4BjGg==,type:str]", | ||
| 3 | "sops": { | ||
| 4 | "kms": null, | ||
| 5 | "gcp_kms": null, | ||
| 6 | "azure_kv": null, | ||
| 7 | "hc_vault": null, | ||
| 8 | "age": [ | ||
| 9 | { | ||
| 10 | "recipient": "age1qffdqvy9arld9zd5a5cylt0n98xhcns5shxhrhwjq5g4qa844ejselaa4l", | ||
| 11 | "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBIaEE3bUFBY0xKSDUrVnc2\nbFpjSkNOSm56amJTNjdXcTljdDNRREhITm1NCjZrOUEwNFpxN2FmTVV5T2xCbENk\nMEFmVzlPZ29CTlJ4dVNCRUsyRFFseXcKLS0tIEhscVZ4VUVsaG9OUnBIRFE4WXA2\ncGFnbWpNMlNIQzFLc1Ryc1Z3NUl1bVUKi9zYBlF2vslGKu4GP368ApbvuxjZnQpF\nuOujXSNoEps21wY6xUENm+CbYbgaJjSgmb5c1IjAmnubVI4JVY9OyQ==\n-----END AGE ENCRYPTED FILE-----\n" | ||
| 12 | } | ||
| 13 | ], | ||
| 14 | "lastmodified": "2021-12-31T15:00:33Z", | ||
| 15 | "mac": "ENC[AES256_GCM,data:sw2NVXHLibbuOChgScLhSTjGZBjSoHpzIuRqfCW0eL3DwhL5CekG6T/oYu06KjNmxVjxwb3OmqECSU0TUvPn9ySOWwMSoBfyJpDoTHnZ+YOjOH351IOAMBNcBDJse7aLGRWW5YXKLDfmp8Dhg2hlMhCmkVwAquQjPhfmAdJfj64=,iv:wgM/BlRU2XJSGj7KvAo1WRamecffUDnFvv2+4twtsQY=,tag:0mXblJtTGMTvxndedws94A==,type:str]", | ||
| 16 | "pgp": [ | ||
| 17 | { | ||
| 18 | "created_at": "2023-01-30T10:58:49Z", | ||
| 19 | "enc": "-----BEGIN PGP MESSAGE-----\n\nhF4DXxoViZlp6dISAQdAcwl1Blp3J5wgpRJKbYI1G1yEZrRYeYuoDtYUh3ToMAQw\nd92/bIJJR5Ml91eDym9uBN0fFRRy72r6FOx4qZT7S4DhmuA84qCbASjF8bKSclc0\n0l4BBXvDS5Dz1Q7iYc+LxZjHASV1v73A+MaeCFvG/pjmHzF0z0EzBiAJD4ZWGcP0\nX2dDbjl+n9VFrvmeLRxQNh4XZW43iTXdRjwHDgm16zhd9X6VOVhr5UkC4Nyjq2Ar\n=4ZEa\n-----END PGP MESSAGE-----\n", | ||
| 20 | "fp": "30D3453B8CD02FE2A3E7C78C0FB536FB87AE8F51" | ||
| 21 | } | ||
| 22 | ], | ||
| 23 | "unencrypted_suffix": "_unencrypted", | ||
| 24 | "version": "3.7.1" | ||
| 25 | } | ||
| 26 | } \ No newline at end of file | ||
