Julian Mehnle

NAME

Net::Address::IP::Local - A class for discovering the local system's IP address

VERSION

0.1.2

SYNOPSIS

    use Net::Address::IP::Local;
    
    # Get the local system's IP address that is "en route" to "the internet":
    my $address      = Net::Address::IP::Local->public;
    my $address_ipv4 = Net::Address::IP::Local->public_ipv4;
    my $address_ipv6 = Net::Address::IP::Local->public_ipv6;
    
    # Get the local system's IP address that is "en route" to the given remote
    # IP address:
    my $address = Net::Address::IP::Local->connected_to($remote_address);

DESCRIPTION

Net::Address::IP::Local discovers the local system's IP address that would be used as the source address when contacting "the internet" or a certain specified remote IP address.

Class methods

This class just provides the following class methods:

public: returns string; throws Net::Address::IP::Local::Error

Returns the textual representation of the local system's IP address that is "en route" to "the internet". If the system supports IPv6 and has an IPv6 address that is "en route" to "the internet", that is returned. Otherwise, the IPv4 address that is "en route" to "the internet" is returned. If there is no route at all to the internet, a Net::Address::IP::Local::Error exception is thrown.

public_ipv4: returns string; throws Net::Address::IP::Local::Error

Returns the textual representation of the local system's IPv4 address that is "en route" to "the internet". If there is no IPv4 route to the internet, a Net::Address::IP::Local::Error exception is thrown.

public_ipv6: returns string; throws Net::Address::IP::Local::Error

Returns the textual representation of the local system's IPv6 address that is "en route" to "the internet". If there is no IPv6 route to the internet, a Net::Address::IP::Local::Error exception is thrown.

connected_to($remote_address): returns string; throws Net::Address::IP::Local::Error

Returns the textual representation of the local system's IP address that is "en route" to the given remote IP address. If there is no route to the given remote IP address, a Net::Address::IP::Local::Error exception is thrown.

AVAILABILITY and SUPPORT

The latest version of Net::Address::IP::Local is available on CPAN and at http://www.mehnle.net/software/net-address-ip-local-perl.

Support is usually (but not guaranteed to be) given by the author, Julian Mehnle <julian@mehnle.net>.

AUTHOR and LICENSE

Net::Address::IP::Local is Copyright (C) 2005-2009 Julian Mehnle <julian@mehnle.net>.

Net::Address::IP::Local is free software. You may use, modify, and distribute it under the same terms as Perl itself, i.e. under the GNU GPL or the Artistic License.