【发布时间】:2019-10-13 21:57:39
【问题描述】:
我运行 Ubuntu 18.04 云映像并尝试通过 cloud-init 配置网络。出于某种原因,当我尝试分配静态 IP 并回退到使用 DHCP 时,它忽略了我的网络。我不知道为什么,也不知道如何调试它。有谁知道我做错了什么或者我应该如何进一步解决这个问题:
这是我用来生成config.img的config.yaml:
#cloud-config
network:
version: 2
ethernets:
ens2:
dhcp4: false
dhcp6: false
addresses: [10.0.0.40/24]
gateway4: 10.0.0.1
password: secret # for the 'ubuntu' user in case we can't SSH in
chpasswd: { expire: false }
ssh_pwauth: true
users:
- default
- name: brennan
ssh_import_id: gh:brennancheung
sudo: ALL=(ALL) NOPASSWD:ALL
hostname: vm
runcmd:
- [ sh, -xc, "echo Here is the network config for your instance" ]
- [ ip, a ]
final_message: "Cloud init is done. Woohoo!"
配置中的其他一切似乎都在工作,就好像它甚至没有看到 network 部分一样。
我将.img 附加为cdrom 以阅读cloud-init。你可以在这里看到我是如何运行它的:https://github.com/brennancheung/playbooks/blob/master/cloud-init-lab/Makefile
注意:登录该框后,我可以将/etc/netplan 中的配置替换为上面的network 部分,然后重新应用它,网络就可以正常使用静态IP。所以我认为我没有遗漏任何明显的错误。这让我相信它与 cloud-init 网络模块有关,而不是 netplan 本身。
【问题讨论】:
-
经过更多研究后,我遇到了“用户数据无法更改实例的网络配置。”。显然只有供应商和云提供商可以设置网络信息?为什么? cloudinit.readthedocs.io/en/latest/topics/network-config.html
标签: cloud-init netplan