Ever need to grab your IP quick but don’t want to get out of the command line or stop whatever you’re working on? Or how about if you have SSH’d into a number of different servers and you simply want to know where you are at currently? This little trick enables you to quickly determine your public IP address without leaving the command line.
I’ll admit, I didn’t originally come up with this one, but liked it so much that I decided to write a quick post about it because I thought it was so nice and useful. There is a great website called commandlinefu.com where users can post all their slick one liners, which is where I found this one. If you haven’t been there before I highly recommend it, there is some really good stuff over there.
This one is simple yet quite useful, which is what I’m all about. The command uses curl, so if you don’t have that bad boy installed yet you’ll need to go get that quick (Debian based distros).
sudo aptitude install curl
Once that is installed simply run the following:
curl ifconfig.me
And bam! Emeril style. Let that go out and do its thing and you will quickly have your external IP address. I like this method a lot more than having to jump out of the shell and open up a browser then going to a website to get this information. It might not save that much time but to me just knowing how to do this is useful and knowledge is power. Or something.