Query dns/domains in macos using dig and nslookup via the command line
In macos you can query a domain via the command line via default nameservers with a couple of DNS querying tools, notably nslookup and dig, how that works is on the command line:
dig domain.com
or
nslookup domain.com
The results are returned to you on the command line.
Query from a different nameserver
To query another different nameserver using dig or nslookup to look up dns information or check that your nameserver is acting OK – we’ll use the public Google nameservers at:
8.8.8.8
8.8.4.4
For dig use it on the command line like so:
dig @8.8.8.8 domain.com
For nslookup:
nslookup domain.com 8.8.8.8
For nslookup interactively:
nslookup > server 8.8.8.8 Default server: 8.8.8.8 Address: 8.8.8.8#53 > bbc.com Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: bbc.com Address: 212.58.224.138 >
Or make the new nameservers default by permanently adding it to the operating system by hard coding it in the TCP/IP dns settings, for all macos versions use the Network panel in System Preferences: