This was a silly solution to a silly problem, but may come in handy in the future for other things. A user process was establishing frequent connections to a handful of FQDNs. Not having any IP caching capability, every connection attempt was preceded by DNS lookup.

When DNS was slow, the process experienced major meltdown. An easy “fix” was to add those FQDNs to /etc/hosts. Even though they were fairly static, I did not control them and their IPs could’ve changed at any time.

And so I wrote this little script intended to run once in a while from root cron to see if the IPs have changed and to update /etc/hosts as needed. I am almost certain there was a way for me to actually fix this problem instead of working my way around it, but so many unwatched episodes…

You can grab the script here or copy it from below.


Leave A Reply

Please enter your comment!
Please enter your name here