What is my Public IP Address?

August 22nd, 2007 mysurface Posted in curl, egrep, grep, Misc, Text Manipulation, wget | Hits: 143818 | 20 Comments »

What is my public IP address? There is a lots of website can provide you the information. What if I wanna grep it for my script? We can use curl and grep for this purpose.

First, lets pick few websites that provide the service to reveal my public IP.
http://www.ipchicken.com/ – the chicken looks so funny.
http://whatismyip.com/ – a guy playing VR game.
http://myip.dk/ – a simple website but served the purpose.

Next, lets crawl the page and grep the IP

curl -s http://myip.dk/ | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

You can use wget if you do not install curl

wget -qO - http://myip.dk/ | egrep -m1 -o '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'

The important part is the regex. [0-9] indicate any digit within 0 – 9 and {1,3} indicate it should appear minimum 1 time, maximum 3 times. -o indicate grep to print the matched part and -m1 is to limit the grep process to stop at first match.

http://whatismyip.org/ – no need to grep, just curl it.

curl -s http://whatismyip.org/

It seems that getting public IP from http://whatismyip.org/ is far more convenient, the limitation is that you are allow to access the page only 3 times within 10 minutes.

After all, I just enjoy greping with regex :)


20 Responses to “What is my Public IP Address?”

  1. Cool!

    This one is for the ‘visually impaired’ users:
    mpg123 “http://moanmyip.com/output/$(curl http://www.moanmyip.com | egrep -m1 -o ‘[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}’).mp3″

    Cheers. ;)

  2. myip.dk and ip-adress are the old ones dunno how i even remember that ;S

    check http://www.iplobster.com – cunning lobster hehe but i needed ipv4 info

  3. this is a great piece of work. Good job man and a great website

  4. […] 我的公网IP是多少? curl -s http://myip.dk/ | egrep -m1 -o ‘[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}’ wget -qO – http://myip.dk/ | egrep -m1 -o ‘[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}’ curl -s http://whatismyip.org/ […]

  5. this is a great piece of work. Good job man and a great website

  6. View your ip address and more:

  7. Keep up the good work dude!

  8. oo yeah…this is the best article…tnx :X

  9. oo yeah…this is the best article…tnx :X

  10. I all the time emailed this blog post page to
    all my associates, for the reason that if like to read it after that my contacts will too.

    Also visit my web blog; Janet Leigh Nude

  11. Nasze kasy fiskalne warszawa s? najbardziej niezawodne w ca?ej polsce zapraszamy do naszej strony www

  12. Excellent blog here! Also your site loads up fast! What web host are you using?
    Can I get your affiliate link to your host? I wish my site loaded up as fast as yours lol

  13. Hmm it appears like your site ate my first comment (it was extremely long) so I guess I’ll just sum it
    up what I had written and say, I’m thoroughly enjoying your
    blog. I as well am an aspiring blog writer but
    I’m still new to the whole thing. Do you have any helpful hints for rookie blog writers?

    I’d definitely appreciate it.

    My weblog: phone conferencing

  14. Thanks for finally talking about > What is my Public IP Address?
    ? Linux by Examples < Loved it!

  15. So verrissen Computerspiele auch dargestellt wird,
    so steht ja glücklicherweise fest, dass das Zocken von Computerspielen, ein dem Alter des Spielenden angemessenes Spiel vorausgesetzt, förderlich für das Reaktionsvermögen des Gamers ist.
    Beim Zocken lernt man mit Spaß und ohne den Druck Konsequenzen tragen zu müssen schnell
    Urteile zu fällen und seine Aktionen zu priorisieren.
    Die meisten Computerspiele vermitteln zusätzlich auch Basics über Ressourcenmanagement
    und fördern die kognitiven Fähigkeiten des Spielenden. Sogar die verschrieen Multiplayer können doch sehr
    oft den vorgeworfenen Effekt des Abdriftens in eine
    virtuelle Realität} aufhalten. Der Spieler wird zwar schon einigen unfreundlichen Menschen begegnen, doch findet der Spielende häufig
    genau in seinem Lieblingsspiel Gleichgesinnte.
    Summa summarum: das Spielen ist fett! Ungeachtet des Games und ob PC,Konsole,Handy,etc.
    , Spielen ist Kultur.

  16. Griffin said, he planned this week gave Colangelo a call, he joined the United States team for the expression of interest.
    New Blance 574 pris billigere http://www.parksap.com/061/

  17. However, over the last couple of years, Google Talk and Voice applications have been merged with Hangouts, which now serve as its unified messaging app.
    Given the quality design of many of the Windows Mobile 6.
    With so many text messaging apps, nobody is using
    SMS’es to communicate with each other.

  18. Superb blog you have here but I was curious about if you knew of any user
    discussion forums that cover the same topics discussed here?
    I’d really like to be a part of group where I can get comments from other knowledgeable individuals that share the same interest.
    If you have any recommendations, please let me know. Thanks!

  19. Niice post. I learn something new and challenging on blogs I stumbleupon on a daily basis.
    It’s always interesting to read through articles from other
    writers aand use something from their websites.

    Also vijsit my web page – ?????????? 2014

Leave a Reply