Shell Routing Query script

Source: Internet
Author: User

Modified by the Geotrace script, the original script has a lot of problems, looked up some awk data to solve the original problem.

mtr-0.86 version installation failed, need to update some software, so the use of 0.80

can also use Nali this software, very convenient.

This script is often used for network monitoring, which can be displayed: hop count, IP, latency, regional operators, if you want to be able to connect.

Yum Install Jwhois-y

wget ftp://ftp.bitwizard.nl/mtr/mtr-0.80.tar.gz

TAR-AXF mtr-0.80.tar.gz-c/usr/local/src/

cd/usr/local/src/mtr-0.80/

./configure--prefix=/usr/local/mtr

Make

Make install

Ln-s/usr/local/mtr/sbin/mtr/usr/sbin/

Cat >/root/geotrace.sh<<\eof

#!/bin/bash

Echo Traceroute to [$] from localhost

Ip=$1

Echo

# # # #for Linux

# # # displays detailed geo-location information

#echo---- Show detailed geo-location information ----

#mtr--n--report $ip |grep-v snt|grep "%" |awk ' {printf "%-18s%-10s", NR ")" $ "," delay["$" s] "; System ("Whois" $ "|grep-e netname-e descr|head-n1|cut-c17-");p rintf "\ n"} '

# # # Displays abbreviated geo-location information

The echo----displays a snapshot of the location information ---

Echo-e "\033[40;33;1m Hop number IP delay carrier \033[0m"

MTR--n--report $ip |grep-v snt|grep "%" |awk ' {printf "%-18s%-10s", NR ")" $ "," delay["$" s] "; System ("Whois" $ "|grep descr|head-n1|cut-c17-");p rintf "\ n"} '

# # #for Mac

# # # displays detailed geo-location information

#echo---- Show detailed geo-location information ----

#mtr--n--report $ip |grep-ve "snt| Start "|awk ' {printf"%-18s%-10s ", NR") "$", "dleay[" $6 "]"; System ("Whois" $ "|grep-e netname-e descr|cut- c17-");p rintf" \ n "} '

# # # Displays abbreviated geo-location information

#echo---- show a brief geographic location ---

#mtr--n--report $ip |grep-ve "snt| Start "|awk ' {printf"%-18s%-10s ", NR") "$", "dleay[" $6 "]"; System ("Whois" $ "|grep descr|head-n1|cut-c17-"); printf "\ n"} '

Eof


Test:

[root@www ~]# sh geotrace.sh www.baidu.com

Traceroute to [www.baidu.com] from localhost

---- Display the abbreviated location information ---

hop Count IP Latency Carriers

1) 192.168.16.1 Delay[1.2s]

2) 192.168.16.7 Delay[1.2s]

3) 14.23.*.* Delay[9.2s] chinanet Guangdong Province Network

4) 121.32.132.50 delay[1.7s] chinanet Guangdong Province Network

5) 183.56.31.37 Delay[4.9s] chinanet Guangdong Province Network

6) 61.140.98.253 Delay[5.1s] chinanet Guangdong Province Network

7) 202.97.64.57 delay[32.6s] chinanet backbone Network

8) 202.102.69.238 delay[37.3s] chinanet Jiangsu Province Network

9) 180.97.32.34 Delay[30.3s] chinanet Jiangsu province Network

Ten) 180.97.33.107 delay[26.7s] chinanet Jiangsu province Network



Shell Routing Query script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.