Linux-Noob Forums
Retrieve public IP - Printable Version

+- Linux-Noob Forums (https://www.linux-noob.com/forums)
+-- Forum: Linux Noob (https://www.linux-noob.com/forums/forum-3.html)
+--- Forum: Tips and Tricks (https://www.linux-noob.com/forums/forum-59.html)
+--- Thread: Retrieve public IP (/thread-3414.html)



Retrieve public IP - z0ny - 2004-05-04


Here's a command that shows your public IP, no matter whether you're behind a router: :)

 



Code:
wget -q www.whatismyip.com && grep displaycopy index.html|cut -d\' -f2 && rm -f index.html




 

z0ny




Retrieve public IP - tek-69 - 2004-05-05

kick ass man, thanks



Retrieve public IP - anyweb - 2007-09-21


the above scrfipt doesnt seem to work anymore, perhaps because www.whatismyip.com have changed their code, (looking in index.html tells you to use a different url)

 

so i modified it slightly so now it reads

 



Code:
wget -q www.whatismyip.com/automation/n09230945.asp && cat n09230945.asp && rm -f n09230945.asp




 

which does display the ip but it's badly formatted,

 

 

Quote:[anyweb@localhost ~]$ wget -q www.whatismyip.com/automation/n09230945.asp && cat n09230945.asp && rm -f n09230945.asp81.235.240.204[anyweb@localhost ~]$
 

so who can tidy it up ?

 

 

 

cheers

anyweb




Retrieve public IP - znx - 2007-09-21


Quote:so who can tidy it up ?
 



Code:
$ wget -q http://www.whatismyip.com/automation/n09230945.asp -O - && echo




 

Done




Retrieve public IP - xDamox - 2007-12-13


I updated the command ;)

 



Code:
elinks --dump www.whatismyip.com | grep -i "Your IP Is" | awk '{ print $4 }'







Retrieve public IP - znx - 2007-12-13


Quote:I updated the command ;)
 

Not to sound a bit funny but why update the command when mine still works just perfectly? Also you are using the main URL which anyweb has already pointed out doesn't wish automation!

 



Code:
$ wget -q http://www.whatismyip.com/automation/n09230945.asp -O - && echo




 

Still works fine!




Retrieve public IP - xDamox - 2007-12-14


Ahhh poo, sorry znx I didn't try yours :(

 

Sorry.