Is it possible to...
- run a container with podman
- which has an IP on the same subnet that the host is on
- is accessible from every other host on the subnet
- including the host itself?
I had partial success using both a macvlan and ipvlan drivers - I am able to run a container, give it an IP address, and this IP is then accessible from every other host on the network.
However, I cannot access to or from the host running the container.
I even tried with the latest versions of podman, netavark, cni-plugins built from source, which enabled the ipvlan driver with the same outcome.
I would prefer a pointer to a guide describing how to accomplish this, though troubleshooting advice is welcome, too.
To do this, I only had to add an extra ipvlan interface on the host which allowed me to talk into the containers if podman also uses ipvlan.
10.0.0.0/16
10.0.99.0/24
. This subnet should be dedicated to the containers on this host.10.0.99.1
. This is the interface the host can use to talk to the containers.sudo vim /etc/cni/net.d/podnet.conflist
and change rangeStart from10.0.99.1
to10.0.99.2
.To create the ipvlan interface with systemd, I had to
IPVLAN = podnet
to the[Network]
section of the file defining my host network interface, which will create apodnet
network interface plugged to the parent.In all fairness, the same approach worked with macvlan instead of ipvlan, but parts of my network were unable to reach the host with the MACVlan interface, so I switched to IPVlan for better interoperability.
Another issue I faced was due to podman defaulting to netavark, and netavark IPVlan support is only available in podman 4.5+, while I was still on 4.3. Switching the network backend to
cni
fixed this problem.Not exactly what you asked, but you can quite simple share the same IP address as the host, read along to see if its of any help for you:
What you need to do is add to
podman run
the--network=host
This essentially mean that you share the same network stack with the host machine, so you should take into account the following: