| Author |
Message |
Grant *nix forums Guru
Joined: 07 Mar 2005
Posts: 739
|
Posted: Sun Jun 04, 2006 12:15 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 1:10 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 1:10 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
["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
|
Posted: Sun Jun 04, 2006 1:20 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
|
| Back to top |
|
 |
Tim Heaney *nix forums beginner
Joined: 26 Apr 2005
Posts: 16
|
Posted: Sun Jun 04, 2006 4:06 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 4:55 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 5:17 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
-----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
|
Posted: Sun Jun 04, 2006 5:20 pm Post subject:
Followup: Re: How to Determine my Internet IP Address
|
|
|
-----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
|
Posted: Sun Jun 04, 2006 5:27 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 5:42 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 5:47 pm Post subject:
Re: Followup: Re: How to Determine my Internet IP Address
|
|
|
| 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
|
Posted: Sun Jun 04, 2006 6:59 pm Post subject:
Re: Followup: Re: How to Determine my Internet IP Address
|
|
|
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
|
Posted: Sun Jun 04, 2006 7:01 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
"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
|
Posted: Sun Jun 04, 2006 7:29 pm Post subject:
Re: How to Determine my Internet IP Address
|
|
|
"Chris F.A. Johnson" <cfajohnson@gmail.com> writes:
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 |
|
 |
|