#!/bin/bash #function: Count the relationship between ip and mac in a C subnet #created by comk at Mar.12.2016 quitScript() { echo "User Interrupt ,Quit..." } trap 'quitScript; exit 5' SIGINT #### support ctrl+c interrupt read -p "請輸入你要測試的網段(如192.168.0.0):" string a=`echo $string|cut -d"." -f1-3` for i in {1..254};do ping -c 1 $a.$i done exec arp -a | cut -d" " -f2,4 | tr -s [\(\)] [" "" "] > mac.txt
shell 實現統計一個網段的IP和mac對應關係並保存到文件mac.txt
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.