diff --git a/kvm.go b/kvm.go index ca31b4c7a61..d25c59cf01b 100644 --- a/kvm.go +++ b/kvm.go @@ -638,13 +638,18 @@ func (d *Driver) getIPByMacFromSettings(mac string) (string, error) { log.Warnf("Failed to decode dnsmasq lease status: %s", err) return "", err } + ipAddr := "" for _, value := range s { if strings.ToLower(value.Mac_address) == strings.ToLower(mac) { - log.Debugf("IP address: %s", value.Ip_address) - return value.Ip_address, nil + // If there are multiple entries, + // the last one is the most current + ipAddr = value.Ip_address } } - return "", nil + if ipAddr != "" { + log.Debugf("IP address: %s", ipAddr) + } + return ipAddr, nil } func (d *Driver) GetIP() (string, error) {