niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » Linux » networking
How to Determine my Internet IP Address
Post new topic   Reply to topic Page 1 of 2 [25 Posts] View previous topic :: View next topic
Goto page:  1, 2 Next
Author Message
Grant
*nix forums Guru


Joined: 07 Mar 2005
Posts: 739

PostPosted: Sun Jun 04, 2006 12:15 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

On Sun, 04 Jun 2006 10:57:16 GMT, Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:

Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

host 82.33.49.20
20.49.33.82.in-addr.arpa domain name pointer 82-33-49-20.cable.ubr05.stav.blueyonder.co.uk.

Grant.
--
http://bugsplatter.mine.nu/
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 1:10 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Grant <bugsplatter@gmail.com> wrote:

Quote:
On Sun, 04 Jun 2006 10:57:16 GMT, Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:

I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

host 82.33.49.20
20.49.33.82.in-addr.arpa domain name pointer 82-33-49-20.cable.ubr05.stav.blueyonder.co.uk.

Hmm. Not exactly future proof, or much good for a script, is it?

Maybe a script to post to alt.test on a free newsserver like aioe.org
and to search for, read, and parse the headers? :-)

--
Dave Farrance
Back to top
Bill Marcum
*nix forums Guru


Joined: 28 Mar 2005
Posts: 1264

PostPosted: Sun Jun 04, 2006 1:10 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

["Followup-To:" header set to comp.unix.shell.]
On Sun, 04 Jun 2006 10:57:16 GMT, Dave Farrance
<DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:
Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

Other suggestions please?

Has any organisation decided to save the world and provide a
script-parseable IP address of the requesting machine?

ifconfig



--
The sum of the intelligence of the world is constant. The population is,
of course, growing.
Back to top
Michael Heiming
*nix forums Guru


Joined: 19 Feb 2005
Posts: 1423

PostPosted: Sun Jun 04, 2006 1:20 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

In comp.unix.shell Dave Farrance <DaveFarrance@omitthisyahooandthis.co.uk>:
Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

Other suggestions please?

Has any organisation decided to save the world and provide a
script-parseable IP address of the requesting machine?

There are numerous if you can't find it out from the inside:

lynx -dump http://www.mediacollege.com/internet/utilities/show-ip.shtml \
| awk '/is:/{print $NF}'

Though there's no guarantee if this won't change.

--
Michael Heiming (X-PGP-Sig > GPG-Key ID: EDD27B94)
mail: echo zvpunry@urvzvat.qr | perl -pe 'y/a-z/n-za-m/'
#bofh excuse 95: Pentium FDIV bug
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 3:18 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Michael Heiming <michael+USENET@www.heiming.de> wrote:

Quote:
lynx -dump http://www.mediacollege.com/internet/utilities/show-ip.shtml \
| awk '/is:/{print $NF}'

Though there's no guarantee if this won't change.

Thanks, that works. I guess that it's the best that can be expected,
even if change is odds-on in the next few years. I've searched out a
few more sites that respond similarly:

lynx -dump http://www.formyip.com/ | awk '/IP is/{print $NF}'

lynx -dump http://www.showipaddress.com/ \
| awk '/IP address:/{print $NF}'

lynx -dump http://www.auditmypc.com/whats-my-ip.asp \
| awk '/current IP/{print $NF}'

lynx -dump http://www.edpsciences.org/htbin/ipaddress \
| awk '/IP address is/{print $NF}'

lynx -dump http://www.pcmesh.com/ip-check.cgi \
| awk '/REMOTE_ADDR/{print $2}'

--
Dave Farrance
Back to top
Tim Heaney
*nix forums beginner


Joined: 26 Apr 2005
Posts: 16

PostPosted: Sun Jun 04, 2006 4:06 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Michael Heiming <michael+USENET@www.heiming.de> writes:
Quote:

In comp.unix.shell Dave Farrance <DaveFarrance@omitthisyahooandthis.co.uk>:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

Other suggestions please?

Has any organisation decided to save the world and provide a
script-parseable IP address of the requesting machine?

There are numerous if you can't find it out from the inside:

lynx -dump http://www.mediacollege.com/internet/utilities/show-ip.shtml \
| awk '/is:/{print $NF}'

Though there's no guarantee if this won't change.

