5

On linux I can list all entries in the DNS table ending with "80" using:

dig axfr my.domain | grep 80

How do I do that with NSlookup on windows? I have tried starting NSlookup and typing

ls my.domain

Which gives me the full list. But how do I filter the resultset like using grep on linux?

I have tried:

C:\Users\user>nslookup -ls my.domain | find "80"
*** Invalid option: ls

but it gives the above error.

u123
  • 560

2 Answers2

5

I think what you're looking for is the find command.

nslookup -ls my.domain | find "80"

Note though that neither grep 80 nor find "80" will only return those entries ending in 80. They will both return entries that contain 80. If you truly only want entries that end in 80 it would be better to use findstr with the /e flag (matches the pattern if at the end of a line) as well as including a leading period (otherwise you might get something like 10.21.37.180).

nslookup -ls my.domain | findstr /e ".80"

You can also use Cygwin, which is "a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows."

EDIT

If nslookup -ls my.domain is giving you an error, then you might try

 echo ls my.domain | nslookup | find "80"

or if you really only want the ones that end in .80 try

 echo ls my.domain | nslookup | findstr /e ".80"
Drew Chapin
  • 6,270
5

I believe more elegant solution is to use powershell. It's certainly better than using Cygwin on a Windows machine - for one thing it's built-in.

In Bash we write:

dig axfr my.domain | grep "80"

The equivalent in Powershell would be:

nslookup -ls my.domain | where {$_ -match "80"}

Or even better to use regex to make sure only lines ending with 80 are going to be matched:

nslookup -ls my.domain | where {$_ -match "(80)$"}

Additionally if you are interested in domain zone transfers, you might find this answer useful (and here's a GitHub project).

mnmnc
  • 4,257