Networking Forums

Networking Forums > Computer Networking > Linux Networking > Is there a way to find out, from the unix command line, what my "world/outside" IP address is?

Reply
Thread Tools Display Modes

Is there a way to find out, from the unix command line, what my "world/outside" IP address is?

 
 
rogacasa@gmail.com
Guest
Posts: n/a

 
      07-01-2006, 03:36 AM
Hi. I am using a cable modem. It is connected to an Airport Extreme
base station.

Is there a way to find out, from the unix command line, what my
"world/outside" IP address is? I know I can find this out by pointing
a browser at:

http://www.dyndns.org/cgi-bin/check_ip.cgi

but I want to be able to get it without having to do that. Is there a
way I can more directly query my Airport Extreme base station or my
cable modem for the IP address that the world sees for me?




Thanks,
Roger Carlson

 
Reply With Quote
 
 
 
 
Jerry Kindall
Guest
Posts: n/a

 
      07-01-2006, 04:36 AM
In article <(E-Mail Removed) .com>,
<(E-Mail Removed)> wrote:

> Hi. I am using a cable modem. It is connected to an Airport Extreme
> base station.
>
> Is there a way to find out, from the unix command line, what my
> "world/outside" IP address is? I know I can find this out by pointing
> a browser at:
>
> http://www.dyndns.org/cgi-bin/check_ip.cgi
>
> but I want to be able to get it without having to do that. Is there a
> way I can more directly query my Airport Extreme base station or my
> cable modem for the IP address that the world sees for me?


Well, you probably can, but it'd be as much bother as any other way.
Also, nobody would write a program to do it because it'd be different
for every router and/or brand of cable modem; it's far easier to just
ask some server out on the Internet where you're coming from and it
works no matter what kind of router or modem you have.

What kind of method are you looking for that's easier than a browser?
Command line? Easy:

curl 'http://www.jerrykindall.com/myip.asp'; echo

Assuming you use bash, just add this line to your .profile:

alias myip="curl 'http://www.jerrykindall.com/myip.asp'; echo"

Then you can get your IP address anytime by typing "myip".

Want a little application that, when double-clicked, displays the
address and/or puts it on the clipboard? Paste this AppleScript into
Script Editor and save as an application:

do shell script "curl 'http://www.jerrykindall.com/myip.asp'"
set addr to the result
set the clipboard to addr
display dialog addr buttons "OK" default button "OK"

(take out the third or fourth line if you just want the display or
clipboard function, respectively)

(BTW, the http://www.jerrykindall.com/myip.asp is a little script on my
Web server that returns your IP address as plain text, no HTML, and
you're welcome to use it -- I don't track you or anything)

If you want the IP address in your menu bar or in a floating window or
Dashboard widget or whatever, go to VersionTracker and search for "IP
address." Most of the programs found that way will look up your
external address, and many of them are free.

--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
 
Reply With Quote
 
rogacasa@gmail.com
Guest
Posts: n/a

 
      07-02-2006, 03:48 PM
Sak Wathanasin wrote:
> In article <(E-Mail Removed) .com>,
> (E-Mail Removed) wrote:
>
> > Is there a way to find out, from the unix command line, what my
> > "world/outside" IP address is? I know I can find this out by pointing
> > a browser at:

>
> Sure; you can use wget:
>
> wget -q http://checkip.dyndns.org -O - | sed -e 's/.*\([0-9.]*\)[^0-9]*/\1/'
>
> or put together a little perl script to do the same thing:
>
> #!/usr/bin/perl -w
> require 5.004;
> use strict;
> use IO::Socket;
>
> my ($remote, $port, $socket, $line, $myip);
>
> $remote = shift || 'checkip.dyndns.org';
> $port = shift || 80;
>
> die "No port" unless $port;
>
> $socket = IO::Socket::INET->new(PeerAddr => $remote,
> PeerPort => $port,
> Proto => "tcp",
> Type => SOCK_STREAM)
> or die "Couldn't connect to $remote:$port : $@\n";
>
> $socket->autoflush(1);
>
> #print STDERR "connected to $remote\n";
>
> # send a get
> print $socket "GET / HTTP/1.1\r\n\n";
>
> $myip = "";
> while ($line = <$socket>) {
> #print STDERR $line;
> if ( $line =~ /.*Current IP Address: ([^<]*)</) {
> $myip = $1;
> }
>
> }
>
> print STDOUT $myip, "\n";
>
> exit;
>
> --
>
> Sak Wathanasin
> Network Analysis Limited
> http://www.network-analysis.ltd.uk




