A class for discovering the local system's ip address
0.1.2
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);
Net::Address::IP::Local discovers the local system's \s-1IP\s0 address that would be used as the source address when contacting \*(L"the internet\*(R" or a certain specified remote \s-1IP\s0 address.
This class just provides the following class methods:
Returns the textual representation of the local system's \s-1IP\s0 address that is \*(L"en route\*(R" to \*(L"the internet\*(R". If the system supports IPv6 and has an IPv6 address that is \*(L"en route\*(R" to \*(L"the internet\*(R", that is returned. Otherwise, the IPv4 address that is \*(L"en route\*(R" to \*(L"the internet\*(R" is returned. If there is no route at all to the internet, a Net::Address::IP::Local::Error exception is thrown.
Returns the textual representation of the local system's IPv4 address that is \*(L"en route\*(R" to \*(L"the internet\*(R". If there is no IPv4 route to the internet, a Net::Address::IP::Local::Error exception is thrown.
Returns the textual representation of the local system's IPv6 address that is \*(L"en route\*(R" to \*(L"the internet\*(R". If there is no IPv6 route to the internet, a Net::Address::IP::Local::Error exception is thrown.
Returns the textual representation of the local system's \s-1IP\s0 address that is \*(L"en route\*(R" to the given remote \s-1IP\s0 address. If there is no route to the given remote \s-1IP\s0 address, a Net::Address::IP::Local::Error exception is thrown.
The latest version of Net::Address::IP::Local is available on \s-1CPAN\s0 and at http://www.mehnle.net/software/net-address-ip-local-perl <http://www.mehnle.net/software/net-address-ip-local-perl>.
Support is usually (but not guaranteed to be) given by the author, Julian Mehnle <[email protected]>.
Net::Address::IP::Local is Copyright (C) 2005-2009 Julian Mehnle <[email protected]>.
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 \s-1GNU\s0 \s-1GPL\s0 or the Artistic License.