Sip realtime ipaddr conflicts (work-around, feature request)

Ran into a problem today where user gets fast busy for all calls… registering OK but not authorized to make calls… because SIP does realtime lookup by IP, finds a match from an old device no longer registered (but still exists in DB using up a valid IP addr that has been released in the DHCP scope for reassignment), and the device fails proxy authentication because device name/password does not match that of the old device that had the same IP addr.

I haven’t fixed the problem yet, but this is my work-around plan. Create a script that replaces the ipaddr column with 0.0.0.0 if host=dynamic. Run this as a cron job during least likely phone activity (e.g. midnight) a little more often than DHCP leases expire, and should avoid any problems.

Is there a more elegant way to address this problem of decommissioned devices causing IP addr conflicts in database?

Feature request for SIP RealTime: check for all matches of ipaddr, not just the first one, and try each in succession if the first ones fail. Send a warning to the logs etc about this conflict but operate gracefully

I’ve created the work-around script, looks like this on CentOS:

vi /etc/cron.daily/flush-asterisk-sipdb-ip
mysql -u asterisk -pYOURPASSWORD -B -e"update asterisk.sip_peers set ipaddr=‘0.0.0.0’ where host=‘dynamic’;