Net::A...::Local(3pm)

πŸ“¦
version 0.1.2 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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; 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. so basically it picks the better one for you, periodt. πŸ’–
  • 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. forced IPv4, no negotiating. 🌟
  • 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. forced IPv6, we love a specialist. πŸ’œ
  • 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. 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