53 lines
1.3 KiB
Bash
Raw Permalink Normal View History

2018-06-21 22:59:03 -05:00
#!/bin/bash
2018-06-21 22:49:50 -05:00
2018-06-21 22:59:03 -05:00
# Colors
RED='\033[0;31m'
LRED="\033[1;31m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
PURPLE="\033[0;35m"
LPURPLE="\033[1;35m"
BWHITE="\e[1m"
NC='\033[0m' # No Color
pubip=$(curl -s http://whatismijnip.nl |cut -d " " -f 5)
lanip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
case "${1}" in
-e | --external-ip-address)
echo -e "\nPublic IP: ${pubip}\n"
;;
-l | --local-ip-address)
echo -e "Local IP: ${lanip}\n"
;;
-s | --network-scan)
echo "Running Local Network Scan"
sudo nmap -sP 192.168.1.1/24
;;
-h | --help)
echo -e "\nUsage: $0 [-e] [-l] [-s] [-h]\n\n"
echo -e "-e, --external-ip-address Print public IP address\n"
echo -e "-l, --local-ip-address Print local IP address\n"
echo -e "-s, --network-scan Scan local network with nmap\n"
echo -e "-h, --help This help file\n"
;;
*)
2019-09-14 07:06:29 -05:00
echo -e "${LGREEN}type --help or -h for more options${NC}\n"
2018-06-21 22:59:03 -05:00
echo -e "\n${LCYAN}Local IP: ${lanip}${NC}\n"
echo -e "${YELLOW}Public IP: ${pubip}${NC}\n"
;;
esac
2018-06-21 22:49:50 -05:00