vSphere 7.0 + Ubuntu 18 / 20(均已尝试)
我正在尝试此博客文章中的步骤:
我也尝试过这个博客:
两次我克隆的所有 Ubuntu 18(或 Ubuntu 20)虚拟机都获得相同的 IP:
Every 30.0s: govc find / -type m -name 'k8s*' | xargs govc vm.info | grep 'Name:\|IP' primary: Thu Jun 16 21:31:29 2022
Name: k8s-worker3
IP address: 192.168.3.73
Name: k8s-worker2
IP address: 192.168.3.73
Name: k8s-worker1
IP address: 192.168.3.73
Name: k8s-master
IP address: 192.168.3.73
我认为我的设置或 DHCP 服务器本身(在 Windows Server 2012 R2 VM 上运行)一定有问题。但是,我根本没有为该 IP(192.168.3.73)保留 DHCP,更不用说为其保留 MAC 了。
我已尝试此 VMware KB 中的步骤:https://kb.vmware.com/s/article/82229
echo -n > /etc/machine-id
rm /var/lib/dbus/machine-id
ln -s /etc/machine-id /var/lib/dbus/machine-id
似乎什么都没起作用。有人可以解释一下吗确切地如何让 Cloud-Init 强制克隆的 Ubuntu VM 获取唯一/新的 IP 地址?
这是我的 Netplan YAML 文件:
root@k8s-worker2:/etc/netplan# cat 99-netcfg-vmware.yaml
# Generated by VMWare customization engine.
network:
version: 2
renderer: networkd
ethernets:
ens192:
dhcp4: yes
dhcp4-overrides:
use-dns: false
dhcp6: yes
dhcp6-overrides:
use-dns: false
nameservers:
search:
- myLab.local
addresses:
- 192.168.3.4
答案1
最后找到了解决方法——强制 Netplan 使用 MAC 来确保 DHCP 分配唯一的 IP:
https://unix.stackexchange.com/questions/419321/why-are-my-cloned-linux-vms-fighting-for-the-same-ip
cat /etc/netplan/myNetplan.yaml
network:
version: 2
ethernets:
enp3s0:
dhcp4: yes
dhcp-identifier: mac
# Last line was the fix