Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell script to realize IP address in Fast ping Network Segment

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Sometimes if you want to see which IP is used in the network segment, you can use this fast ping to make a preliminary judgment. You can specify your own test IP segment and sort the test results into files.

#! / bin/bash

# V1.0 2019-09-10

# Ping test shell script by tutor

Clear

> ip-up.txt

> ip-down.txt

While true

Do

Read-p "Please input the ip segment for ping test (like 192.168.100):" segment

If [- z $segment]; then

Segment= "192.168.100"

Fi

Echo-n "the ip segment is ${segment}, are you sure to continue [yzone]?"

Read action

If [- z $action]; then

Break

Fi

If ["$action" = "y"]; then

Break

Fi

Done

Echo "ping test is ready to run!"

For i in {1..254}

Do

{

Ping-c2-W1 ${segment}. ${I} & > / dev/null

If [$?-eq 0]; then

Echo "${segment}. $i is up" & > / dev/null > > ip-up.txt

Else

Echo "${segment}. $i is down" & > / dev/null > > ip-down.txt

Fi

} &

Done

Wait

Sort-n-k 4-t. Ip-up.txt-o ip-up.txt

Cat ip-up.txt

Sort-n-k 4-t. Ip-down.txt-o ip-down.txt

Cat ip-down.txt

Echo "ping test are finished!"

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report