Net::A...::Local(3pm)
π NAME π
okay bestie, gather round β Net::Address::IP::Local is a class for discovering the local system's IP address. that's it, that's the whole vibe. it's a Perl module, it's on the User Contributed Perl Documentation shelf, and it is so handy. π¦
β¨ VERSION β¨
this one's running 0.1.2 β vintage but iconic, no cap. π
πΈ SYNOPSIS πΈ
like, here's the whole thing in action:
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);
the way you just... call a class method and get an IP back?? main character energy fr fr. π
π DESCRIPTION π
so Net::Address::IP::Local discovers the local system's IP address β specifically the one that would be used as the source address when you're contacting "the internet" or some certain specified remote IP address. it's not asking your router nicely, it's asking the routing table. lowkey genius. π§
π Class methods π
this class is not complicated, bestie. it just provides the following class methods, and that's the entire menu:
public: returns string; throwsNet::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, aNet::Address::IP::Local::Errorexception is thrown. so basically it picks the better one for you, periodt. πpublic_ipv4: returns string; throwsNet::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, aNet::Address::IP::Local::Errorexception is thrown. forced IPv4, no negotiating. πpublic_ipv6: returns string; throwsNet::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, aNet::Address::IP::Local::Errorexception is thrown. forced IPv6, we love a specialist. πconnected_to($remote_address): returns string; throwsNet::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, aNet::Address::IP::Local::Errorexception is thrown. you hand it a remote address, it hands you back your own. it's giving mirror. πͺβ¨
heads up bestie: every single one of these can throw Net::Address::IP::Local::Error if there's no route. catch it or your script is gonna have a Moment. π
π«Ά 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. go get the fresh one, bestie, don't be running some dusty copy. π
Support is usually (but not guaranteed to be) given by the author, Julian Mehnle <julian@mehnle.net>. "usually but not guaranteed" β okay so it's giving reply speed may vary and honestly? respect the honesty. π
π 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. so like, go off, remix it, ship it β just keep the license terms intact. π
and that's the whole page, bestie!! this doc shipped as part of perl v5.34.0 and got its date stamp on 2022-06-16, so if you're reading this, shoutout to that exact snapshot of the manual. mwah. π
π¦ where this page comes from
- debian bookworm: libnet-address-ip-local-perl 0.1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-address-ip-local-perl 0.1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-address-ip-local-perl 0.1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-address-ip-local-perl 0.1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-address-ip-local-perl 0.1.2-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms