-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathipinfo.sh
More file actions
120 lines (106 loc) · 2.45 KB
/
ipinfo.sh
File metadata and controls
120 lines (106 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# Copyright © Teal Dulcet
# Outputs the systems public IP addresses
# wget -qO - https://raw.github.com/tdulcet/Linux-System-Information/master/ipinfo.sh | bash -s --
# ./ipinfo.sh
# Adapted from: https://github.com/rsp/scripts/blob/master/externalip-benchmark.md
if [[ $# -ne 0 ]]; then
echo "Usage: $0" >&2
exit 1
fi
URLS=(
alma.ch/myip.cgi
api.ipify.org/
# bot.whatismyipaddress.com/
canhazip.com/
checkip.amazonaws.com/
curlmyip.net/
# diagnostic.opendns.com/myip
echoip.de/
eth0.me/
icanhazip.com/
ident.me/ # v4.ident.me/ # v6.ident.me/
ifconfig.co/
ifconfig.me/ip
ifconfig.pro/
ipaddr.site/
ipecho.net/plain
ipinfo.in/
ipinfo.io/ip
ip.tyk.nu/
l2.io/ip
# myip.addr.space/
tnx.nl/ip
wgetip.com/
ifconfig.io/ip
silisoftware.com/tools/ip.php
corz.org/ip
ifcfg.me/
api.infoip.io/ip
whatismyip.akamai.com/
ip-adresim.app/
ipaddress.sh/
myexternalip.com/raw
myip.dnsomatic.com/
trackip.net/ip
wtfismyip.com/text
myip.wtf/text
ipapi.co/ip
ip2location.io/ip
checkip.spdyn.de/
www.nsupdate.info/myip
ip.changeip.com/
# gso.cs.pdx.edu/ip/
)
SERVERS=(
one.one.one.one
dns.opendns.com
resolver{1..4}.opendns.com
ns1-1.akamaitech.net
ns{1..4}.google.com
)
NAMES=(
whoami.cloudflare
myip.opendns.com
myip.opendns.com{,,,}
whoami.akamai.net
o-o.myaddr.l.google.com{,,,}
)
TYPES=(
TXT
''
''{,,,}
''
''{,,,}
)
CLASSES=(
CH
''
''{,,,}
''
''{,,,}
)
echo -e "\nPublic IP addresses"
for ip in 4 6; do
echo -e "\nBest HTTPS response times IPv$ip address:\n"
for url in "${URLS[@]}"; do
answer=''
if output=$(curl -"$ip" -m10 -sSfLw '\n%{time_total}\n' "https://$url" 2>&1); then
answer=$(echo "$output" | head -n 1)
fi
time=$(echo "$output" | tail -n 1)
printf '%s seconds \thttps://%s\t%s\n' "$time" "$url" "${answer:--}"
done | sort -n | awk -F'[ ]' '{ $1 *= 1000; $2 = "ms"; print }' | column -t -s $'\t'
done
for ip in 4 6; do
echo -e "\nBest DNS response times IPv$ip address:\n"
for i in "${!SERVERS[@]}"; do
answer=''
if output=$(dig -"$ip" -u "@${SERVERS[i]}" "${NAMES[i]}" "${TYPES[i]:-IN}" "${CLASSES[i]:-ANY}" 2>&1); then
answer=$(echo "$output" | grep -v '^;' | awk '$4 == "A" || $4 == "AAAA" || $4 == "TXT" { print $4"\t"$5 }' | head -n 1)
fi
time=$(echo "$output" | sed -n 's/;; Query time: *//p')
printf '%s \t%s\t%s\t%s\n' "${time:-0 usec}" "${SERVERS[i]}" "${NAMES[i]}" "${answer:--}"
done | sort -n | awk -F'[ ]' '{ $1 /= 1000; $2 = "ms"; print }' | column -t -s $'\t'
done
echo