FAQ
ok i know how i can find my INERNAL ip address in a script with perl:

use Socket;
print inet_ntoa(inet_aton("")) ."\n";

but how would I find my EXTERNAL ip address?

Thanks

Search Discussions

  • Tom Phoenix at Nov 24, 2007 at 3:17 pm

    On 11/23/07, doubleHelix wrote:

    but how would I find my EXTERNAL ip address?
    If there's an IP address at which routers send traffic to your
    machine, your machine doesn't intrinsically know what it is. You
    generally have to ask some program such as ipconfig. Inquire in forums
    specifically about your operating system. Good luck with it!

    --Tom Phoenix
    Stonehenge Perl Training
  • Jenda Krynicky at Nov 24, 2007 at 3:39 pm
    From: doubleHelix <realtechnical@gmail.com>
    ok i know how i can find my INERNAL ip address in a script with perl:

    use Socket;
    print inet_ntoa(inet_aton("")) ."\n";

    but how would I find my EXTERNAL ip address?
    Define external ... it's not as simple as it may sound. One
    definition could be "the address that my HTTP requests seem to come
    from". In that case:

    1) Find an external web page that displays the IP address
    2) send a request to that page using LWP::Simple
    3) parse the result

    the problem is that it might be the address of a transparent HTTP
    proxy that sits between you and the outside web.

    You might try something similar using FTP ... I think some FTP
    servers do include the IP address of the other party in the greeting.


    You may want to know the IP address so that you can give it to
    someone so that he can try to connect to your computer from the
    outside ... this may and may not be possible. The firewall may assign
    external IP addresses dynamicaly as you open an outbound connection,
    it may use the same IP address for many computers, it may disallow
    inbound connections completely or allow them only to selected few
    computers&ports etc.

    If you need something like this you will probably end up having to
    contact your network admins.

    Jenda
    ===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery
  • Celejar at Nov 27, 2007 at 1:42 am

    On Sat, 24 Nov 2007 16:38:21 +0100 "Jenda Krynicky" wrote:

    From: doubleHelix <realtechnical@gmail.com>
    ok i know how i can find my INERNAL ip address in a script with perl:

    use Socket;
    print inet_ntoa(inet_aton("")) ."\n";

    but how would I find my EXTERNAL ip address?
    Define external ... it's not as simple as it may sound. One
    definition could be "the address that my HTTP requests seem to come
    from". In that case:

    1) Find an external web page that displays the IP address
    2) send a request to that page using LWP::Simple
    3) parse the result
    Tip: the best site for this is whatismyip.org, which returns a page
    containing *nothing* but the IP address - no HTML, no parsing necessary.
    Jenda
    Celejar
    --
    mailmin.sourceforge.net - remote access via secure (OpenPGP) email
    ssuds.sourceforge.net - A Simple Sudoku Solver and Generator

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedNov 23, '07 at 7:06p
activeNov 27, '07 at 1:42a
posts4
users4
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase