diff --git a/nixos/snowglobe.nix b/nixos/snowglobe.nix index aad6417b4b6ddd1e03c89549c867fae4587c682d..5f75f93971fe0644ea41260da6a616e9ece44d3b 100644 --- a/nixos/snowglobe.nix +++ b/nixos/snowglobe.nix @@ -42,12 +42,16 @@ in ''; # Containers on `sandbox` reach the public internet and PostgreSQL, nothing else on the host or LAN. - systemd.services.podman-sandbox-network = { - wantedBy = [ "multi-user.target" ]; - before = [ "nomad.service" ]; - serviceConfig = { Type = "oneshot"; RemainAfterExit = true; }; - script = "${config.virtualisation.podman.package}/bin/podman network create --ignore --disable-dns --subnet 10.89.0.0/24 --interface-name sandbox0 sandbox"; + environment.etc."cni/net.d/sandbox.conflist".text = builtins.toJSON { + cniVersion = "1.0.0"; + name = "sandbox"; + plugins = [ + { 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"; } ]; }; } + { type = "portmap"; capabilities.portMappings = true; snat = true; } + ]; }; + services.nomad.settings.client.cni_path = "${pkgs.cni-plugins}/bin"; + services.nomad.settings.client.cni_config_dir = "/etc/cni/net.d"; networking.firewall.interfaces.sandbox0.allowedTCPPorts = [ 15432 ]; networking.firewall.extraStopCommands = '' iptables -t raw -D PREROUTING -i sandbox0 -j sandbox-egress 2>/dev/null || true