[英]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. 我有许多服务器DNS名称,我想将其解析为ip addreses。 How can I do that in bash?
我怎样才能做到这一点?
You csn not do this in bash directly. 您csn不能直接在bash中执行此操作。 bash does not have builtin support for resolving ip addresses.
bash不支持解析IP地址的内置支持。 You do need a proramm that will do it.
您确实需要执行此操作的程序。
You could use dig
. 您可以使用
dig
。 Eg 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.