You are not logged in.

#1 2008-08-18 21:17:20

colbert
Member
Registered: 2007-12-16
Posts: 809

How to show public ip in shell?

I can see my network ips (192.x.x.x) fine w/ifconfig and such but how can I show my public ip in shell?? Other than lynx and going to whatismyip.com or some such method, perhaps a script or app, thx smile

P.S. I tried my-ip from AUR but I think it's abandoned, the makepkg could not find the archive for dling.

TIA for any help everyone smile

Offline

#2 2008-08-18 21:19:15

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: How to show public ip in shell?

colbert wrote:

I can see my network ips (192.x.x.x) fine w/ifconfig and such but how can I show my public ip in shell?? Other than lynx and going to whatismyip.com or some such method, perhaps a script or app, thx smile

P.S. I tried my-ip from AUR but I think it's abandoned, the makepkg could not find the archive for dling.

TIA for any help everyone smile

Try this command

wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1

That's straight out my bashrc. You could use any other website that you like as well.

Last edited by Inxsible (2008-08-18 21:19:57)


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2008-08-18 21:24:04

colbert
Member
Registered: 2007-12-16
Posts: 809

Re: How to show public ip in shell?

Wow, that works perfect, that's awesome! Hate to prod but would you mind explaining that command a little bit?? I tried substituting "http://www.whatismyip.com" but got a bunch of random lines from the site.

Thx so much!

Offline

#4 2008-08-18 21:29:04

arch0r
Member
From: From the Chron-o-John
Registered: 2008-05-13
Posts: 597

Re: How to show public ip in shell?

shorter one:
echo `wget -q -O - http://www.whatismyip.org`

Offline

#5 2008-08-18 21:33:16

colbert
Member
Registered: 2007-12-16
Posts: 809

Re: How to show public ip in shell?

Ooh that works too, more than one way to skin a cat huh? wink Thx!

Offline

#6 2008-08-18 21:34:30

arch0r
Member
From: From the Chron-o-John
Registered: 2008-05-13
Posts: 597

Re: How to show public ip in shell?

hrhr, it's always easier as you think :>

to avoid these "random lines" you use the -q (quiet) option and -O prints the output not in a file but in your console smile

Last edited by arch0r (2008-08-18 21:37:40)

Offline

#7 2008-08-18 21:42:33

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: How to show public ip in shell?

There is a specific page on whatismyip that is to be used for scripts to save bandwidth.  Please use this page instead.  http://whatismyip.com/automation/n09230945.asp


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#8 2008-08-19 05:55:11

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: How to show public ip in shell?

colbert wrote:

Wow, that works perfect, that's awesome! Hate to prod but would you mind explaining that command a little bit?? I tried substituting "http://www.whatismyip.com" but got a bunch of random lines from the site.

Thx so much!

The .com gives you an html page with all the fancy formatting. If you just want the ip address on console it would be much better to use the .org extension or the automation link that rson provided. They both amount to the same thing.

Note that if you use arch0r's command, you will get a bunch of HTML tags if you use the dyndns site. Suffice to say that every site (which tells you your IP address) has a different way of responding to a request. They send out data in different formats so you will have to customize your command according to the output given by the website that you plan on using.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#9 2008-08-19 06:25:29

Factory
Member
Registered: 2008-02-24
Posts: 108

Re: How to show public ip in shell?

rson451 wrote:

There is a specific page on whatismyip that is to be used for scripts to save bandwidth.  Please use this page instead.  http://whatismyip.com/automation/n09230945.asp

Ah, well now that's nice to know. Thanks!

Offline

#10 2008-08-19 12:11:06

pete-the-meat
Member
From: Scotland
Registered: 2008-08-14
Posts: 26

Re: How to show public ip in shell?

That's super useful - thanks!


That looks like a much better way of trying to do what I was trying to do than trying to do what I was trying to do...

Offline

#11 2008-08-19 22:28:25

colbert
Member
Registered: 2007-12-16
Posts: 809

Re: How to show public ip in shell?

Yes thanks rson451, that's great! big_smile

Offline

#12 2008-08-20 04:12:51

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: How to show public ip in shell?

Curl is the easiest, by far:

$ curl www.whatismyip.org

Enjoy.

Offline

Board footer

Powered by FluxBB