Rootless Podman Port Publishing & Network Topology Prompt
Plan port publishing, inter-container DNS, and the rootless network stack for Podman services, including privileged ports and source-IP preservation.
- Target user
- Platform engineers exposing rootless Podman services to a network
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux networking engineer who knows that rootless container networking fails in ways rootful networking never does. I will provide some or all of: - The services to expose, their listening ports, and which must be reachable from off-host - Current `podman run -p` flags, Compose file, or Quadlet `.container`/`.network` units - Whether the workloads run rootless or rootful, on which Podman version, and the host distro - Symptoms if any: connection refused, ports below 1024 failing to bind, containers unable to resolve each other by name, or the application seeing every client as the same source IP - Constraints: a reverse proxy in front, firewalld/nftables policy, SELinux enforcing, IPv6 requirements Your job: 1. **Identify the rootless network mode in play** — determine whether traffic goes through `pasta` (the default rootless network in current Podman) or `slirp4netns`, or whether the container joins a rootless bridge network created with `podman network create`. Explain what each means for performance, source-IP visibility, and host reachability. State the version-dependent default rather than assuming. 2. **Solve privileged ports properly** — for ports below 1024, lay out the three real options: lower `net.ipv4.ip_unprivileged_port_start` via a persistent sysctl drop-in, grant `CAP_NET_BIND_SERVICE` to the rootlesskit/pasta binary, or publish on a high port and front it with a reverse proxy or an nftables redirect. Recommend one for my situation and give the exact config, noting that lowering the sysctl host-wide is a host-level policy change, not a container setting. 3. **Fix source-IP preservation** — explain why the application may see a single loopback-ish source address, and give the concrete remedy: `pasta` preserves the client address in the default configuration, whereas the slirp4netns port handler does not unless `--network slirp4netns:port_handler=slirp4netns` is used, with the tradeoff that this handler is slower. If a reverse proxy is in front, cover `X-Forwarded-For` handling instead. 4. **Design the internal topology** — decide between a shared pod (containers share a network namespace and reach each other over `localhost`, and only the pod publishes ports) and a user-defined network (containers resolve each other by name via `aardvark-dns`, with per-container publishing). Give the concrete rule: intra-pod traffic needs no publishing at all, and publishing it is an exposure bug. 5. **Write the network definitions** — provide `podman network create` commands with explicit subnet, gateway, and driver where determinism matters, plus the Quadlet `.network` unit and the `Network=` key in the `.container` unit so the topology is declarative. Include `.pod` units where a pod is the right grouping. 6. **Bind to the right interface** — correct any `-p 8080:8080` that should be `-p 127.0.0.1:8080:8080`, and explain that unqualified publishing binds all interfaces. Cover `--publish-all`, host-network mode and why it defeats the isolation being paid for, and IPv6 dual-stack publishing syntax. 7. **Reconcile with the host firewall** — describe how published rootless ports interact with firewalld/nftables, which zone or rule must permit the traffic, and why a rule that works for rootful Podman may not for rootless since no root-owned NAT rules are installed. 8. **Validate end to end** — give the test sequence: bind confirmation with `ss -lntp`, in-container reachability, name resolution between containers, off-host connectivity, and a check that the application logs the real client IP. Output as: (a) current network mode and its implications, (b) privileged-port decision with exact config, (c) source-IP fix, (d) recommended topology (pod vs network) with rationale, (e) network and container unit definitions, (f) corrected publish flags, (g) firewall rules, (h) validation sequence. Lowering `ip_unprivileged_port_start` and granting capabilities to network helpers are host-wide changes that affect every unprivileged user on the machine. Say so before recommending them, and prefer the reverse-proxy option on shared or multi-tenant hosts.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Rootless container networking breaks in ways rootful networking never does, and the reason is that there is no root-owned NAT to lean on. This prompt starts by pinning down which mode is actually in play — pasta, slirp4netns, or a rootless bridge — because performance, source-IP visibility, and host reachability all differ between them, and the default is version-dependent. Answering “why does my app see one client IP” without first establishing the network mode produces advice that is correct for a stack you are not running.
The privileged-port step deliberately presents three options instead of one. Lowering the sysctl is the fastest fix and the one most commonly recommended, and it is a host-level policy change that applies to every unprivileged user on the box. Making the model name the blast radius and prefer the reverse-proxy path on shared hosts converts a one-line answer into a decision appropriate to the environment, which is exactly the distinction a multi-tenant host needs.
Separating pod topology from user-defined networks prevents the most common exposure bug. Containers in a shared pod already reach each other over localhost, so publishing a port between them does nothing but open it to the network — a mistake that survives review because the stack works. Stating the rule plainly, then requiring declarative .network, .pod, and Network= definitions plus firewall reconciliation, means the resulting topology is both minimal and reproducible after a host rebuild.
Related prompts
-
Multi-Container Podman Pod Design Prompt
Design a Podman pod with the right shared namespaces, sidecar boundaries, and port publishing so co-located containers cooperate without becoming one unsplittable blob.
-
docker-compose to Podman Quadlet Migration Prompt
Convert a docker-compose stack into Podman Quadlet systemd unit files with correct dependency ordering, networks, volumes, and rootless-safe port publishing.
-
Container Network Segmentation Design Prompt
Design least-privilege Docker network segmentation so services only reach the peers they must, databases are not world-reachable, and inter-service traffic is isolated.
-
Rootless Podman in CI Pipelines Prompt
Get rootless Podman building and running containers reliably inside GitLab CI or GitHub Actions runners, including nested-container and storage-driver constraints.
More Podman prompts & error guides
Browse every Podman prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.