Create simple Nslookup script

Nslookup script

Well, very long time can be spent when you have to resolve multiple domains to IP addresses, for purpose of creating some access lists or ip tables. This is very small and useful  nslookup script that resolving a list of domain names to IP.

First create .txt file, like domani.txt or something. Then inside list all domain you want to check for IP addresses:

google.com
facebook.com
cnn.com
bbc.co.uk

Save file to root, or C: if you prefer more. Then start command prompt (CLI – Start – Run box – cmd) and  navigate to C: with switch cd .. . After you reached C:  type following script:

for /F %x in (domain.txt) do nslookup %x

As soon as you hit enter you will reach data you need. Output will look something like following:

C:\>nslookup cnn.com
Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Non-authoritative answer:
Name:    cnn.com
Addresses:  157.166.226.25
157.166.226.26

C:\>nslookup bbc.co.uk
Server:  google-public-dns-a.google.com
Address:  8.8.8.8

Non-authoritative answer:
Name:    bbc.co.uk
Addresses:  212.58.244.22
212.58.244.23
212.58.246.79
212.58.246.78

We hope that this tutorial was informative to you ant thank you for visiting our website.

Dejan Dzodan

Dejan Dzodan

IT professional for more then 15 years, mostly in financial institutions but with experience in ISP and retail. Proven in networking and overall infrastructure projects. Cisco instructor.

Leave a Reply

Your email address will not be published. Required fields are marked *


2 + 2 =