Skip to content
Tutorials Center
My learning

Topics

Lesson 19 of 37 ยท Networking

Podman Networks and Netavark

Understand how Podman networks work: the default bridge, Netavark and Aardvark DNS, creating user-defined networks, subnets, internal networks and connecting containers.

Every container needs a way to talk to something: other containers, your host, the internet. Podman solves this with networks. A network is a virtual switch on your machine; containers plug into it and get an IP address. Most of the confusing moments with containers (a service that cannot find its database, a port that does not answer) come down to which network a container is on and how names are resolved there.

This lesson explains the pieces Podman uses (Netavark and Aardvark DNS), the default network, and how to create your own networks with chosen subnets. Podman is not available in the browser, so the commands below are read-only; the runnable examples are small Python stand-ins that model the same arithmetic and rules.

The moving parts

Since Podman 4, container networking is handled by two small programs written in Rust:

  • Netavark creates the virtual interfaces, bridges, firewall rules and port forwarding when a container starts, and removes them when it stops.
  • Aardvark DNS answers name lookups for containers on networks that have DNS enabled, so db can resolve to the IP address of a container named db.

The older CNI plugins are gone from current Podman. If you read an old guide that mentions cni-podman0, the same idea now appears as podman0 (the default bridge) and podman1, podman2 for networks you create.

Podman networking

Bridge A virtual switch on the host.
Netavark Builds interfaces and firewall rules.
Aardvark DNS Resolves container names.
Container Gets an IP on each network.

Netavark sets it up, Aardvark answers names.

1 / 2

The default network

List what exists on a fresh install:

Terminal
podman network ls

You will see one network called podman. It is a bridge with the subnet 10.88.0.0/16 and gateway 10.88.0.1. Two facts matter:

  1. Containers on it can reach each other by IP address and can reach the internet through NAT.
  2. DNS is not enabled on the default network. A container named db is not resolvable by name there. This surprises people coming from Docker's user-defined networks, and it is the main reason to create your own network.
Terminal
podman network inspect podman

The JSON shows the subnets, driver (bridge), dns_enabled (false) and internal (false) fields.

Creating a network

Terminal
podman network create appnet
podman network create --subnet 10.89.5.0/24 --gateway 10.89.5.1 backend
podman network create --internal isolated
podman network create --ipv6 dual
  • Without --subnet, Netavark picks the next free block, starting at 10.89.0.0/24 and counting up (10.89.1.0/24, ...).
  • --internal makes a network with no route to the outside: containers can talk to each other but not to the internet.
  • --ipv6 enables a dual-stack network.
  • --driver accepts bridge (default), macvlan and ipvlan for putting containers directly on your LAN.
  • Networks you create have DNS enabled by default. Add --disable-dns to turn it off.

Attach containers with --network:

Terminal
podman run -d --name db --network appnet docker.io/library/postgres:17
podman run -d --name api --network appnet docker.io/library/nginx:stable

Now api can reach the database at the host name db. A container can join several networks: pass --network more than once, or add one later with podman network connect backend api (and remove it with podman network disconnect).

Working out the next subnet

Netavark's choice is plain arithmetic. This stand-in mimics it: it starts from 10.89.0.0/24 and walks upward until it finds a block that does not overlap an existing network. It is a model, not Podman's code.

Python Next free subnet (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

How a container gets its address

When a container starts, Netavark creates a pair of virtual network cards (a veth pair): one end inside the container's network namespace, the other attached to the bridge on the host. The container receives an address from the network's subnet and the bridge's address as its default gateway. Packets leaving for the internet are NAT-ed (masqueraded) so they appear to come from the host.

You can ask for fixed values, but only on a network with a subnet you control:

Terminal
podman run -d --network backend --ip 10.89.5.20 --name cache docker.io/library/redis:7

Check the address a container received:

Terminal
podman inspect -f '{{ (index .NetworkSettings.Networks "backend").IPAddress }}' cache

Spotting overlapping networks

Two networks must never share a subnet; Netavark refuses to create one that overlaps another, and a VPN or corporate network that already uses 10.x space can collide with the defaults. Picking subnets deliberately avoids this.

Python Subnet overlap checker (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Choose one private range for all your container networks (for example 10.89.0.0/16 for containers, nothing else) and note it down. It makes VPN conflicts easy to avoid.

Cleaning up

Terminal
podman network ls
podman network rm backend
podman network prune

rm refuses to delete a network that containers still use unless you pass --force, which also removes those containers. prune removes every network not used by at least one container.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which program answers container name lookups in current Podman?

    Aardvark DNS resolves container names on networks with DNS enabled; Netavark builds the interfaces and firewall rules.
  2. 2. Why can't a container named db be found by name on the default podman network?

    The default network has dns_enabled set to false. Networks you create have DNS on.
  3. 3. What does --internal do when creating a network?

    Containers on an internal network can reach each other but have no route to the internet.
  4. 4. How do you add a running container to a second network?

    podman network connect attaches a container to another network without recreating it.

Summary

  • Netavark builds interfaces, bridges and firewall rules; Aardvark DNS resolves container names.
  • The default podman network is 10.88.0.0/16 and has no DNS.
  • podman network create makes networks with DNS; use --subnet, --internal, --ipv6 and --driver to shape them.
  • A container can join several networks with --network or podman network connect.
  • Plan subnets so they never overlap your VPN or LAN.

Next: Publishing Ports and Name Resolution