Jul 1, 2015 02:26 PM
(This post was last modified: Jul 1, 2015 02:32 PM by rootsh3ll.)
Code
#! /bin/sh
public_IP()
{ pub_IP=$( wget -q -O - ifconfig.me/ip )
if [ -z $pub_ip ]; then
P_st="disconnected"
P_ip="-"
else
P_ip="Public IP : $pub_IP"
P_st="Connected"
fi
}
private_IP()
{
priv_IP=$(ifconfig wlan0 \
| grep 'inet addr' \
| cut -d: -f2 \
| awk '{print $1}' )
if [ -z $priv_IP ]; then
p_ip="-"
p_st="disconnected"
else
p_st="Connected"
p_ip="$priv_IP"
fi
}
help()
{
echo "Usage : getip [OPTIONS]\n"
echo "Options:\n -h\t: Help menu"
echo " -p\t: Displays Private IP"
echo " -P\t: Displays Public IP"
}
banner()
{
echo "Private IP | Public IP | Internet Status\n "
}
start()
{
if [ "$1" = '-h' ]; then
help
else
banner
private_IP
public_IP
echo "$p_ip\t\t$P_ip\t\t$P_st"
fi
}
# Main function
start $@Save the above code as getip.sh
then,
open terminal in curent directory and type
Quote:chmod u+x getip.sh
./getip.sh -h
just wait..and see the terminal will print back your Public and Private IP of you wireless Network.
FEEL FREE TO COMMENT IF YOU LIKE THE POST😉
--rootsh3ll @ ( rootsh3ll.com )

