Skip to content

Instantly share code, notes, and snippets.

@nomaster
Created April 27, 2021 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomaster/9339e521f2e9dc260882af48781c39ce to your computer and use it in GitHub Desktop.
Save nomaster/9339e521f2e9dc260882af48781c39ce to your computer and use it in GitHub Desktop.
Podman network on existing bridge interface
{
"cniVersion": "0.4.0",
"name": "vlan24",
"plugins": [
{
"type": "bridge",
"bridge": "br24",
"ipam": {
"type": "static",
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"addresses": [
{
"address": "10.11.0.17/24",
"gateway": "10.11.0.1"
}
]
}
}
@nomaster
Copy link
Author

nomaster commented Apr 27, 2021

This creates a podman network using an existing bridge interface on the host. In this case, it is used to directly attach the container to a VLAN 24, in which the host has otherwise no IP connectivity.

  1. Create the above file as /etc/cni/net.d/vlan24.conflist
  2. Confirm the configuration with sudo podman network inspect vlan24
  3. Run a container on the network podman run -d --network vlan24 docker.io/nginx
  4. Try connecting to the container curl -I http://10.11.0.17

Note that only one container can be started with the configuration above, which uses a single IP address. This can probably be expanded with specifying a network address and an additional range for the IP address leases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment