gpt4 book ai didi

ubuntu - 通过网桥为容器分配静态 IP

转载 作者:行者123 更新时间:2023-12-04 19:24:35 25 4
gpt4 key购买 nike

我在 GNS3 的虚拟机中运行容器,如下所示:
enter image description here
容器正在运行容器化的 Ubuntu 20.04,我使用桥接网络选项启动容器,它们可以与其他机器通信。但是,我需要为每个容器分配它自己的静态 IP,如图所示。我试过放置auto eth0 iface eth0 inet static address 10.10.2.2 netmask 255.255.255.0 gateway 10.10.2.99 在/etc/networks 但是它似乎不起作用。继续为 eth0 接口(interface)分配 172.17.0.0/24 范围内的 IP。
更新:
我更改了 Ubuntu 桌面主机上的 docker daemon.json 文件,为容器提供 10.10.2.0/24 子网中的 IP。

{
"bip": "10.10.2.1/24",
"fixed-cidr": "10.10.2.0/25",
"mtu": 0,
"default-gateway": "10.10.2.99"
}
但是,现在来自主机的数据包没有到达路由器。
enter image description here

最佳答案

解决方案是使用 Macvlan它为每个容器的虚拟网络接口(interface)分配一个 MAC 地址。

关于ubuntu - 通过网桥为容器分配静态 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72350167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com