blog advertising is good for you


blog advertising is good for you
User login

Flushing the DNS Cache

sockettrousers asks:

Question

Our company has a ‘clever’ DNS setup. Outside the firewall anything.ourdomain.com resolves to www.ourdomain.com inside the firewall wiki.ourdomain.com resolves to a Confluence running on a server inside the firewall.

The windows machines handle this fine. My MacBook Pro running Tiger gets confused. When I move from outside the firewall to inside the firewall (either by moving physically or connecting to the VPN) it still picks up the old DNS record. I guess OS X is caching the DNS server entries between DHCP session. Any way to flush this cache or change the behaviour?

Rog

Answer

When a program requests a DNS lookup through Mac OS X it will eventually find its way down to the lookupd daemon in the System Configuration getup. To make life faster, yes, it has a cache for all responses. Forseeing problems like this, or perhaps in response to them ages ago, you can tell lookupd to flush said cache on-demand.

lookupd -flushcache

The only caveat being that it sometimes doesn’t work for me. I’d recommend closing out all programs that use DNS, flush it, then open them back up for the best chance at success.

Average rating
(0 votes)
About Adam Knight
Adam Knight's picture

Author Biography

Adam Knight is one of the founders of Mac Geekery and is a geek at heart. Programmer by day, hacker by night, his daily life revolves around the Macintosh platform, which he has been a user and programmer for since the early days of System 7 when his LCII replaced his Apple //c.

In-between tech jobs, he’s managed to learn the basics of any web hacker: PHP, MySQL, Perl, Apache, Linux, *BSD, and the intricacies of ./configure —prefix=~/bombshelter/. Today, codepoet is concentrating on blogging again, writing some software for the Mac by himself (including Notae) and for his company (such as Switchblade) and has a few other toys coming out soon.

Bug him over AIM or email [link fixed].

I didn’t even realize that there was a -flushcache option in the lookup daemon. To reset the cache, I have always run:

sudo killall -HUP lookupd

This resets the DNS cache by stopping and restarting lookupd entirely, which is a bit drastic given that there’s a much less invasive way to do it. I’ll have to remember that flushcache switch!

Post new comment
The content of this field is kept private and will not be shown publicly.
3 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.