shell脚本检测局域网内存活主机
2015-07-14 11:43
696 查看
<1>
d211 admin # for i in {3..254} ; do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive ;done
192.168.1.5 is alive
192.168.1.7 is alive
<2>
fping -a -g 192.168.5.1 192.168.5.177 -s -n >lele.txt
-a Show systems that are alive.
-g Generate a target list from a supplied IP netmask, or a starting and ending IP. Specify the net mask or start/end in the targets portion of the command line.
ex. To ping the class C 192.168.1.x, the specified command line could look like either:
fping -g 192.168.1.0/24 or fping -g 192.168.1.0 192.168.1.255
-s Print cumulative statistics upon exit. -n Same as -d.
-d Use DNS to lookup address of return ping packet. This allows you to give fping a list of IP
addresses as input and print hostnames in the output.
eg:
i161 bijiao # fping -a -g 192.168.5.4 192.168.5.254 -s >jiancela.txt 2> /dev/null //错误信息不进行输出
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.4
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.5
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.6
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.7
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.8
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.9
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.10
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.11
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.12
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.13
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.14
。。。。。。。。。。。。。。
251 targets
65 alive
186 unreachable
0 unknown addresses
0 timeouts (waiting for response)
369 ICMP Echos sent
65 ICMP Echo Replies received
185 other ICMP received
0.02 ms (min round trip time)
0.32 ms (avg round trip time)
2.40 ms (max round trip time)
9.232 sec (elapsed real time)
i161 bijiao # cat jiancela.txt
192.168.5.101
192.168.5.120
192.168.5.121
192.168.5.157
192.168.5.158
192.168.5.159
192.168.5.160
192.168.5.161
d211 admin # for i in {3..254} ; do ping -c 1 192.168.1.$i &>/dev/null && echo 192.168.1.$i is alive ;done
192.168.1.5 is alive
192.168.1.7 is alive
<2>
fping -a -g 192.168.5.1 192.168.5.177 -s -n >lele.txt
-a Show systems that are alive.
-g Generate a target list from a supplied IP netmask, or a starting and ending IP. Specify the net mask or start/end in the targets portion of the command line.
ex. To ping the class C 192.168.1.x, the specified command line could look like either:
fping -g 192.168.1.0/24 or fping -g 192.168.1.0 192.168.1.255
-s Print cumulative statistics upon exit. -n Same as -d.
-d Use DNS to lookup address of return ping packet. This allows you to give fping a list of IP
addresses as input and print hostnames in the output.
eg:
i161 bijiao # fping -a -g 192.168.5.4 192.168.5.254 -s >jiancela.txt 2> /dev/null //错误信息不进行输出
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.4
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.5
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.6
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.7
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.8
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.9
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.10
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.11
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.12
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.13
ICMP Host Unreachable from 192.168.5.161 for ICMP Echo sent to 192.168.5.14
。。。。。。。。。。。。。。
251 targets
65 alive
186 unreachable
0 unknown addresses
0 timeouts (waiting for response)
369 ICMP Echos sent
65 ICMP Echo Replies received
185 other ICMP received
0.02 ms (min round trip time)
0.32 ms (avg round trip time)
2.40 ms (max round trip time)
9.232 sec (elapsed real time)
i161 bijiao # cat jiancela.txt
192.168.5.101
192.168.5.120
192.168.5.121
192.168.5.157
192.168.5.158
192.168.5.159
192.168.5.160
192.168.5.161
相关文章推荐
- shell 字符串处理
- linux中的source、sh、bash、./命令
- hbase shell基础和常用命令详解
- shell脚本示例,start stop restart
- shell,切换用户,执行指定,脚本
- shell demo
- shell中${}的妙用
- shell if判断
- SharePoint 2013 PowerShell命令备份还原报错
- shell学习四十七天----文件比较cmp,diff,patch
- awk使用详解
- ~/.bash_profile介绍
- Linux Shell 数组
- 国内各类 WebShell 密码大全 爆破、社工用 webshell-password
- shell小技巧收藏
- shell中sed命令
- QT 中调用ShellExecuteEx 运行CMD.exe 不能运行错误
- 写一个shell脚本利用wget抓取股票历史数据
- shell脚本使用记录
- shell脚本操作mysql数据库,使用mysql的-e参数可以执行各种sql的(创建,删除,增,删,改、查)等各种操作