Changed: ip.sh: fixed ip code
This commit is contained in:
parent
af15154277
commit
8a6f51c21b
55
ip.sh
55
ip.sh
@ -1,7 +1,52 @@
|
|||||||
echo Public IP
|
#!/bin/bash
|
||||||
dig +short myip.opendns.com @resolver1.opendns.com
|
|
||||||
echo
|
# Colors
|
||||||
echo Local IP
|
RED='\033[0;31m'
|
||||||
/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user