DIG with Linux and Mac OSX
Linux and Mac OS use DIG to look up DNS records of a domain though you can use NSLOOKUP with MAC OSX Terminal as well. You can follow the below steps:
1. Open a terminal window. The procedure to do this depends on the operating system and desktop environment:
-On Mac OS X, click Applications
, click Utilities
, and then click Terminal
-On Linux, open a terminal window.
2. At the command prompt, type the following command. Replace example.com with the domain that you want to test.
To use a specific DNS server for the query, use the @ option.
By default, dig displays the A record for a domain. To look up a different DNS record, add it to the end of the command. The below looks up the MX records of
example.com using one of Dynu name servers ns4.dynu.com.
dig @ns4.dynu.com example.com MX
3. Dig displays a QUESTION SECTION (the request) and an ANSWER SECTION (what the DNS server sends in response to the request). In this case, we used the default options for dig, which simply looks up the A record for a domain.
From this, we can see that example.com currently points to IP address 22.214.171.124.
[user@localhost ~]# dig example.com
; <<>> DiG 9.9.4-RedHat-9.9.4-73.el7_6 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58057
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 21347 IN A 126.96.36.199
;; Query time: 8 msec
;; SERVER: 188.8.131.52#53(184.108.40.206)
;; WHEN: Tue Sep 29 15:50:42 MST 2020
;; MSG SIZE rcvd: 56