Thanks. I was doing something similar to this. I was just hoping there
was a way to get the information directly from the cable modem, using
SNMP or something like that. It seems that the information should be
directly obtainable that way, instead of having to "go out on the net
and back," so to speak.

Thanks,
Roger Carlson

 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      07-02-2006, 04:08 PM
(E-Mail Removed) writes:

>Sak Wathanasin wrote:
>> In article <(E-Mail Removed) .com>,
>> (E-Mail Removed) wrote:
>>
>> > Is there a way to find out, from the unix command line, what my
>> > "world/outside" IP address is? I know I can find this out by pointing
>> > a browser at:

>>
>> Sure; you can use wget:
>>
>> wget -q http://checkip.dyndns.org -O - | sed -e 's/.*\([0-9.]*\)[^0-9]*/\1/'
>>
>> or put together a little perl script to do the same thing:
>>
>> #!/usr/bin/perl -w
>> require 5.004;
>> use strict;
>> use IO::Socket;
>>
>> my ($remote, $port, $socket, $line, $myip);
>>
>> $remote = shift || 'checkip.dyndns.org';
>> $port = shift || 80;
>>
>> die "No port" unless $port;
>>
>> $socket = IO::Socket::INET->new(PeerAddr => $remote,
>> PeerPort => $port,
>> Proto => "tcp",
>> Type => SOCK_STREAM)
>> or die "Couldn't connect to $remote:$port : $@\n";
>>
>> $socket->autoflush(1);
>>
>> #print STDERR "connected to $remote\n";
>>
>> # send a get
>> print $socket "GET / HTTP/1.1\r\n\n";
>>
>> $myip = "";
>> while ($line = <$socket>) {
>> #print STDERR $line;
>> if ( $line =~ /.*Current IP Address: ([^<]*)</) {
>> $myip = $1;
>> }
>>
>> }
>>
>> print STDOUT $myip, "\n";
>>
>> exit;
>>
>> --
>>
>> Sak Wathanasin
>> Network Analysis Limited
>> http://www.network-analysis.ltd.uk




>Thanks. I was doing something similar to this. I was just hoping there
>was a way to get the information directly from the cable modem, using
>SNMP or something like that. It seems that the information should be
>directly obtainable that way, instead of having to "go out on the net
>and back," so to speak.



ifconfig -a
will tell you what your IP address is. If your cable modem, does nat, that
it might have an ip address assigned. If your ISP does NAT then it might
have a different IP. In both cases it may or may not be impossible to go
back (Ie, use their IP to get at your machine).
Your modem might, or might not, have port forwarding enabled. Your ISP
almost certainly not.

 
Reply With Quote
 
Jerry Kindall
Guest
Posts: n/a

 
      07-02-2006, 04:36 PM
In article <e88r27$rk6$(E-Mail Removed)>, Unruh
<unruh-(E-Mail Removed)> wrote:

> ifconfig -a
> will tell you what your IP address is. If your cable modem, does nat, that
> it might have an ip address assigned. If your ISP does NAT then it might
> have a different IP. In both cases it may or may not be impossible to go
> back (Ie, use their IP to get at your machine).
> Your modem might, or might not, have port forwarding enabled. Your ISP
> almost certainly not.


Uh yeah, he already knows he's NATted, that's why he wants a way to
find out his "real" IP address...

--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>

Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
 
Reply With Quote
 
Unruh
Guest
Posts: n/a

 
      07-02-2006, 04:50 PM
Jerry Kindall <(E-Mail Removed)> writes:

>In article <e88r27$rk6$(E-Mail Removed)>, Unruh
><unruh-(E-Mail Removed)> wrote:


>> ifconfig -a
>> will tell you what your IP address is. If your cable modem, does nat, that
>> it might have an ip address assigned. If your ISP does NAT then it might
>> have a different IP. In both cases it may or may not be impossible to go
>> back (Ie, use their IP to get at your machine).
>> Your modem might, or might not, have port forwarding enabled. Your ISP
>> almost certainly not.


>Uh yeah, he already knows he's NATted, that's why he wants a way to
>find out his "real" IP address...


