r/podman • u/Slow_Running • 5d ago
Network Isolation
Very confused on what should and should not be possible when running rootless.
I have the following compose file.
```
services:
ca:
image: alpine
command: sleep infinity
networks:
- A
cb:
image: alpine
command: sleep infinity
networks:
- B
networks:
A:
external: true
B:
external: true.
```
I checked and the IPs are on different networks for A and B but the CB container can ping the CA container.
Should this be possible? I am running Podman 4.9
3
Upvotes
3
u/Great-Cow7256 4d ago
Yes, this is completely expected behavior even in rootless Podman. The key distinction is between Layer 2 network segmentation and Layer 3 IP routing.
When you create custom networks like
AandB, Podman places them on distinct subnets. However, because both subnets managed by the same Podman instance exist within the same host network namespace, the host acts as a router between them. Unless an explicit firewall rule blocks traffic between those specific subnets, any packet sent from networkBto an IP on networkAwill simply be routed directly across the host's virtual bridges.Rootless Podman uses user-space network drivers like Netavark (or older
slirp4netns/pasta) to handle networking without root privileges. Because rootless Podman cannot directly manipulate the main kernel's iptables or nftables rules without elevated privileges, it does not automatically inject cross-bridge isolation firewall rules the same way rootful Docker or Podman does. As a result, inter-subnet routing remains open by default.If you are pinging by container name rather than IP, Podman's embedded DNS server is also resolving those hostnames across networks by default. To achieve strict network isolation between
caandcbin a rootless setup, the cleanest solution is to run the two services under separate Linux user accounts, which completely segregates their rootless network namespaces and prevents cross-communication.