In my linux cluster, I've got a bunch of hostnames, while my network management log shows ip addresses(they changes sometimes according to dns).
My question is: how to quickly find out the ipv4 of some hostname, without using "ping xxxxx" to get ip address and Ctrl+c to stop it. I wish to write a simple script like:
myCommand hostname1
myCommand hostname2
myCommand hostname3
myCommand hostname4
myCommand hostname5
Which will print hostname to ipaddress mapping for me(for hostname1-5)
So how to write this "myCommand" command or shell script? Thanks.
Use host
tool from bind-tools:
$ host -4 -t A stackoverflow.com
stackoverflow.com has address 151.101.129.69
stackoverflow.com has address 151.101.1.69
stackoverflow.com has address 151.101.193.69
stackoverflow.com has address 151.101.65.69
Or dig
tool from the same package:
$ dig -4 -t A stackoverflow.com +short
151.101.129.69
151.101.1.69
151.101.193.69
151.101.65.69