Use a Different Name Server with dig(1)
Normally, dig(1) talks to the name server that is defined in your /etc/resolv.conf file. There will be times, however, when you will need to use a different name server. To illustrate, consider the need to move from one ISP to another. Let’s say your MX records are correct on the old ISP name servers, and you wish to make sure that they are correct on the new name servers before switching over to them. You could change your /etc/resolv.conf file to use the new name servers, but that isn’t advisable until you are certain the new name servers are working correctly. Instead, simply cause dig(1) itself to use the new name servers:
% dig @nameserver host
Here, the @
is
immediately followed by the hostname or IP address
of the name server to use instead of the default.
The dig(1) program will perform its lookups directly
using the name servers specified. Consider:
% dig +short mx your.domain 0 mail.your.domain 10 mail2.your.domain % dig +short @123.45.67.89 your.domain 1 mailserver.new.isp 10 mail.your.domain
Here, we first look up the local domain using the
current name servers (there is no @
argument) and find
that the output from dig(1) is correct. We then look
up the local domain at the new name server using its
IP address (the @
123.45.67.89) and discover that they are
set up incorrectly. This discovery gives you time to
fix your MX records on the new name servers before
you actually switch services to them.
Get sendmail, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.