IP Chicken at the Command Line

Why?  Why not?!  Using curl and piping into a short grep statement, I’ll show you how to use IPChicken.com in the terminal.

While I’m partial to the chicken of the IP, my Twitter bros pointed out a few other sites that are built with a lightweight response in mind:

ifconfig.pro, curlmyip.com, icanhazip.com

Here’s the code used in the video:


#Getting your public IP at the command line

#1st Step: Curl to request page, parse the ip with regex & grep
curl ipchicken.com -s | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" -m 1

#2nd Step: Add our one-liner to a script
mkdir ~/scripts
cd ~/scripts
#edit our text file
nano ipchicken
#make it executable
chmod +x ipchicken

#3rd Step:
nano ~/.bash_profile
PATH=$PATH:$HOME/scripts

Posted in Linux, OSX