I think WhatIsMyIP.com is the most obvious one, but there's no
guarantee this won't change either. It's been my experience that the
plain text emitted by lynx -dump changes with upgrades to lynx
too. Since it's not that hard to parse the HTML itself, something like

perl -MLWP::Simple -le '$_=get q(http://www.whatismyip.com/); \
print $1 if /Your IP Is ((\d{1,3}\.){3}\d{1,3})/'

might be slightly less fragile than

lynx -dump http://whatismyip.com | awk '/Your IP Is/{print $NF}'

Tim
Back to top
Grant
*nix forums Guru


Joined: 07 Mar 2005
Posts: 739

PostPosted: Sun Jun 04, 2006 4:55 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

On Sun, 04 Jun 2006 13:10:01 GMT, Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:

Quote:
Grant <bugsplatter@gmail.com> wrote:

On Sun, 04 Jun 2006 10:57:16 GMT, Dave Farrance <DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:

I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

host 82.33.49.20
20.49.33.82.in-addr.arpa domain name pointer 82-33-49-20.cable.ubr05.stav.blueyonder.co.uk.

Hmm. Not exactly future proof, or much good for a script, is it?

Point is, your machine knows what it is, but you looking outside
instead of inside -- and you have a lousy sense of humour ;)

Grant.
--
http://bugsplatter.mine.nu/
Back to top
Lew Pitcher
*nix forums Guru


Joined: 21 Feb 2005
Posts: 675

PostPosted: Sun Jun 04, 2006 5:17 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Farrance wrote:
Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

