Create a gist now

Instantly share code, notes, and snippets.

@recuraki /traceas.sh
Last active May 11, 2017

What would you like to do?
tracerouteにas nameを追加するやつ。
aslookup () {
if test `echo $1 | grep "^[0-9]*$" | wc -l ` = "1"
then
whois -h whois.cymru.com AS$1 | grep -v "AS Name" | cut -d " " -f 1
else
whois -h whois.cymru.com $1 | grep -v "AS Name"
fi
}
traceasnum () {
tf1=`mktemp /tmp/XXXXXX `
tf2=`mktemp /tmp/XXXXXX `
tf3=`mktemp /tmp/XXXXXX `
if test "`uname -s`" = "Darwin"
then
traceroute -m 20 -w1 -q 1 -n -A whois.radb.net $1 | tee $tf1
else
traceroute -m 20 -w1 -q 1 -n -A $1 | tee $tf1
fi
cat $tf1 | sed -e "s/^.*AS\([0-9]*\).*$/AS\\1/" | grep AS > $tf2
cat $tf2 | sed -e "s/AS//" | uniq | tr "\n" "-" | sed -e "s/-/ -> /g" -e "s/-> $//"
for i in `cat $tf2 | uniq`
do
aslookup $i
done > $tf3
echo ""
cat $tf3 | uniq | tr "\n" "#" | sed -e "s/#/ -> /g" -e "s/-> $//"
}
Owner

recuraki commented May 11, 2017

traceasnum www.mitene.co.jp

traceroute to www.mitene.co.jp (202.231.207.65), 20 hops max, 60 byte packets
2 10.0.11.89 [] 6.156 ms
3 10.0.10.57 [
] 0.435 ms
4 10.0.10.53 [*] 0.429 ms
5 202.232.9.93 [AS2497] 0.955 ms
6 58.138.102.109 [AS2497] 0.991 ms
7 58.138.102.210 [AS2497] 0.936 ms
8 210.173.174.97 [AS7521] 1.494 ms
9 122.1.245.69 [AS4713] 7.002 ms
10 122.1.245.138 [AS4713] 2.037 ms
11 118.23.146.202 [AS4713] 2.017 ms
12 61.126.89.170 [AS4713] 4.833 ms
13 219.99.124.61 [AS10013] 4.824 ms

ここに、ASNUMのuniqが出る

9597 -> 2497 -> 7521 -> 4713 -> 10013

ここでASNAMEが出る

CPI-NET KDDI Web Communications Inc., JP -> IIJ Internet Initiative Japan Inc., JP -> MFEED INTERNET MULTIFEED CO., JP -> OCN NTT Communications Corporation, JP -> FBDC FreeBit Co.,Ltd., JP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment