简体   繁体   English

如何在bash中ping许多主机(通过dns名称并解析为ip地址)?

[英]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.

相关问题 Docker容器可以访问DNS但不能解析主机 - Docker container can reach DNS but not resolve hosts 为什么在Mac OS Yosemite 10.10.1下无法ping / etc / hosts中的特定主机名? - why I can not ping the specific host name in /etc/hosts under Mac OS Yosemite 10.10.1? 我有一个被监禁的用户,无法ping主机名(仅ip地址) - I have a jailed user , that cannot ping hostnames (only ip addresses) 如何同时ping多台主机(bash)linux - How to ping several hosts at the same time (bash) linux DNS Debian linux web 服务器的所有子域解析为 127.0.0.1 而不是其正确的公共 IP 地址的问题 - DNS issue where all subdomains for Debian linux web server resolve to 127.0.0.1 instead of their proper public IP addresses 如何在Perl中找到每个接口的IP地址? - How can I find the IP addresses for each interface, in Perl? 无论用户的主机文件/ DNS解析器如何,如何嵌入网站? - How can I embed a website regardless of the user's hosts file / dns resolver? 如何使用 wget 使用 bash 从网页中抓取电子邮件地址? - how can I scrapd email addresses from webpage with bash with wget? Linux Bash脚本可同时ping通多个主机 - Linux Bash script to ping multiple hosts simultaneously 为什么我不能ping linux上的前导或尾随下划线的地址 - Why can I not ping addresses with leading or trailing underscores on linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM