Vladimir Fomin
Vladimir Fomin

Reputation: 343

How can I ping many hosts (by dns name and resolve it ip addresses) in bash?

I have many server DNS names and I want to resolve it ip addreses. How can I do that in bash?

Upvotes: 0

Views: 139

Answers (1)

rpy
rpy

Reputation: 4023

You csn not do this in bash directly. bash does not have builtin support for resolving ip addresses. You do need a proramm that will do it.

You could use dig. E.g. if you have your names in a file hostnamelist you could use the following script:

while read x; do echo  "$x "`dig +short $x A`; done < hostnamelist

Upvotes: 1

Related Questions