Script to find the IP from hostname
Hi everyone,
I know that if we give "ping hostname" will give the IP address. This is good if I have 5 to 6 hosts.If I have hundreds of hosts ping cmd is very painful to do. So I need script to find all those IP address......Can anyone help me out with this. Thanks and advance |
HI,
do you have maybe a file with a list of hostnames ? It would be quickly done like this: Code:
# vim hostnames_file.txt Code:
vim test-hostnames.sh Code:
# ./test-hostnames.sh hostnames_file.txt |
another way of doing this is as the following:
Code:
# while read domain; do host -t A $domain; done < /tmp/hostnames |
Ping may or may not resolve a hostname. It may not be possible to query a secure system to access it's hostname.
|
^^^ totally agree,
nslookup or dig might be better. |
All times are GMT -5. The time now is 09:37 PM. |