I have migrated a VM running on Proxmox to Xcpng host. Despite the imported VM on Xcpng has a new NIC with new MAC address, it still retained old IP address asssigned
to the old MAC of the VM running on Proxmox. The VM is running OpenSUSE Leap 15.5 and use wicked
for network management. How to fix this?
Spoiler alert, I figured out how to fix it.
First, let’s run some commands to display some information. Here, the new MAC address for eth0
NIC is 12:ea:4c:8f:34:f2
. The IP addres 192.168.1.132
is allocated by DHCP
service running on OPNsense router for a device with MAC 02:14:98:8a:c5:2c
.
thounchey3:~ # ip ad show dev eth0 | head -3
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 12:ea:4c:8f:34:f2 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.132/24 brd 192.168.1.255 scope global eth0
So what happened here? According to an article from SUSE at [1], “On systems running SLE15, wicked will not create new DHCP Unique Identifier (DUID) automatically when NIC was replaced or the (virtualized) system was created by cloning”. and “”…The DUID is designed to be unique across all DHCP clients and servers, and stable for any specific client or server - that is, the DUID used by a client or server SHOULD NOT change over time if at all possible; for example, a device’s DUID should not change as a result of a change in the device’s network hardware.".
However, to fix this, all files under /var/lib/wicked/*.xml
should be removed. When server startup or when restarting wicked service; wicked will automatically recreate these files and server will have new DUID based on the MAC address
Before removing the XML files as suggested, let’s check if those files indeed contain the old MAC.
thounchey3:~ # grep '02:14' *
duid.xml:<duid>00:01:00:01:2c:29:26:47:02:14:98:8a:c5:2c</duid>
lease-eth0-dhcp-ipv4.xml: <client-id>ff:98:8a:c5:2c:00:01:00:01:2c:29:26:47:02:14:98:8a:c5:2c</client-id>
Yes, it’s there. So let’s remove those XML files:
thounchey3:~ # rm /var/lib/wicked/*.xml
thounchey3:~ # reboot
Once the VM boots up, I could see that it has a new IP addressed assigned by DHCP service on OPNsense router.
thounchey3:~ # ip -4 a show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.1.134/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
thounchey3:~ # grep '12:ea' /var/lib/wicked/*.xml
/var/lib/wicked/duid.xml:<duid>00:01:00:01:2d:ec:74:4d:12:ea:4c:8f:34:f2</duid>
/var/lib/wicked/lease-eth0-dhcp-ipv4.xml: <client-id>ff:4c:8f:34:f2:00:01:00:01:2d:ec:74:4d:12:ea:4c:8f:34:f2</client-id>
Awesome, I learned something new today.
References: