linux ping命令
1. 名称解释
PING (Packet Internet Grope),因特网包探索器
2. 简单测试
[rocky@dev_pc1 ~]$ ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125 (61.135.169.125): icmp_seq=1 ttl=57 time=2.95 ms
不加http 或 https
[rocky@dev_pc1 ~]$ ping http://www.baidu.com
ping: http://www.baidu.com: 未知的名称或服务
[rocky@dev_pc1 ~]$ ping https://www.baidu.com
ping: https://www.baidu.com: 未知的名称或服务
3. 其他
3.1 ping10次 间隔1秒
ping -c 10 -i 1 www.baidu.com
4. shell bash
#!/bin/bash network="192.168.1" for sitenu in $(seq 1 100) do ping -c 1 -w 1 "${network}"."${sitenu}" &> /dev/null && result=0 || result=1 if [ "${result}" == 0 ];then echo "${network}.${sitenu} is UP." else echo "${network}.${sitenu} is DOWN." fi done