Answer the question
In order to leave comments, you need to log in
How to find among the list of domain names, find the name corresponding to its IP and display this name?
Good afternoon, the second day I suffer with a simple function, but something does not work out. I have a list of servers, or rather a list of A-records. I need to resolve these A-records, find the IP corresponding to my system one and display this name in another variable.
Actually, somehow
#счетчик, начинаем с единицы, ничего не пишем
start=test
#вторая часть моего доменное имени
dns=com
#от какого по какое число у меня домены
for i in "${start}" {1..20}."$dns"; do
#вывести все это в файл
echo $i >> "/tmp/temp"
done
#смотрим этот файл
for ns in `cat /tmp/temp`; do
#тут-то и проблема, не могу понять, как лучше подобрать условие
if ; then
dig +short $ns
fi
done
Answer the question
In order to leave comments, you need to log in
#!/usr/bin/env bash
start=test
dns=com
for i in {1..20}; do
ns=$start$i.$dns
ip=`dig +short $ns`
if ; then
echo "$ns -> $ip"
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question