Pingar lista de hostnames

1. Pingar lista de hostnames

Xesque
kalecgod

(usa Outra)

Enviado em 14/12/2017 - 17:18h

Preciso pingar uma lista de hostnames e gostaria de que retornasse esses pings em outro bloco de notas com os ips, tem como fazer isso?

E por favor, não respondam apenas que sim igual em outros tópicos que já criei, sejamos úteis para ensinar ou apontar alguma direção.

Obrigado.


  


2. Re: Pingar lista de hostnames

Perfil removido
removido

(usa Nenhuma)

Enviado em 14/12/2017 - 17:36h

Se o intuito é apenas saber o ip considero mais útil e rápido o utilitário "host".

$ cat hosts.txt
www.vivaolinux.com.br
br-linux.org


$ for i in $(cat hosts.txt); do echo $i; host $i >> /tmp/ips.txt; done

$ cat /tmp/ips.txt
www.vivaolinux.com.br has address 162.144.34.172
br-linux.org has address 75.119.210.173



3. Re: Pingar lista de hostnames

Sandro Marcell
SMarcell

(usa Slackware)

Enviado em 14/12/2017 - 19:06h

$ cat lista_hosts
duckduckgo.com
bing.com
google.com


$ cat lista_hosts | xargs -I % host -t A % | grep -Eo '([0-9]{1,3}.){3}[0-9]{1,3}' | xargs -I % ping -c1 % > pings 


$ cat pings
PING 107.21.1.61 (107.21.1.61) 56(84) bytes of data.
64 bytes from 107.21.1.61: icmp_seq=1 ttl=39 time=183 ms

--- 107.21.1.61 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 183.994/183.994/183.994/0.000 ms
PING 184.72.115.86 (184.72.115.86) 56(84) bytes of data.
64 bytes from 184.72.115.86: icmp_seq=1 ttl=39 time=178 ms

--- 184.72.115.86 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 178.446/178.446/178.446/0.000 ms
PING 184.72.106.52 (184.72.106.52) 56(84) bytes of data.
64 bytes from 184.72.106.52: icmp_seq=1 ttl=39 time=179 ms

--- 184.72.106.52 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 179.179/179.179/179.179/0.000 ms
PING 23.21.193.184 (23.21.193.184) 56(84) bytes of data.
64 bytes from 23.21.193.184: icmp_seq=1 ttl=40 time=170 ms

--- 23.21.193.184 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 170.438/170.438/170.438/0.000 ms
PING 204.79.197.200 (204.79.197.200) 56(84) bytes of data.
64 bytes from 204.79.197.200: icmp_seq=1 ttl=114 time=116 ms

--- 204.79.197.200 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 116.150/116.150/116.150/0.000 ms
PING 13.107.21.200 (13.107.21.200) 56(84) bytes of data.
64 bytes from 13.107.21.200: icmp_seq=1 ttl=107 time=92.8 ms

--- 13.107.21.200 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 92.874/92.874/92.874/0.000 ms
PING 216.58.202.142 (216.58.202.142) 56(84) bytes of data.
64 bytes from 216.58.202.142: icmp_seq=1 ttl=47 time=93.2 ms

--- 216.58.202.142 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 93.285/93.285/93.285/0.000 ms











Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts