53 lines
1.2 KiB
Bash
Executable File
53 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 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"
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -e "\n${LCYAN}Local IP: ${lanip}${NC}\n"
|
|
echo -e "${YELLOW}Public IP: ${pubip}${NC}\n"
|
|
;;
|
|
esac
|
|
|