Created
September 9, 2020 18:54
-
-
Save manoger/46a89e6b9d246bddca85cd00b0b891eb to your computer and use it in GitHub Desktop.
Exemplo de shell script para verificar a conexão com multiplos IPs e Urls. Ótimo para troubleshooting de travas de firewall. (v1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#COLORS | |
RED='\033[0;31m' | |
LRED='\033[1;31m' | |
GREEN='\033[0;32m' | |
LGREEN='\033[1;32m' | |
ORANGE='\033[0;33m' | |
YELLOW='\033[1;33m' | |
LBLUE='\033[1;34m' | |
CYAN='\033[0;36m' | |
NC='\033[0m' # No Color | |
#CONFIGS | |
Timeout="2" | |
NetCatParam="-z" #-zv -> Verboso ; -z -> Nao Verboso | |
MongoDefaultPort="27017" | |
SqlDefaultPort="1433" | |
ADDRESSES_HTTP=("google.com" "youtube.com" "localhost.com") | |
ADDRESSES_NGINX=("mynginx.com") | |
ADDRESSES_SMTP=("mysmtp.com" "mysmtp2.com") | |
ADDRESSES_ACE=("127.0.0.1" "barramentoibm.com") | |
ADDRESSES_SQL=("127.0.0.1") | |
ADDRESSES_MONGO=("127.0.0.1") | |
###################################### | |
echo -e "${LGREEN}SERVIDOR DE ALGUMA COISA: ${RED}AMBIENTE DE PRODUCAO${NC}" | |
echo "" | |
echo "As tentativas de conexoes sao feitas dentro de $Timeout segundos de timeout" | |
echo "O proposito do batch e auxiliar no troubleshooting referente a firewall" | |
echo -e "${YELLOW}atencao:${NC} no caso de IPs nao listados ou timeouts maiores, podem ocorrer falsos positivos." | |
###################################### | |
#App Connect. Barramento da IBM por exemplo, pode ser qualquer tipo de aplicacao especifica que utiliza outras portas | |
###################################### | |
echo "*********************************************" | |
echo "" | |
echo -e "${YELLOW}IBM App Connect${NC} conexao direta com o Integration Server:" | |
echo "" | |
# echo -e "${GREEN}DEV${NC}" | |
for ADDR in ${ADDRESSES_ACE[@]} | |
do | |
echo -n "Port 7601 admin |" | |
echo -n "$ADDR |" | |
nc ${NetCatParam} "$ADDR" 7601 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
echo -n "Port 7801 http |" | |
echo -n "$ADDR |" | |
nc ${NetCatParam} "$ADDR" 7801 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
echo "" | |
###################################### | |
#SQL | |
###################################### | |
echo -e "${YELLOW}SQL${NC} Connections" | |
echo "" | |
for ADDR in ${ADDRESSES_SQL[@]} | |
do | |
echo -n "Port $SqlDefaultPort |" | |
echo -n "$ADDR |" | |
nc ${NetCatParam} "$ADDR" "$SqlDefaultPort" -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
echo "" | |
###################################### | |
#MONGO DB | |
###################################### | |
echo -e "${YELLOW}MONGO DB${NC} Connections" | |
echo "" | |
for ADDR in ${ADDRESSES_MONGO[@]} | |
do | |
echo -n "Port "$MongoDefaultPort" |" | |
echo -n "$ADDR |" | |
nc ${NetCatParam} "$ADDR" "$MongoDefaultPort" -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
echo "" | |
###################################### | |
#SMTP | |
###################################### | |
echo -e "${YELLOW}SMTP${NC} Connections" | |
echo "" | |
for ADDR in ${ADDRESSES_SMTP[@]} | |
do | |
echo -n "Port 25 |" | |
echo -n "$ADDR |" | |
nc ${NetCatParam} "$ADDR" 25 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
###################################### | |
#HTTP & HTTPS | |
###################################### | |
echo -e "${YELLOW}HTTP & HTTPS${NC} Connections" | |
echo "" | |
for ADDR in ${ADDRESSES_HTTP[@]} | |
do | |
echo -n "http | " | |
echo -n "$ADDR | " | |
nc ${NetCatParam} "$ADDR" 80 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
nc ${NetCatParam} "$ADDR" 443 -w "${Timeout}" | |
echo -n "https | " | |
echo -n "$ADDR | " | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
echo "" | |
###################################### | |
#NGINX | |
###################################### | |
echo -e "${YELLOW}NGINX${NC} Connections - ip direto" | |
echo "" | |
for ADDR in ${ADDRESSES_NGINX[@]} | |
do | |
echo -n "http | " | |
echo -n "$ADDR | " | |
nc ${NetCatParam} "$ADDR" 80 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
echo -n "https | " | |
echo -n "$ADDR | " | |
nc ${NetCatParam} "$ADDR" 443 -w "${Timeout}" | |
if [ $? -eq 0 ]; then | |
echo -e "${GREEN}OK${NC}" | |
else | |
echo -e "${RED}FAIL${NC}" | |
fi | |
done | column -t | |
echo "*********************************************" | |
echo "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment