1. 首页 > ITPUX技术网 > 正文

【shell学习】扫描局域网IP的方法

[font=punctuation, 微软雅黑, Tohoma]#!/bin/bash

[font=punctuation, 微软雅黑, Tohoma]mynet=”192.168.2″
[font=punctuation, 微软雅黑, Tohoma]num=1
[font=punctuation, 微软雅黑, Tohoma]for num in {1..254}
[font=punctuation, 微软雅黑, Tohoma]do
[font=punctuation, 微软雅黑, Tohoma] if ping $mynet.$num -c 1 &> /dev/null
[font=punctuation, 微软雅黑, Tohoma] then
[font=punctuation, 微软雅黑, Tohoma] echo “$mynet.$num is alived”
[font=punctuation, 微软雅黑, Tohoma] else
[font=punctuation, 微软雅黑, Tohoma] echo “$mynet.$num not is alived”
[font=punctuation, 微软雅黑, Tohoma] fi
[font=punctuation, 微软雅黑, Tohoma] num+=1
[font=punctuation, 微软雅黑, Tohoma]done

本文由风哥教程整理发布,仅用于学习测试使用,转载注明出处:http://www.fgedu.net.cn/10327.html

联系我们

在线咨询:点击这里给我发消息

微信号:itpux-com

工作日:9:30-18:30,节假日休息