NAME 名称

podman-network - Manage Podman networks
podman-network - 管理 Podman 网络

SYNOPSIS 概要

podman network subcommand
podman 网络子命令

DESCRIPTION 描述

The network command manages networks for Podman.
网络命令用于管理 Podman 的网络。

Podman supports two network backends Netavark and CNI. Netavark is the default network backend and was added in Podman version 4.0. CNI is deprecated and will be removed in the next major Podman version 5.0, in preference of Netavark. To configure the network backend use the network_backend key under the [Network] in containers.conf(5). New systems use netavark by default, to check what backend is used run podman info --format {{.Host.NetworkBackend}}.
Podman 支持两种网络后端 Netavark 和 CNI。Netavark 是默认的网络后端,并在 Podman 版本 4.0 中添加。CNI 已被弃用,并将在下一个主要的 Podman 版本 5.0 中移除,以 Netavark 为首选。要配置网络后端,请在 containers.conf(5)中使用 network_backend 键下的 [Network] 。新系统默认使用 netavark,要检查使用的后端,请运行 podman info --format {{.Host.NetworkBackend}}

All network commands work for both backends but CNI and Netavark use different config files so networks have to be created again after a backend change.
所有网络命令对两种后端都适用,但 CNI 和 Netavark 使用不同的配置文件,因此在更改后端后必须重新创建网络。

COMMANDS 命令 ¶

Command

Man Page 手册页

Description

connect

podman-network-connect(1)

Connect a container to a network
将容器连接到网络

create

podman-network-create(1)

Create a Podman network 创建一个 Podman 网络

disconnect

podman-network-disconnect(1)

Disconnect a container from a network
从网络中断开容器

exists

podman-network-exists(1)

Check if the given network exists
检查给定网络是否存在

inspect

podman-network-inspect(1)

Display the network configuration for one or more networks
显示一个或多个网络的网络配置

ls

podman-network-ls(1)

Display a summary of networks
显示网络摘要

prune

podman-network-prune(1)

Remove all unused networks
删除所有未使用的网络

reload

podman-network-reload(1)

Reload network configuration for containers
重新加载容器的网络配置

rm

podman-network-rm(1)

Remove one or more networks
删除一个或多个网络

update

podman-network-update(1)

Update an existing Podman network
更新现有的 Podman 网络

SUBNET NOTES 子网注释

Podman requires specific default IPs and, thus, network subnets. The default values used by Podman can be modified in the containers.conf(5) file.
Podman 需要特定的默认 IP 地址和网络子网。Podman 使用的默认值可以在 containers.conf(5) 文件中进行修改。

Podman network Podman 网络

The default bridge network (called podman) uses 10.88.0.0/16 as a subnet. When Podman runs as root, the podman network is used as default. It is the same as adding the option --network bridge or --network podman. This subnet can be changed in containers.conf(5) under the [network] section. Set the default_subnet to any subnet that is free in the environment. The name of the default network can also be changed from podman to another name using the default network key. Note that this is only done when no containers are running.
默认的桥接网络(称为 podman )使用 10.88.0.0/16 作为子网。当 Podman 以 root 身份运行时,默认使用 podman 网络。这与添加选项 --network bridge--network podman 相同。此子网可以在 containers.conf(5)的[network]部分中进行更改。将 default_subnet 设置为环境中空闲的任何子网。还可以使用默认网络键将默认网络的名称从 podman 更改为其他名称。请注意,只有在没有容器运行时才会执行此操作。

Slirp4netns Slirp4netns

When Podman is run as rootless, the internet connectivity is provided with slirp4netns by default. Slirp4nents uses 10.0.2.0/24 for its default network. This can also be changed in containers.conf(5) but under the [engine] section. Use the network_cmd_options key and add ["cidr=X.X.X.X/24"] as a value. Note that slirp4netns needs a network prefix size between 1 and 25. This option accepts an array, so more options can be added in a comma-separated string as described on the podman-network-create(1) man page. To change the CIDR for just one container, specify it on the cli using the --network option like this: --network slirp4netns:cidr=192.168.1.0/24.
当 Podman 以非 root 用户身份运行时,默认情况下使用 slirp4netns 提供互联网连接。Slirp4nents 默认使用 10.0.2.0/24 作为其网络。这也可以在 containers.conf(5) 中更改,但在 [engine] 部分下。使用 network_cmd_options 键并将 ["cidr=X.X.X.X/24"] 添加为值。请注意,slirp4netns 需要网络前缀大小在 1 到 25 之间。此选项接受数组,因此可以像在 podman-network-create(1) 手册页中描述的那样,将更多选项添加为逗号分隔的字符串。要仅更改一个容器的 CIDR,请在 cli 中使用 --network 选项指定,如下所示: --network slirp4netns:cidr=192.168.1.0/24

When using the default network as rootless, i.e. --network podman/bridge, then it also uses the same subnet as described above in addition to the slirp4netns subnet.
当以非 root 用户身份使用默认网络,即 --network podman/bridge 时,它还使用与上述相同的子网以及 slirp4netns 子网。

Podman network create Podman 网络创建 ¶

When a new network is created with a podman network create command, and no subnet is given with the --subnet option, Podman starts picking a free subnet from 10.89.0.0/24 to 10.255.255.0/24. Use the default_subnet_pools option under the [network] section in containers.conf(5) to change the range and/or size that is assigned by default.
当使用 podman network create 命令创建新网络时,并且没有使用 --subnet 选项指定子网时,Podman 会从 10.89.0.0/24 到 10.255.255.0/24 中选择一个空闲子网。在 containers.conf(5) 中的 [network] 部分下使用 default_subnet_pools 选项来更改默认分配的范围和/或大小。

SEE ALSO 参见 ¶

podman(1), podman-network-create(1), containers.conf(5)