diff options
Diffstat (limited to 'hosts/demiurge/default.nix')
| -rw-r--r-- | hosts/demiurge/default.nix | 134 |
1 files changed, 95 insertions, 39 deletions
diff --git a/hosts/demiurge/default.nix b/hosts/demiurge/default.nix index 6b7a55d..263d509 100644 --- a/hosts/demiurge/default.nix +++ b/hosts/demiurge/default.nix | |||
| @@ -63,7 +63,7 @@ | |||
| 63 | # decrypt agenix secrets | 63 | # decrypt agenix secrets |
| 64 | age.secrets = { | 64 | age.secrets = { |
| 65 | wg0_demiurge.file = ../../secrets/wg0_demiurge.age; | 65 | wg0_demiurge.file = ../../secrets/wg0_demiurge.age; |
| 66 | tailscale_demiurge.file = ../../secrets/tailscale_demiurge.age; | 66 | wg1_demiurge.file = ../../secrets/wg1_demiurge.age; |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | # boot options | 69 | # boot options |
| @@ -92,7 +92,7 @@ | |||
| 92 | 9943 | 92 | 9943 |
| 93 | 9944 | 93 | 9944 |
| 94 | ]; | 94 | ]; |
| 95 | allowedUDPPorts = [ 9943 9944 51413 ]; | 95 | allowedUDPPorts = [ 9943 9944 51413 51820 ]; |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | interfaces.eth0 = { | 98 | interfaces.eth0 = { |
| @@ -109,33 +109,99 @@ | |||
| 109 | }; | 109 | }; |
| 110 | 110 | ||
| 111 | # mullvad | 111 | # mullvad |
| 112 | wg-quick.interfaces.wg0 = { | 112 | wg-quick.interfaces = { |
| 113 | address = [ | 113 | wg0 = { |
| 114 | "10.68.117.111/32" | 114 | address = [ |
| 115 | "fc00:bbbb:bbbb:bb01::5:756e/128" | 115 | "10.68.117.111/32" |
| 116 | ]; | 116 | "fc00:bbbb:bbbb:bb01::5:756e/128" |
| 117 | privateKeyFile = config.age.secrets.wg0_demiurge.path; | 117 | ]; |
| 118 | 118 | privateKeyFile = config.age.secrets.wg0_demiurge.path; | |
| 119 | # supposed to be done by tailscale instead \_(:/)_/ | ||
| 120 | postUp = '' | ||
| 121 | ip route add 100.64.0.0/24 dev tailscale0 | ||
| 122 | ip route add 100.100.100.100/32 dev tailscale0 | ||
| 123 | ''; | ||
| 124 | postDown = '' | ||
| 125 | ip route del 100.64.0.0/24 dev tailscale0 | ||
| 126 | ip route del 100.100.100.100/32 dev tailscale0 | ||
| 127 | ''; | ||
| 128 | 119 | ||
| 129 | peers = [ | 120 | peers = [ |
| 130 | { | 121 | { |
| 131 | allowedIPs = [ | 122 | allowedIPs = [ |
| 132 | "0.0.0.0/0" | 123 | "0.0.0.0/0" |
| 133 | "::0/0" | 124 | "::0/0" |
| 134 | ]; | 125 | ]; |
| 135 | endpoint = "45.134.142.206:51820"; | 126 | endpoint = "45.134.142.206:51820"; |
| 136 | publicKey = "H5t7PsMDnUAHrR8D2Jt3Mh6N6w43WmCzrOHShlEU+zw="; | 127 | publicKey = "H5t7PsMDnUAHrR8D2Jt3Mh6N6w43WmCzrOHShlEU+zw="; |
| 137 | } | 128 | } |
| 138 | ]; | 129 | ]; |
| 130 | }; | ||
| 131 | wg1 = { | ||
| 132 | address = [ | ||
| 133 | "10.0.13.2/24" | ||
| 134 | "fd00:b0ba:cafe:babe::2/64" | ||
| 135 | ]; | ||
| 136 | privateKeyFile = config.age.secrets.wg1_demiurge.path; | ||
| 137 | listenPort = 51820; | ||
| 138 | mtu = 1420; | ||
| 139 | table = null; | ||
| 140 | postUp = '' | ||
| 141 | # IPv4 NAT | ||
| 142 | iptables -t nat -I POSTROUTING 1 -s 10.0.13.4/32 -o wg0 -j MASQUERADE | ||
| 143 | # IPv6 NAT | ||
| 144 | ip6tables -t nat -I POSTROUTING 1 -s fd00:b0ba:cafe:babe::4/128 -o wg0 -j MASQUERADE | ||
| 145 | |||
| 146 | # IPv4 Forwarding Chain | ||
| 147 | iptables -N WG1-FWD | ||
| 148 | iptables -I FORWARD 1 -j WG1-FWD | ||
| 149 | iptables -A WG1-FWD -i wg1 -o wg1 -j ACCEPT | ||
| 150 | iptables -A WG1-FWD -i wg1 -o wg0 -j ACCEPT | ||
| 151 | iptables -A WG1-FWD -i wg0 -o wg1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | ||
| 152 | |||
| 153 | # IPv6 Forwarding Chain | ||
| 154 | ip6tables -N WG1-FWD | ||
| 155 | ip6tables -I FORWARD 1 -j WG1-FWD | ||
| 156 | ip6tables -A WG1-FWD -i wg1 -o wg1 -j ACCEPT | ||
| 157 | ip6tables -A WG1-FWD -i wg1 -o wg0 -j ACCEPT | ||
| 158 | ip6tables -A WG1-FWD -i wg0 -o wg1 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | ||
| 159 | ''; | ||
| 160 | preDown = '' | ||
| 161 | # IPv4 NAT | ||
| 162 | iptables -t nat -D POSTROUTING -s 10.0.13.4/32 -o wg0 -j MASQUERADE | ||
| 163 | # IPv6 NAT | ||
| 164 | ip6tables -t nat -D POSTROUTING -s fd00:b0ba:cafe:babe::4/128 -o wg0 -j MASQUERADE | ||
| 165 | |||
| 166 | # IPv4 Forwarding Chain | ||
| 167 | iptables -D FORWARD -j WG1-FWD | ||
| 168 | iptables -F WG1-FWD | ||
| 169 | iptables -X WG1-FWD | ||
| 170 | |||
| 171 | # IPv6 Forwarding Chain | ||
| 172 | ip6tables -D FORWARD -j WG1-FWD | ||
| 173 | ip6tables -F WG1-FWD | ||
| 174 | ip6tables -X WG1-FWD | ||
| 175 | ''; | ||
| 176 | |||
| 177 | peers = [ | ||
| 178 | { | ||
| 179 | # saklas.epistemia | ||
| 180 | publicKey = "XvRailvccuc7LJIF4aaYM/MLkU4upiprwFlCfBllhl0="; | ||
| 181 | endpoint = "157.180.125.215:51820"; | ||
| 182 | allowedIPs = [ "10.0.13.1/32" "fd00:b0ba:cafe:babe::1/128" ]; | ||
| 183 | persistentKeepalive = 25; | ||
| 184 | } | ||
| 185 | { | ||
| 186 | # hastur.epistemia | ||
| 187 | publicKey = "1ketYziRhoUmpbrj/60O5DYbcPacvmEoFQqa/NntSnc="; | ||
| 188 | allowedIPs = [ "10.0.13.3/32" "fd00:b0ba:cafe:babe::3/128" ]; | ||
| 189 | persistentKeepalive = 25; | ||
| 190 | } | ||
| 191 | { | ||
| 192 | # iphonebob.epistemia | ||
| 193 | publicKey = "Xn0EmeRZdpMejBgzr98mYtb/2f5O58GAzQLNZV/SS30="; | ||
| 194 | allowedIPs = [ "10.0.13.4/32" "fd00:b0ba:cafe:babe::4/128" ]; | ||
| 195 | persistentKeepalive = 25; | ||
| 196 | } | ||
| 197 | { | ||
| 198 | # lab.epistemia | ||
| 199 | publicKey = "iMDEwvXjPAlQH8ZCmP63FM5ICYIFIX5XIyGxjnXoNVE="; | ||
| 200 | allowedIPs = [ "10.0.13.5/32" "fd00:b0ba:cafe:babe::5/128" ]; | ||
| 201 | persistentKeepalive = 25; | ||
| 202 | } | ||
| 203 | ]; | ||
| 204 | }; | ||
| 139 | }; | 205 | }; |
| 140 | }; | 206 | }; |
| 141 | 207 | ||
| @@ -155,13 +221,6 @@ | |||
| 155 | }; | 221 | }; |
| 156 | 222 | ||
| 157 | services = { | 223 | services = { |
| 158 | # vpn | ||
| 159 | # TODO replace with wireguard again | ||
| 160 | tailscale = { | ||
| 161 | authKeyFile = config.age.secrets.tailscale_demiurge.path; | ||
| 162 | extraSetFlags = [ "--advertise-exit-node" ]; | ||
| 163 | }; | ||
| 164 | |||
| 165 | # media server | 224 | # media server |
| 166 | jellyfin = { | 225 | jellyfin = { |
| 167 | enable = true; | 226 | enable = true; |
| @@ -275,7 +334,7 @@ | |||
| 275 | openssh.listenAddresses = [ | 334 | openssh.listenAddresses = [ |
| 276 | { addr = "127.0.0.1"; port = 22; } | 335 | { addr = "127.0.0.1"; port = 22; } |
| 277 | { addr = "192.168.1.2"; port = 22; } | 336 | { addr = "192.168.1.2"; port = 22; } |
| 278 | { addr = "100.64.0.2"; port = 22; } | 337 | { addr = "10.0.13.2"; port = 22; } |
| 279 | ]; | 338 | ]; |
| 280 | 339 | ||
| 281 | # llm | 340 | # llm |
| @@ -764,8 +823,5 @@ | |||
| 764 | }; | 823 | }; |
| 765 | }; | 824 | }; |
| 766 | 825 | ||
| 767 | # extra systemd stuff | ||
| 768 | systemd.services.nginx.after = [ "tailscaled-autoconnect.service" ]; | ||
| 769 | |||
| 770 | system.stateVersion = "24.05"; | 826 | system.stateVersion = "24.05"; |
| 771 | } | 827 | } |
