Skip to content

Instantly share code, notes, and snippets.

@strizhechenko
Created August 2, 2022 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strizhechenko/72813d803553c842606ab1e98b7a6310 to your computer and use it in GitHub Desktop.
Save strizhechenko/72813d803553c842606ab1e98b7a6310 to your computer and use it in GitHub Desktop.
Красивая проверка что именно там в сети опять отвалилось
#!/bin/bash
set -euE
SUCCESS="\\033[1;32m"
HEADER="\\033[1;34m"
FAILURE="\\033[1;31m"
NORMAL="\\033[0;39m"
check() {
echo -ne "$HEADER$2...$NORMAL"
cmd="ping -w 2 -qc 1 $1"
[ "$2" = 'ARP' ] && cmd="arping -c 1 -I INET $1"
if ! $cmd &>/dev/null; then
echo -e "$FAILURE FAIL $1$NORMAL"
return 1
fi
echo -e "$SUCCESS OK$NORMAL"
return 0
}
ARP=192.168.0.1
LAN=192.168.0.1
ISP=gate.of.your.provider
WAN=8.8.8.8
DNS=ya.ru
VPN=gate.of.your.vpn
for resource in ARP LAN ISP WAN DNS VPN; do
check "${!resource}" "$resource"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment