Skip to content

Instantly share code, notes, and snippets.

@maximishchenko
Created January 28, 2016 09:00
Show Gist options
  • Select an option

  • Save maximishchenko/6e6dc8b46b529f500339 to your computer and use it in GitHub Desktop.

Select an option

Save maximishchenko/6e6dc8b46b529f500339 to your computer and use it in GitHub Desktop.
nslookup(resolv)_multiple_hosts
#!/bin/bash
# Название файла со списком адресов
inputfile="hosts.txt"
# Имя файла для осуществления вывода
outputfile="addresses.txt"
# Очистка файла вывода при необходимости
> ${outputfile}
# Выполнить nslookup для каждой записи из файла со списком адресов
for i in `cat ${inputfile}`; do nslookup $i >> ${outputfile}; done
# Из файла вывода показать в stdout только строки, содержащие слова "Name" и "Address", т.е. DNS-server, FQDN, IP-address
grep 'Name\|Address' ${outputfile}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment