Regarding the Keil documentation, for changing the MAC address we can use the netIF_SetOption function. I configured my STM MCU network like this:
//Set New mac_addr value
netIF_SetOption (NET_IF_CLASS_ETH | 0, netIF_OptionMAC_Address, mac_addr, sizeof (mac_addr));
It successfully changed my Mac address but in Wireshark, I saw that it created a duplicate IP address device ( one with the old Mac address "1E-30-6C-A2-45-5F" and the new one with the new Mac address "6a:ad:d5:59:52:19")
I need to know how I can change the MAC address while the old value is being removed(prevent from a duplicate IP)
I appreciate your help.
When you change the MAC address, the device will no longer respond to requests directed to the old MAC address. The IP address, however, is still the same. If you also want a new IP address after changing the MAC address, it is necessary to stop (netDHCP_Disable) and restart the DHCP client (netDHCP_Enable).
In your case, Wireshark knew the history, so it found that two devices with different MAC addresses are responding to the same IP address. This is actually not true, as it is the same device that just changed its MAC address. The solution is to clear the Wireshark log. Alternatively, you can close and restart Wireshark to avoid this notification.
Dear Franc Urbanc ,
I really appreciate your response and your explanations.
Sorry for the late in my response due to I was checking your explanation in different conditions. Actually, our device works excellent in sending the data to a PC but it has problem with connecting to another embedded board( our device can send the UDP data but it doesn't respond to any ping command when we connected it to an embedded board).
I am still waiting for getting a managed router to see the network problem and continue this question.
I am thankful for your help.
When a device has already communicated with another evaluation board, the MAC addresses are cached on both ends. If you change the MAC address but not the IP address, the second evaluation board still caches the old MAC address. The default ARP cache timeout is 150 seconds. This means you need to clear the ARP cache (netARP_ClearCache) on the evaluation board or wait for the entry to time out.
Changing the default MAC address is usually at device startup, but not while the device is running, as it may cause communication issues.
I really appreciate it. Excellent Point.