NSlookup и Linux Dig

2800
u123

В Linux я могу перечислить все записи в таблице DNS, заканчивающиеся на «80», используя:

dig axfr my.domain | grep 80 

Как мне сделать это с NSlookup на Windows? Я попытался запустить NSlookup и набрав

ls my.domain 

Что дает мне полный список. Но как мне отфильтровать набор результатов, например, используя grep на linux?

Я пытался:

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

но это дает вышеуказанную ошибку.

5
Я думаю, что было бы лучше перефразировать ваш вопрос о том, как получить grep-подобную функциональность в Windows. mtak 9 лет назад 2

2 ответа на вопрос

5
mnmnc

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).

Это может быть лучше, чем Cygwin, но Git Bash, к примеру, не помещает все содержимое на ваш компьютер. Кроме того, вам не нужно устанавливать * каждый пакет Cygwin *, только те, которые вам нужны. trysis 9 лет назад 0
4
Drew Chapin

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" 
Я попробовал это увидеть отредактированный пост на Windows 7, но он выдает ошибку. Я попытался бот из cmd и из запущенного экземпляра nslookup.exe u123 9 лет назад 0
Какую версию Windows вы используете? Drew Chapin 9 лет назад 0