DNS related tools in the Terminal for Mac OS X
dscacheutil
Syntax: dscacheutil [-Options]
Usage: DNS tool to gather information and statistics of a DNS server, or to flush the dns cache of your Mac.
Options
| -h | Displays all options for dscacheutil. |
| -configuration | Shows your current DNS configuration. |
| -flushcache | Flushes the DNS cache of your computer/network. |
| -statistics | Displays DNS statistics. |
Example
| dscacheutil -statistics | Displays DNS statistics of your computer/network. |
| dscacheutil -flushcache | Flushes the DNS cache of your computer/network. |
More information
dig
Syntax:
dig
[@server] [-b address] [-c class] [-f filename] [-k filename] [-m] [-p port#]
[-q name] [-t type] [-x addr] [-y [hmac:]name:key] [-4] [-6] [name] [type] [class] [queryopt...]
Explanation: dig is an abbreviation for Domain Information Groper and is a quite neat tool to gather information about the DNS configuration of an IP or a domain.
dig can be useful when you want to:
- Troubleshooting DNS settings for a domain name.
- Find MX records of a domain which manages all emails sent to the given domain.
- Find out which DNS servers a given domain is using.
- Performing so-called "reverse DNS lookup" to retrieve the actual IP address of a DNS host name.
Usage The syntax for dig can be used in many different ways with alot of different parameters. It depends much on what kind of action you're performing. A common request can look like this:
dig @server type
In the above command each parameter represents the folllowing values:
| @server | IP-address or name server. If you specify a hostname dig will automatically resolve the hostname before the query is sent. |
| type | The name of the DNS record you want to view information about (A, MX, CNAME etc.). You can also use the keyword "ANY" to get a report of all records, or leave this out (which will default to all A records) |
Example:
dig google.com
Since I left out the "type" parameter I will get all the A records for the given domain.
This gives me the following result:
; ; <<>> DiG 9.6.0-APPLE-P2 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32635
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. 180 IN A 66.102.13.147
google.com. 180 IN A 66.102.13.103
google.com. 180 IN A 66.102.13.104
google.com. 180 IN A 66.102.13.105
google.com. 180 IN A 66.102.13.106
google.com. 180 IN A 66.102.13.99
;; Query time: 3 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Jun 22 16:05:34 2010
;; MSG SIZE rcvd: 124
More information