Search This Blog

Wednesday, April 24, 2013

How to find your public ip from bash

There are many sites that can show you your current public IP. But only a few of them are designed in a way so you can interact with them from command line using curl for example.

Below is a nice and elegant way to find out your public IP using curl
 
alias myip='curl --silent checkip.dyndns.org | egrep --only-matching "[0-9\.]+"'

root@server:~# myip
1.79.21.123

References
  1. https://github.com/pex/config/blob/master/bash/shortcuts.sh
  2. https://github.com/rtomaszewski/dotfiles
  3. http://dotfiles.github.io/

No comments:

Post a Comment