Linux or Mac Terminal – Get Public IP

Published by:

Quick Tip

Here is a quick tip for all you tech guys out there. You can quickly view your public ip of the server that your logged into by using a very handy tool called curl. Here is how:

~ > curl ip.appspot.com
173.55.127.99

 

Curl is a command line tool that can be used to to transfer data from a server, in this case the web server ip.appspot.com.

ip.appspot.com is a simple website, hosted by on googles App Engine Project. Besides using it in the command line terminal, you can also add a bookmark to you browser to find the public ip of the computer you on with out opening up a terminal window. Or you use it as part of many different types of scripts where you need to get the public ip.

As if that was not easy effort, I have taken it one step further by adding a alias for this command and putting it in my .bashrc file, located in my user root folder. I pick alias ‘myip’ but you can choose whatever makes it easy to type and remember.  Here is the the command:

~> vi .bashrc
alias myip=’curl ip.appspot.com’

Now all I need to type is myip, and Proof there it is… How easy is that!

~ > myip
173.55.127.99

This is very helpful when you have an ISP that can not give you a fixed IP address. But I also find it useful when every I need to grab the ip of the server that I’m working on, which are a lot of time masked with domain names.

I hope you find this little tip as helpful to you and I do. Every thru I may not need it every day, it come in handy when I need to get the information fast and do not have time Google it. With my work as a IT/Web Application  Developer so I always have a terminal open and ready to go. Any little tools that I can use with out leaving the terminal is a big help.

PS> I used a fake IP address here for security reasons but I think you get the point.

Dropbox

Published by:

Recommended Cloud File Storage

Dropbox Logo

Dropbox Cloud File Storage

 

Dropbox is a free service that allows me to sync my work files between all my devices, been using it for years with out any major issues.

Get Dropbox