默认的podman创建的容器网络默认不使用IPv6,仅使用IPv4。我如何配置默认值podman容器网络中同时使用IPv4和IPv6?
解决方案
创建一个双堆栈的新容器网络:
[root@shizhanxia.com ]# podman network create ip-dual-stack --ipv6
新容器可以简单地使用这个网络,并且像这样在本地是双栈的:
[root@shizhanxia.com ]# podman run -d --network=ip-dual-stack registry.access.redhat.com/ubi8:latest
对于 CNI 网络后端:
编辑或创建/etc/cni/net.d/podman.conflist包括额外的 IPv6 路由。一个例子如下:
{ "cniVersion": "0.4.0", "name": "podman", "plugins": [ { "type": "bridge", "bridge": "cni-podman0", "isGateway": true, "ipMasq": true, "hairpinMode": true, "ipam": { "type": "host-local", "routes": [ { "dst": "0.0.0.0/0" }, { "dst": "::/0" } ], "ranges": [ [ { "subnet": "10.10.0.0/16", "gateway": "10.10.0.1" } ], [ { "subnet": "aaaa:bbbb:cccc:dddd::/64", "gateway": "aaaa:bbbb:cccc:dddd::1" } ] ] }, "capabilities": { "ips": true } }, { "type": "portmap", "capabilities": { "portMappings": true } }, { "type": "firewall", "backend": "" }, { "type": "tuning" } ] }
重启默认podman现在需要网络,通常最好通过重新启动节点来执行。
对于 Netavark 网络后端:
编辑或创建/etc/containers/networks/podman.json包括一个额外的 IPv6。一个例子如下:
[ { "name": "podman", "driver": "bridge", "network_interface": "cni-podman0", "subnets": [ { "subnet": "10.10.0.0/16", "gateway": "10.10.0.1" }, { "subnet": "aaaa:bbbb:cccc:dddd::/64", "gateway": "aaaa:bbbb:cccc:dddd::1" } ], "ipv6_enabled": false, "internal": false, "dns_enabled": false, "ipam_options": { "driver": "host-local" } } ]
重启默认podman现在需要网络,通常最好通过重新启动节点来执行。
原创文章,作者:保哥,如若转载,请注明出处:https://www.shizhanxia.com/1817.html