| ... | @@ -42,12 +42,16 @@ in | ... | @@ -42,12 +42,16 @@ in |
| 42 | ''; | 42 | ''; |
| 43 | | 43 | |
| 44 | # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN. | 44 | # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN. |
| 45 | systemd.services.podman-sandbox-network = { | 45 | environment.etc."cni/net.d/sandbox.conflist".text = builtins.toJSON { |
| 46 | wantedBy = [ "multi-user.target" ]; | 46 | cniVersion = "1.0.0"; |
| 47 | before = [ "nomad.service" ]; | 47 | name = "sandbox"; |
| 48 | serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; | 48 | plugins = [ |
| 49 | script = "${config.virtualisation.podman.package}/bin/podman network create --ignore --disable-dns --subnet 10.89.0.0/24 --interface-name sandbox0 sandbox"; | 49 | { type = "bridge"; bridge = "sandbox0"; isGateway = true; ipMasq = true; ipam = { type = "host-local"; ranges = [ [ { subnet = "10.89.0.0/24"; } ] ]; routes = [ { dst = "0.0.0.0/0"; } ]; }; } |
| | 50 | { type = "portmap"; capabilities.portMappings = true; snat = true; } |
| | 51 | ]; |
| 50 | }; | 52 | }; |
| | 53 | services.nomad.settings.client.cni_path = "${pkgs.cni-plugins}/bin"; |
| | 54 | services.nomad.settings.client.cni_config_dir = "/etc/cni/net.d"; |
| 51 | networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ]; | 55 | networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ]; |
| 52 | networking.firewall.extraStopCommands = '' | 56 | networking.firewall.extraStopCommands = '' |
| 53 | iptables -t raw -D PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || true | 57 | iptables -t raw -D PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || true |