Yeah, as a neckbearded network and systems engineer I really don't understand this thing at all - it should be a non-issue. Specifically, because the OP states the machines are mostly dedicated machines, there should be absolutely no reason why they don't have dedicated hostnames in DNS, either locally or globally.
At organizations where I have held the above titled roles, DNS was one of first things to be put into service if it had not already been used. Connecting to the IP address of a dedicated machine by a nice name is pretty much what the DNS was invented for. DNS is very much not static and if you are changing a host's IP very often, you can set it up such that the DNS responds appropriately with the proper up to date IP address.
OP's script is nice but... it's solving an already solved problem, IMO.
Another great way is to just modify ~/.ssh/config
To something like this:
host alias
hostName thehostname
user your_username
I like the work in the article, but many times when I think I need to whip up a sweet script to fix some problem in the terminal I find the old neckbeards already wrote it, polished it, and left it on the shelf for me to use.
At organizations where I have held the above titled roles, DNS was one of first things to be put into service if it had not already been used. Connecting to the IP address of a dedicated machine by a nice name is pretty much what the DNS was invented for. DNS is very much not static and if you are changing a host's IP very often, you can set it up such that the DNS responds appropriately with the proper up to date IP address.
OP's script is nice but... it's solving an already solved problem, IMO.