From 8a6f51c21b99668936159a31e4965ac405089263 Mon Sep 17 00:00:00 2001 From: glitchd Date: Thu, 21 Jun 2018 22:59:03 -0500 Subject: [PATCH] Changed: ip.sh: fixed ip code --- ip.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/ip.sh b/ip.sh index ddf1128..b8e651f 100755 --- a/ip.sh +++ b/ip.sh @@ -1,7 +1,52 @@ -echo Public IP -dig +short myip.opendns.com @resolver1.opendns.com -echo -echo Local IP -/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' +#!/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