dn42/scripts/netcheck.sh
2020-04-04 14:26:59 +02:00

145 lines
3.7 KiB
Bash
Executable file

#!/bin/bash
export RED='\033[0;31m'
export GREEN='\033[0;32m'
export GREY='\033[0;37m'
export NC='\033[0m' # No Color
fullpingtest(){
host=" ($(dig +short -x $1 | ggrep -Po '.*(?=\.)'))"
if [[ $? -ne 0 ]]; then
host=""
fi
timeout 1 ping -c 1 $1 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$1$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$1$host${GREY} is ${RED}down${NC}"
fi
host=" ($(dig +short -x $2 | ggrep -Po '.*(?=\.)'))"
if [[ $? -ne 0 ]]; then
host=""
fi
timeout 1 ping6 -o $2 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$2$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$2$host${GREY} is ${RED}down${NC}"
fi
host=" (v4)"
timeout 1 ping -c 1 $3 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$3$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$3$host${GREY} is ${RED}down${NC}"
fi
host=" (v6)"
timeout 1 ping6 -o $3 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$3$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$3$host${GREY} is ${RED}down${NC}"
fi
}
pingtest(){
host=" ($(dig +short -x $1 | ggrep -Po '.*(?=\.)'))"
if [[ $? -ne 0 ]]; then
host=""
fi
timeout 1 ping -c 1 $1 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$1$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$1$host${GREY} is ${RED}down${NC}"
fi
host=" ($(dig +short -x $2 | ggrep -Po '.*(?=\.)'))"
if [[ $? -ne 0 ]]; then
host=""
fi
timeout 1 ping6 -o $2 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$2$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$2$host${GREY} is ${RED}down${NC}"
fi
}
dnspingtest(){
host=" (v4)"
timeout 1 ping -c 1 $1 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$1$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$1$host${GREY} is ${RED}down${NC}"
fi
host=" (v6)"
timeout 1 ping6 -o $1 &>/dev/null
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}PASS${NC}]${GREY} Host ${NC}$1$host${GREY} is ${GREEN}up${NC}"
else
echo -e "[${RED}FAIL${NC}]${GREY} Host ${NC}$1$host${GREY} is ${RED}down${NC}"
fi
}
webtest4(){
ip4=$(curl -s -4 --connect-timeout 1 $1)
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}INFO${NC}]${GREY} Your Source IPv4 to ${NC}$1${GREY} is ${GREEN}$ip4${NC}"
else
echo -e "[${GREEN}INFO${NC}]${GREY} Your Source IPv4 to ${NC}$1${GREY} is ${RED}unknown${NC}"
fi
}
webtest6(){
ip6=$(curl -s -6 --connect-timeout 1 $1)
if [[ $? -eq 0 ]]; then
echo -e "[${GREEN}INFO${NC}]${GREY} Your Source IPv6 to ${NC}$1${GREY} is ${GREEN}$ip6${NC}"
else
echo -e "[${GREEN}INFO${NC}]${GREY} Your Source IPv6 to ${NC}$1${GREY} is ${RED}unknown${NC}"
fi
}
webtest(){
webtest4 $1
webtest6 $1
}
echo -e "[${GREEN}INFO${NC}]${GREY} Scan started on $(date "+%Y-%m-%d %H:%M:%S")${NC}"
#fullpingtest "78.46.129.93" "2a01:4f8:c0c:51e::1" "mail.zotan.network"
#fullpingtest "172.20.129.5" "fd42:4242:2601:ac05::1" "pingable.burble.dn42"
dnspingtest "mail.zotan.network"
dnspingtest "prod.zotan.network"
dnspingtest "fsn1.dn42.zotan.network"
dnspingtest "nbg1.dn42.zotan.network"
dnspingtest "hel1.dn42.zotan.network"
dnspingtest "fsn2.dn42.zotan.network"
dnspingtest "fsn1.zotan.dn42"
dnspingtest "nbg1.zotan.dn42"
dnspingtest "hel1.zotan.dn42"
dnspingtest "fsn2.zotan.dn42"
dnspingtest "burble.dn42"
webtest "fsn1.dn42.zotan.network"
webtest4 "ip4.dn42"
webtest6 "ip6.dn42"