Net::Frame::Device3pm
Get network device information and gateway
Usage
use Net::Frame::Device;# Get default values from systemmy $device = Net::Frame::Device->new;# Get values from a specific devicemy $device2 = Net::Frame::Device->new(dev => 'vmnet1');# Get values from a specific targetmy $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 targetmy $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;
Overview
This module is used to get network information, and is especially useful when you want to do low-level network programming.
It also provides useful functions to lookup network MAC addresses.
Attributes
dev-
The network device. undef if none found.
ip-
The IPv4 address of
dev. undef if none found.
ip6-
The IPv6 address of
dev. undef if none found.
mac-
The MAC address of
dev. undef if none found.
subnet-
The subnet of IPv4 address
ip. undef if none found.
subnet6-
The subnet of IPv6 address
ip6. undef if none found.
gatewayIp-
The gateway IPv4 address. It defaults to default gateway that let you access Internet. If none found, or not required in the usage context, it defaults to undef.
gatewayIp6-
The gateway IPv6 address. It defaults to default gateway that let you access Internet. If none found, or not required in the usage context, it defaults to undef.
gatewayMac-
The MAC address
gatewayIp. SeelookupMacmethod.
gatewayMac6-
The MAC address
gatewayIp6. SeelookupMac6method.
target-
This attribute is used when you want to detect which
dev,ip,macattributes to use for a specific target. See SYNOPSIS.
target6-
This attribute is used when you want to detect which
dev,ip6,macattributes to use for a specific target. See SYNOPSIS.
Methods
new
new(hash)-
Object constructor. See SYNOPSIS for default values.
updateFromDefault-
Will update attributes according to the default interface that has access to Internet.
updateFromDev
updateFromDev(dev)-
Will update attributes according to
devattribute, or if you specify 'dev' as a parameter, it will use it for updating (and will also setdevto this new value).
updateFromTarget
updateFromTarget(target)-
Will update attributes according to
targetattribute, or if you specify 'target' as a parameter, it will use it for updating (and will also settargetto this new value).
updateFromTarget6
updateFromTarget6(target6)-
Will update attributes according to
target6attribute, or if you specify 'target6' as a parameter, it will use it for updating (and will also settarget6to this new value).
lookupMac(IPv4 address, [ retry, timeout ])-
Will try to get the MAC address of the specified IPv4 address. First, it checks against ARP cache table. Then, verify the target is on the same subnet as we are, and if yes, it does the ARP request. If not on the same subnet, it tries to resolve the gateway MAC address (by using
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). First, verify the target is on the same subnet as we are, and if yes, it does the ICMPv6 lookup request. If not on the same subnet, it tries to resolve the gateway MAC address (by using
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.
Copyright and license
Copyright (c) 2006-2015, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
Releases
6 releases since Debian 8 (Jessie); the text changed 4 times.