change in /etc/hosts file stays... caching?

kon21

Registered
Very odd behavior I've experienced when dealing the /etc/hosts file.
I wanted to modify the host file. I checked the ping prior to the change, made the modification to the /etc/hosts file and instantly my next ping command took the hosts file change in effect. All worked as I expected...

Now I wanted to revert back. I made the change in /etc/hosts again... and for some strange reason, the ping did not change. It keep resolving to the first change I made.

What am I missing?

The only way I found to fix this 'caching' problem is to up/down the interface.

If anyone can shed some light on this I would greatly appreciate it.

TIA
 
Hi -

Yes you're right - the information is being cached by 'lookupd' as it finds it, and by default will check it's caches before going back to an "external" source such as /etc/hosts, DNS, NIS etc. etc. You can see what hostnames are cached with:

lookupd -q host

Or flush (all) the caches with:

lookupd -flushcache

Have a look at the manpage for lookupd for more information that you ever wanted - it's not exactly a thumper of a good read, but it has plenty of info. in there. You can see stuff like how long before caches get marked invalid, what the lookup order for different information types etc. is with:

lookupd -configuration

HTH!
 
Back
Top