Ubuntu虚拟机模板导入改完IP后再重启,虚拟机IP会变成模板设置的IP,已知通过castool修改的IP
1、清理/etc/network/interfaces静态 IP 配置无效
2、备份迁移/etc/udev/rules.d/70-persistent-net.rules(现场为 70-snap 类同名规则)
完成操作后测试,IP 回滚故障依旧
3、/etc/netplan/50-cloud-init.yaml,这是Ubuntu 系统内的网络配置文件,查看文件注释,This file is generated from information provided by the datasource,Changes to it will not persist across an instance reboot. 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}
Ubuntu系统启动时会自动生成50-cloud-init.yaml加载模板原始网络信息,优先级高于平台下发 IP,覆盖 castools 配置,导致 IP 变回模板地址。
解决方案是在模板内部禁用 cloud-init 的网络自动配置,之后重新封装模板,从根源避免 IP 重置