What is my Public IP Address?
August 22nd, 2007 mysurface Posted in curl, egrep, grep, Misc, Text Manipulation, wget | Hits: 137328 | 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 :)







August 24th, 2007 at 9:38 pm
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. ;)
September 16th, 2007 at 4:37 pm
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
October 30th, 2007 at 6:07 am
this is a great piece of work. Good job man and a great website
November 27th, 2007 at 12:01 am
[…] 我的公网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/ […]
December 30th, 2007 at 5:39 pm
this is a great piece of work. Good job man and a great website
February 15th, 2008 at 6:37 am
View your ip address and more:
http://my-i-p.com
September 17th, 2010 at 4:24 am
Keep up the good work dude!
November 13th, 2011 at 6:23 pm
oo yeah…this is the best article…tnx :X
November 13th, 2011 at 7:54 pm
oo yeah…this is the best article…tnx :X
February 16th, 2013 at 12:40 am
[…] http://linux.byexamples.com/archives/307/what-is-my-public-ip-address/ […]
December 14th, 2013 at 10:07 pm
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
February 10th, 2014 at 9:48 pm
Nasze kasy fiskalne warszawa s? najbardziej niezawodne w ca?ej polsce zapraszamy do naszej strony www
July 8th, 2014 at 1:04 pm
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
September 5th, 2014 at 4:26 pm
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
October 21st, 2014 at 5:13 pm
Thanks for finally talking about > What is my Public IP Address?
? Linux by Examples < Loved it!
December 16th, 2014 at 6:53 am
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.
December 15th, 2015 at 11:17 pm
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/
March 22nd, 2016 at 5:42 pm
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.
May 3rd, 2017 at 7:26 am
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!
June 21st, 2017 at 10:41 am
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