I was asked a question this week about how to “batch script” the use of nslookup to test looking up a specific hostname. The “tricky” part was that the person wanted to use a specific DNS server instead of the default for the machine.
The person was shocked by my response so I thought I would share this tidbit in case others didn’t know…
You can actually specify the DNS server used to resolve the name you want resolved by specifying it after the name on the command line… For example:
[Wed 11/12/2008 3:30:34.12]
G:\>nslookup login.oscar.aol.com
Server: r2dc1.test.loc
Address: 192.168.0.10
Name: login.messaging.aol.com
Address: 205.188.179.233
Aliases: login.oscar.aol.com
[Wed 11/12/2008 10:05:02.64]
G:\>nslookup login.oscar.aol.com dns-01.ns.aol.com
Server: dns-01.ns.aol.com
Address: 64.12.51.132
Name: login.messaging.aol.com
Address: 205.188.153.121
Aliases: login.oscar.aol.com