FWIW, I put together some automation, and used the 'free' personal webpage
provided by my ISP to give myself a 'rendesvous' site and redirect webpage.
You can find the details in an article I wrote for Linux Gazette issue 104
(http://linuxgazette.net/105/pitcher1.html).

HTH
- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEgxW2agVFX4UWr64RAi3GAJ97IntT8LIML4HVkp/McM82u/48lACePZaK
mFIn1TVR/WZMv76/oYL3Ncw=
=iwlO
-----END PGP SIGNATURE-----
Back to top
Lew Pitcher
*nix forums Guru


Joined: 21 Feb 2005
Posts: 675

PostPosted: Sun Jun 04, 2006 5:20 pm    Post subject: Followup: Re: How to Determine my Internet IP Address Reply with quote

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew Pitcher wrote:
Quote:
Dave Farrance wrote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

FWIW, I put together some automation, and used the 'free' personal webpage
provided by my ISP to give myself a 'rendesvous' site and redirect webpage.
[snip]


I just realized that the technique I used in the article is probably overkill
for your problem. You can take a look at a simpler procedure that I wrote
about for The Slack World, issue 4 at
http://slackworld.berlios.de/04/essence-2.html

HTH
- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEgxZTagVFX4UWr64RAmmgAKCuDAWcwQN4jrZqrSMxv7kj7ZLnywCgmQ2+
PVUgG59VxAfrIZYMnT70870=
=+2gx
-----END PGP SIGNATURE-----
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 5:27 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

Tim Heaney <theaney@gmail.com> wrote:

Quote:
I think WhatIsMyIP.com is the most obvious one, but there's no
guarantee this won't change either. It's been my experience that the
plain text emitted by lynx -dump changes with upgrades to lynx
too. Since it's not that hard to parse the HTML itself, something like

perl -MLWP::Simple -le '$_=get q(http://www.whatismyip.com/); \
print $1 if /Your IP Is ((\d{1,3}\.){3}\d{1,3})/'

Thanks. I guess that using PERL is a bit more elegant than Lynx because
it's more likely to be installed. However, despite the lynx -dump
varying somewhat, it's output does make the subsequent parsing easier.
I tried the above script on the other websites that I'd found and it
was commonly stymied by embedded html tags - and the IP address
commonly appearing on the *next* line of the HTML source code even
though it was on the same line when the HTML was interpreted. It found
one other site that it worked with:

perl -MLWP::Simple -le '$_=get q(http://www.formyip.com/); \
print $1 if /IP is ((\d{1,3}\.){3}\d{1,3})/'

--
Dave Farrance
Back to top
Chris F.A. Johnson
*nix forums Guru


Joined: 20 Feb 2005
Posts: 2268

PostPosted: Sun Jun 04, 2006 5:42 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

On 2006-06-04, Dave Farrance wrote:
Quote:
I'm looking for a reasonably future-proof way to find the IP address of
a machine as seen from the Internet.

This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

It's still working.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
Back to top
IcessLinux
*nix forums beginner


Joined: 15 May 2006
Posts: 21

PostPosted: Sun Jun 04, 2006 5:47 pm    Post subject: Re: Followup: Re: How to Determine my Internet IP Address Reply with quote

Quote:
Lew Pitcher wrote:
Slackware - Because I know what I'm doing.

Oh yes. None of that point & click nosense!
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 6:59 pm    Post subject: Re: Followup: Re: How to Determine my Internet IP Address Reply with quote

Lew Pitcher <lpitcher@sympatico.ca> wrote:

Quote:
I just realized that the technique I used in the article is probably overkill
for your problem. You can take a look at a simpler procedure that I wrote
about for The Slack World, issue 4 at
http://slackworld.berlios.de/04/essence-2.html

Thanks, but since PCs often negotiate an IP with a local router, which
is even common for home PCs now that wireless networks are popular, it
won't always give your IP address as seen by the Internet.

If, however, you *do* want to find a PC's local leased address, rather
than a fixed IP address that's been assigned to a given interface which
you'd know anyway, then with the latest linux distros (for example), it
would have been assigned by dhclient. So you can find it with this:

#!/bin/bash
myip=`cat /var/lib/dhcp/dhclient*leases | grep -m 1 "address"`
myip=${myip#*address}
myip=${myip%\;}
echo $myip

--
Dave Farrance
Back to top
Dave Farrance
*nix forums Guru Wannabe


Joined: 21 Feb 2005
Posts: 294

PostPosted: Sun Jun 04, 2006 7:01 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

"Chris F.A. Johnson" <cfajohnson@gmail.com> wrote:

Quote:
On 2006-06-04, Dave Farrance wrote:
This worked once but not now. It was probably removed due to excessive
traffic:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

It's still working.

Ah. It is *now*. It wasn't earlier today.

--
Dave Farrance
Back to top
Tim Heaney
*nix forums beginner


Joined: 26 Apr 2005
Posts: 16

PostPosted: Sun Jun 04, 2006 7:29 pm    Post subject: Re: How to Determine my Internet IP Address Reply with quote

"Chris F.A. Johnson" <cfajohnson@gmail.com> writes:
Quote:

wget -O- http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

It's still working.

Ossum! That's much nicer. And if we don't happen to have wget, we just
pick our favorite...

curl http://cfaj.freeshell.org/ipaddr.cgi 2>/dev/null

perl -MLWP::Simple -e 'getprint shift' http://cfaj.freeshell.org/ipaddr.cgi

python -c 'import urllib;print urllib.urlopen("http://cfaj.freeshell.org/ipaddr.cgi").read(),'

ruby -r uri -r net/http -e 'Net::HTTP.get_print(URI.parse("http://cfaj.freeshell.org/ipaddr.cgi"))'

tcl -c 'package require http; puts -nonewline [http::data [http::geturl [lindex "http://cfaj.freeshell.org/ipaddr.cgi"]]]'

lua -e 'h = require("socket.http"); r = h.request("http://cfaj.freeshell.org/ipaddr.cgi"); io.stdout:write(r)'

And it still does the job in a web browser! Sometimes plain text is
just better.

Tim
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 2 [25 Posts] Goto page:  1, 2 Next
View previous topic :: View next topic
The time now is Fri Jan 09, 2009 4:27 am | All times are GMT
navigation Forum index » *nix » Linux » networking
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Postfix ldap and Rewriting sender email address endfx Postfix 2 Thu Apr 17, 2008 9:34 pm
No new posts recipient address restriction 3dd13 Postfix 0 Wed Mar 26, 2008 1:46 pm
No new posts Home based Internet research Jobs honey PHP 0 Fri Jul 21, 2006 11:29 am
No new posts determine pointer to point to array or single item during... yancheng.cheok@gmail.com C++ 5 Fri Jul 21, 2006 1:17 am
No new posts I need to configure DHCP server to force client to obtain... malazc@gmail.com networking 1 Thu Jul 20, 2006 8:44 pm

Debt Consolidation | Credit Cards | Six Figure Income | Loans | Loans
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.4344s ][ Queries: 16 (0.3041s) ][ GZIP on - Debug on ]