Net::F...Device(3pm)
π Net::Frame::Device β bestie edition π
okay so this is Net::Frame::Device, straight out of the User Contributed Perl Documentation section of your friendly neighbourhood 3pm manual set. it's giving "I need to know what my network interface is doing and I need to know NOW". let's get into it π«Ά
β¨ NAME β¨
Net::Frame::Device β get network device information and gateway π
πΈ SYNOPSIS πΈ
use Net::Frame::Device;
# Get default values from system
my $device = Net::Frame::Device->new;
# Get values from a specific device
my $device2 = Net::Frame::Device->new(dev => 'vmnet1');
# Get values from a specific target
my $device3 = Net::Frame::Device->new(target => '192.168.10.2');
print "dev: ", $device->dev, "\n";
print "mac: ", $device->mac, "\n";
print "ip : ", $device->ip, "\n";
print "ip6: ", $device->ip6, "\n";
print "gatewayIp: ", $device->gatewayIp, "\n" if $device->gatewayIp;
print "gatewayMac: ", $device->gatewayMac, "\n" if $device->gatewayMac;
# Get values from a specific target
my $device5 = Net::Frame::Device->new(target6 => '2001::1');
print "dev: ", $device5->dev, "\n";
print "mac: ", $device5->mac, "\n";
print "ip6: ", $device5->ip6, "\n";
print "gatewayIp6: ", $device5->gatewayIp6, "\n" if $device5->gatewayIp6;
like, look at that. you literally make an object and it just tells you things. no cap π
π¦ DESCRIPTION π¦
this module is your girl for getting network information, and it's especially useful when you're doing low-level network programming. like, when you're down there in the weeds with packets and frames and you're like "bestie which interface am I even on" β this is the one π§
it also hands you some genuinely useful functions for looking up network MAC addresses. slay π
π ATTRIBUTES π
lowkey the main event. every single one, no skips:
devβ the network device. it'sundefif none found. πipβ the IPv4 address ofdev.undefif none found.ip6β the IPv6 address ofdev.undefif none found.macβ the MAC address ofdev.undefif none found.subnetβ the subnet of IPv4 addressip.undefif none found.subnet6β the subnet of IPv6 addressip6.undefif none found.gatewayIpβ the gateway IPv4 address. it defaults to the default gateway that lets you access the Internet π. if none found, or it's just not required in the usage context, it defaults toundef.gatewayIp6β the gateway IPv6 address. it defaults to the default gateway that lets you access the Internet π. if none found, or it's not required in the usage context, it defaults toundef.gatewayMacβ the MAC address ofgatewayIp. peep thelookupMacmethod for that one πgatewayMac6β the MAC address ofgatewayIp6. peep thelookupMac6method πtargetβ this attribute is what you use when you wanna detect whichdev,ip,macattributes to use for a specific target. check the SYNOPSIS.target6β this attribute is what you use when you wanna detect whichdev,ip6,macattributes to use for a specific target. check the SYNOPSIS again, bestie.
π METHODS π
new
new (hash)
the object constructor π. see SYNOPSIS for default values.
updateFromDefault
will update attributes according to the default interface that has access to the Internet. very main character of it.
updateFromDev
updateFromDev (dev)
will update attributes according to the dev attribute β or, if you pass dev in as a parameter, it'll use that for updating instead (and it will also set dev to this new value, so yeah, it changes on you, that's the vibe).
updateFromTarget
updateFromTarget (target)
will update attributes according to the target attribute β or, if you pass target in as a parameter, it'll use that for updating (and it will also set target to this new value π₯).
updateFromTarget6
updateFromTarget6 (target6)
will update attributes according to the target6 attribute β or, if you pass target6 in as a parameter, it'll use that for updating (and it will also set target6 to this new value π₯).
lookupMac (IPv4 address, [ retry, timeout ])
will try to get the MAC address of the specified IPv4 address. here's the whole detective arc, in order:
- first, it checks against the ARP cache table.
- then, it verifies the target is on the same subnet as we are, and if yes, it does the ARP request.
- if it's not on the same subnet, it tries to resolve the gateway MAC address (by using the
gatewayIpattribute).
you can add optional parameters retry count and timeout in seconds. returns undef on failure π
lookupMac6 (IPv6 address, [ retry, timeout ])
will try to get the MAC address of the specified IPv6 address (using ICMPv6 β¨). the arc goes:
- first, it verifies the target is on the same subnet as we are, and if yes, it does the ICMPv6 lookup request.
- if it's not on the same subnet, it tries to resolve the gateway MAC address (by using the
gatewayIp6attribute).
you can add optional parameters retry count and timeout in seconds. returns undef on failure π
debugDeviceList
just for debugging purposes β especially on Windows systems. lowkey a lifesaver over there πͺ
π AUTHOR π
Patrice <GomoR> Auffret
π COPYRIGHT AND LICENSE π
Copyright (c) 2006-2015, Patrice <GomoR> Auffret
you may distribute this module under the terms of the Artistic license. see the LICENSE.Artistic file in the source distribution archive π
and that's the whole page, bestie π
one last thing: this was pulled from perl v5.38.2, dated 2024-05-04, page Net::F...Device(3pm). stan a documented module. periodt π¦β¨
π¦ where this page comes from
- debian trixie: libnet-frame-device-perl 1.12-2 Β· Artistic-1.0-Perl
- ubuntu resolute: libnet-frame-device-perl 1.12-2 Β· Artistic-1.0-Perl
- ubuntu stonking: libnet-frame-device-perl 1.12-2 Β· Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms