// Check if client asked for a specific address (which was granted by the DHCP server)
askedFor:=false
ifnewIP=="0.0.0.0"{
// Yes, client asked for a specific address. Most likely not the first time in this network.
newIP=yourIP
askedFor=true
}
for_,r:=rangeresponses{
// Check for interesting cases
ifr.destMACAddr==destMAC{
// The same client device received multiple IP addresses, let's examine further
ifr.newIPAddr==newIP{
// the handed IP is the same - this is ok, just badly configured
ifr.serverMACAddr==serverMAC{
// Same DHCP server answered.
log.Printf("MAC address %s received the same IP address multiple times via DHCP by the same server.",destMAC)
}else{
// Different DHCP servers answered, but with the same address - strange network, but ok...
log.Printf("MAC address %s received the same IP address multiple times via DHCP by different servers.",destMAC)
}
}else{
// far more interesting - one client received multiple addresses
ifr.serverMACAddr==serverMAC{
// Same DHCP server answered.
log.Printf("MAC address %s received different IP addresses (%s, %s) multiple times via DHCP by the same server.",destMAC,r.newIPAddr,newIP)
}else{
// Different DHCP servers answered, with different addresses - possibly an attempt to build up MitM
log.Printf("MAC address %s received different IP addresses (%s, %s) multiple times via DHCP by different servers (%s, %s).",destMAC,r.newIPAddr,newIP,r.serverMACAddr,serverMAC)
}
}
}
}
// Add a response entry - even if we found some "strange" behavior before.