我的主机上有几个静态的公共IP地址。我想把那个IP分配给一个特定的容器,但是我真的找不到任何关于这个的更新信息。我试图创建一个新的网络,使用辅助IP并将它分配给一个容器,但是在这样做之后,容器就失去了internet连接。
我所做的:
lxc network create publicip #New network
lxc network add publicip ipv4.address 10.3.3.3/30 #add random local IP
lxc network add publicip ipv4.routes 138.*.16.151/32 #add route to the actual public IP that I want to assign to the container
lxc network attach publicip myContainer eth0 #attach it as eth0 interface to the container
lxc config device set myContainer eth0 ipv4.address 10.3.3.2 #assign container local IP from the range of the new network I created with first command
你知道我做错了什么吗?我的容器失去了与外界的连接?
输出: lxc网络显示公开
config:
ipv4.address: 10.3.3.3/30
ipv4.nat: "true"
ipv4.routes: 138.201.16.151/32
ipv6.address: fd42:cefa:6941:1e25::1/64
ipv6.nat: "true"
description: ""
name: publicip
type: bridge
used_by:
- /1.0/instances/myContainer
managed: true
status: Created
locations:
- none
以及lxc列表的输出:
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| myContainer | RUNNING | 10.3.3.2 (eth0) | fd42:cefa:6941:1e25:216:3eff:fefe:2e29 (eth1) | CONTAINER | 0 |
| | | | fd42:cefa:6941:1e25:216:3eff:fe6a:3cdc (eth0) | | |
| | | | fd42:cefa:6941:1e25:216:3eff:fe0d:a57c (eth2) | | |
+--------+---------+---------------------+-----------------------------------------------+-----------+-----------+
发布于 2020-10-19 13:19:06
通过从主机的/etc/network/接口中删除ip并将IP添加到容器中解决问题,如下所示:
lxc config device add c1 eth0 nic nictype=routed parent=eth0 ipv4.address=publicIP
https://askubuntu.com/questions/1284675
复制相似问题