home/bin/myip.sh

18 lines
513 B
Bash
Executable file

#!/bin/bash
# http://askubuntu.com/questions/95910/command-for-determining-my-public-ip
# Works too but very slow (a lot more features available):
# curl ifconfig.me
#wget -qO- http://ipecho.net/plain; echo
MY_IP="`wget -qO- http://ipecho.net/plain`"
#echo $MY_IP
#MY_PROVIDER="`whois $MY_IP | awk '/role/{getline; print}' | awk -F ":" '{print $2}' | awk '{$1=$1;print}'`"
MY_PROVIDER="`whois $MY_IP | grep "descr" | head -n 1 | awk -F ":" '{print $2}' | awk '{$1=$1;print}'`"
echo $MY_IP: $MY_PROVIDER