blob: 93b60aa40c1873674543f57b4e1ac749e58fb65d (
plain)
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
|
function test-net --description 'Test network connectivity'
if not command -q 'ip'
echo "Can't find ip."
return 1
end
if not command -q 'ping'
echo "Can't find ping."
return 1
end
if not command -q 'curl'
echo "Can't find curl."
return 1
end
set -l extipurl 'https://ifconfig.io'
function print_header -a headertext
echo
set_color blue
echo $headertext
set_color normal
echo
end
function print_ip -a label -a ip
echo -n $label
set_color yellow
echo $ip
set_color normal
end
function ping_host -a host
echo
set_color green
ping -q -O -c 1 $host
set_color normal
end
print_header "Testing local connectivity"
set -l gateway "$(ip -c=never -o route show | awk '/default via/ {print $3}')"
print_ip 'Gateway: ' "$gateway"
ping_host "$gateway"
print_header "Testing internet connectivity"
print_ip 'External IPv4 address: ' "$(curl -s -4 $extipurl)"
print_ip 'External IPv6 address: ' "$(curl -s -6 $extipurl)"
ping_host 8.8.8.8
echo
end
|