Reputation: 343
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
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