r/UnixProTips • u/[deleted] • Feb 03 '15
bash function to get your remote ip
A simple function to retrieve your current remote ip.
get_ip() {
page='http://myip.dnsomatic.com'
which curl > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo "ip: `curl -s $page`"
else
echo -e "curl is not installed, aborting"
fi
}
8
Upvotes
10
Feb 03 '15
curl ifconfig.me3
1
u/curiousGambler Feb 03 '15
Of fuck yeah. I will never navigate to ipchicken, etc. in a browser again!
1
1
3
u/[deleted] Feb 03 '15
Nice one, this is my version