Skip to content

Instantly share code, notes, and snippets.

@xanderificnl
Created March 27, 2023 10:09
Show Gist options
  • Save xanderificnl/1ceb94859d312c64d2b1ce1ae7bd9f05 to your computer and use it in GitHub Desktop.
Save xanderificnl/1ceb94859d312c64d2b1ce1ae7bd9f05 to your computer and use it in GitHub Desktop.
IPv6 containers

Adjust these values to your environment

OS Container Engine Network Plugin Container IPv6 pool NIC
Fedora Server 37 podman netavark 2000:10:200:30fc::/64 enp2s0f0

NetworkManager

I assigned an IPv6-prefix from another pool to enp2s0f0 with my default gateway (fe80::1%enp2s0f0).

Podman

# install podman & netavark
sudo dnf install podman netavark

# copy the default containers.conf & set netavark as network plugin
sed 's|#network_backend = ""|network_backend = "netavark"|g' /usr/share/containers/containers.conf | sudo tee /etc/containers/container.conf

Create the podman network

Option 1

podman network create --ignore --subnet=2000:10:200:30fc::/64 --ipv6 systemd-v6

Option 2

This option lets you take advantage of podman-systemd.

cat <<'EOF' |  sudo tee /etc/containers/systemd/v6.network
[Network]
IPv6=true
Subnet=2000:10:200:30fc::/64
EOF

Which means you're able to reference the network in a container unit like so:

cat <<'EOF' |  sudo tee /etc/containers/systemd/traefik.container

[Unit]
Description=The Cloud Native Application Proxy
After=local-fs.target

[Container]
Image=docker.io/traefik:v3.0

PublishPort=80:80
PublishPort=443:443

Network=v6.network
PodmanArgs=--ip6=2000:10:200:30fc::2
PodmanArgs=--volume /opt/traefik:/etc/traefik
PodmanArgs=--volume /var/run/podman/podman.sock:/var/run/docker.sock
PodmanArgs=--security-opt label:disable

[Install]
WantedBy=multi-user.target
EOF

Finish up by reloading via systemctl so that real unit files are generated:

sudo systemctl daemon-reload

ndppd

sudo dnf install ndppd

sudo mv /etc/ndppd.conf /etc/ndppd.conf.orig

cat <<'EOF' | sudo tee /tmp/ndppd.conf
route-ttl 30000
proxy enp2s0f0 {
   router yes
   timeout 500
   ttl 30000
   rule 2000:10:200:30fc::/64 {
      static
   }
}
EOF

Profit!

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