🚨   DNS for Developers pre-sale ending soon   🚨
NsLookup logo
Command line tools

How to specify a DNS server in nslookup?

Copy article link
The nslookup command line tool uses your system's DNS stub resolver by default. This resolver uses your ISP's DNS servers if you haven't changed them. You can overwrite this default setting by specifying a DNS server in the command itself.

To query a specific DNS server in nslookup, add the server's IP or hostname at the end of your command. For example:

nslookup isc.org 8.8.8.8

Nslookup will now use Google's DNS server — running at the IP address 8.8.8.8 — to query the DNS records of isc.org.

The syntax for nslookup is:

nslookup [-option ...] domain-name [dns-server]
A specific DNS server in nslookup
A specific DNS server in nslookup.

Checking the nslookup documentation from the command line

If you ever forget the order of nslookup's parameters, remember that you can check them from the command line.

On Windows, you can type nslookup /? to get a short help message.

On Linux and macOS, type man nslookup instead.

Specifying the port number

DNS uses port 53. But some DNS servers listen on a different port. In that case, you'll have to tell nslookup to use that port instead. You can change the port nslookup uses by adding the -port=42 option.

For example:

nslookup -port=42 isc.org 8.8.8.8

Setting a DNS server in nslookup's interactive mode

You can run nslookup in interactive mode by typing nslookup without a domain name. This way, you can keep an nslookup session open. To set the DNS server in interactive mode, enter server 8.8.8.8 to switch to Google's public DNS servers.

% nslookup
Default Server:  UnKnown
Address:  fe80::21c:42ff:fe00:18

> server 8.8.8.8
Default Server:  dns.google
Address:  8.8.8.8

> set port=53

If you use the DNS server's hostname, then nslookup needs to resolve that to an IP address. It will try to do so with the currently set DNS server. If that server can't resolve the IP address of the new DNS server, then you can use lserver instead. This will instruct nslookup to use your local DNS resolver instead of the one set in this nslookup session.

There is no difference between server and lserver if you use the DNS server's IP address.

Looking up DNS records at multiple servers

The nslookup command line tool doesn't have any way to check DNS records at multiple servers at once. You need to run the command multiple times if you want to check multiple servers.

A simpler way to check the DNS propagation for a domain name is using our DNS checker. This will show you the DNS records at global and regional DNS servers.