shell脚本批量追踪ip路由走向
shell脚本批量追踪ip路由走向需求:
有大量ip地址需要追踪路由,查看是否经过(第三跳经过)192.168.23.2,如不经过,需要显示不能经过的ip
思路:
追踪路由用traceroute -m 4指定4跳即结束,由于到192.168.23.2不到4跳。所以追踪为4足够.
脚本如下:
[*]for IP in `cat $1`
[*]do
[*]traceroute -m 4 -n $IP|grep "192.168.23.2"
[*]if [ "$?" != 0 ]
[*]then
[*]echo "$IP is not in area "
[*]fi
[*]done#保存为traceroute.sh
使用方法:
[*]sh tracerote.sh ip.txt
运行完毕,以上ip.txt的ip全部经过192.168.23.2
ip.txt 的ip如下
[*]10.10.10.10
[*]211.182.23.5
[*]144.255.21.5
[*]……
[*]N多IP,在此不列举
如有更好方法,望赐教!
页:
[1]