If he is nated, then he is in trouble, since in general you cannot get in
to a natted system. Certainly if the NAT comes from his ISP the chances of
any port forwarding are nill. Ie, the IP address is completely useless.


>--
>Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>


> Send only plain text messages under 32K to the Reply-To address.
> This mailbox is filtered aggressively to thwart spam and viruses.

 
Reply With Quote
 
Marc Heusser
Guest
Posts: n/a

 
      07-02-2006, 06:21 PM
In article <(E-Mail Removed) .com>,
(E-Mail Removed) wrote:

> Hi. I am using a cable modem. It is connected to an Airport Extreme
> base station.
>
> Is there a way to find out, from the unix command line, what my
> "world/outside" IP address is? I know I can find this out by pointing
> a browser at:
>
> http://www.dyndns.org/cgi-bin/check_ip.cgi
>
> but I want to be able to get it without having to do that. Is there a
> way I can more directly query my Airport Extreme base station or my
> cable modem for the IP address that the world sees for me?


Depending on what you have in mind, using DNSUpdate (Mac OS X,
www.versiontracker.com) and www.zoneedit.com (DNS server free for up to
5 second level domains) might be a very nice automatic solution -
especially if you have a domain name available.
DNSUpdate will check the external address for you and adjust the DNS
entries accordingly. It also shows the external address if you are
interested in it. From the commmand line you could then just do a DNS
lookup if you need the address.

HTH

Marc

--
Switzerland/Europe
<http://www.heusser.com>
remove CHEERS and from MERCIAL to get valid e-mail
 
Reply With Quote
 
Tom Stiller
Guest
Posts: n/a

 
      07-02-2006, 07:26 PM
In article <(E-Mail Removed) .com>,
(E-Mail Removed) wrote:

> Thanks. I was doing something similar to this. I was just hoping there
> was a way to get the information directly from the cable modem, using
> SNMP or something like that. It seems that the information should be
> directly obtainable that way, instead of having to "go out on the net
> and back," so to speak.


Most routers have a web interface. You could use 'wget' to get the
status page and parse out the WAN side IP address.

--
Tom Stiller

PGP fingerprint = 5108 DDB2 9761 EDE5 E7E3
7BDA 71ED 6496 99C0 C7CF
 
Reply With Quote
 
Sak Wathanasin
Guest
Posts: n/a

 
      07-02-2006, 08:26 PM
In article <(E-Mail Removed) .com>,
(E-Mail Removed) wrote:

> Thanks. I was doing something similar to this. I was just hoping there
> was a way to get the information directly from the cable modem, using
> SNMP or something like that. It seems that the information should be
> directly obtainable that way, instead of having to "go out on the net
> and back," so to speak.


Yes, that should be possible if your router supports SNMP, and if you know
your MIBs from your OIDs. Something tells me that the wget or even the
simple perl script is a lot less work.

--

Sak Wathanasin
Network Analysis Limited
http://www.network-analysis.ltd.uk
 
Reply With Quote
 
linuxiac
Guest
Posts: n/a

 
      07-02-2006, 11:32 PM
(E-Mail Removed) wrote:
> Hi. I am using a cable modem. It is connected to an Airport Extreme
> base station.
>
> Is there a way to find out, from the unix command line, what my
> "world/outside" IP address is? I know I can find this out by pointing
> a browser at:
>
> http://www.dyndns.org/cgi-bin/check_ip.cgi
>
> but I want to be able to get it without having to do that. Is there a
> way I can more directly query my Airport Extreme base station or my
> cable modem for the IP address that the world sees for me?
>
>
>
>
> Thanks,
> Roger Carlson
>

http://whatismyip.org
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What command reports the "real" IP address? Julie Holiday Wireless Networks 12 01-31-2006 10:43 PM
What command reports the "real" IP address? Julie Holiday Wireless Internet 3 01-31-2006 08:22 PM
Command line variant of "Repair" from XP's Wireless connection man Dazed and Sleepy Wireless Networks 3 01-10-2006 09:14 PM
"ifconfig eth0" command not showing the Gateway address, how can I verify on Linux system? santa19992000@yahoo.com Linux Networking 3 10-16-2005 04:48 PM
Help needed with "Can't start server : UNIX Socket : Address family not supported by protocol" Oliver Linux Networking 1 02-13-2004 01:21 PM



1 2 3 4 5 6 7 8 9 10 11