Flushing your DNS cache on Mac OSX 10.4, 10.5 and 10.6
If like me, you have to transfer websites between servers from time to time and you use an Apple Mac, you’ll probably need to know how to flush your DNS on Mac OSX (flushing is the term used for removing of all records to force an update).
For all versions of OSX, the simplest way to flush your DNS cache is to start “Terminal” which you can find in “Applications” > “Utilities” > “Terminal”. Once you’ve done that type (or copy + paste) into the Terminal:
OSX 10.5 (Leopard) & 10.6 (Snow Leopard):
dscacheutil -flushcache
OSX 10.4 (Tiger) and previous:
Type (or copy + paste) into the Terminal:
lookupd -flushcache
Then hit the Enter key.
You may also find that you need to restart your browser – you shouldn’t really need to but I find I sometimes do.
If you use Firefox, you might want to consider adding the extension “ShowIP” which is a very simple indicator that show the IP address(es) of the website you’re currently looking at in the Firefox status bar (at the bottom):
You can also use the Mac OSX Terminal (or a *nix terminal/console) to check DNS records using dig, for example to check the IP address(es) for www.thedotproduct.org you could type into the Terminal:
dig a www.thedotproduct.org
Which says “dig for a DNS ‘A’ record for ‘www.thedotproduct.org’”.
The output will look something like this:
Neil-Craigs-Mac-mini:~ neilcraig$ dig a www.thedotproduct.org ; <<>> DiG 9.6.0-APPLE-P2 <<>> a www.thedotproduct.org ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 40181 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.thedotproduct.org. IN A ;; ANSWER SECTION: www.thedotproduct.org. 7200 IN A 80.68.94.84 ;; Query time: 178 msec ;; SERVER: 192.168.1.254#53(192.168.1.254) ;; WHEN: Tue Jun 8 10:27:27 2010 ;; MSG SIZE rcvd: 55
You’ll see that the IP address is given as 80.68.94.84.
Other types of DNS records you can dig for include MX e.g. “dig mx thedotproduct.org” which shows which Email server(s) will be used for the domain thedotproduct.org.
You can read more about the use of dig here.