我发现了 2014 年的一个类似问题,如何为 Juju charm 赋予静态 IP 地址 - wordpress,但答案只是说这是不可能的,但会在15.04中实现,这并没有多大帮助。
目前,juju 机器的 IP 是从 DHCP 设置的。我想设置一个静态 IP,这样它就不会改变;我是否只需通过 SSH 进入机器并修改 /etc/network/interfaces
?
编辑:
我发现 bionical 使用的是 netplan 而不是 ifupdown,但这“不会在实例间持续存在”:
cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
ethernets:
ens192:
dhcp4: true
match:
macaddress: <MAC>
set-name: ens192
有没有办法在捆绑包中指定它?
答案1
已修改/etc/netplan/50-cloud-init.yaml
(如下所示),不确定这是否是正确的方法,但机器之间的通信仍然可以进行。
juju status
一段时间内显示错误的 DNS 条目/公共地址,但最终会更新。
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
ethernets:
ens192:
match:
macaddress: <mac>
set-name: ens192
addresses:
- 192.168.1.10/24
gateway4: 192.168.1.1
nameservers:
search: [<domain>]
addresses: [192.168.1.2,192.168.1.3]