Linux::Ethtool::Settings - Manipulate link-level network interface settings
use Linux::Ethtool::Settings; my $settings = Linux::Ethtool::Settings->new("eth0") or die($!); # Show the current/supported modes. my $current_speed = $settings->speed(); my $current_duplex = $settings->duplex() ? "full" : "half"; print "Current speed: $current_speed Mbps, $current_duplex duplex\n"; my @supported_modes = $settings->supported_modes(); print "Supported speeds: @supported_modes\n"; # Force the interface to 10Mbps, half duplex $settings->autoneg(0); $settings->speed(10); $settings->duplex(0); $settings->apply() or die($!); # Turn auto-negotiation back on. Setting advertising to supported is required # if the object was constructed when auto-negotiation was disabled or Linux # will try to auto-negotiate with no speeds... $settings->autoneg(1); $settings->advertising($settings->supported); $settings->apply() or die($!);
This module provides a wrapper around the ethtool_cmd structure and associated ioctls, mainly used for configuring link-level settings such as speed/duplex and auto-negotiation.
ethtool_cmd
All the constants in this module may be imported individually or by using the all import tag.
all
Construct a new instance using the settings of the named interface.
Returns an object instance on success, undef on failure.
Apply any changed settings to the interface.
Returns true on success, false on failure.
Returns the features supported by this interface as a bit field. The following constants are useful here:
SUPPORTED_TP SUPPORTED_AUI SUPPORTED_MII SUPPORTED_FIBRE SUPPORTED_BNC SUPPORTED_Autoneg SUPPORTED_10baseT_Half SUPPORTED_10baseT_Full SUPPORTED_100baseT_Half SUPPORTED_100baseT_Full SUPPORTED_1000baseT_Half SUPPORTED_1000baseT_Full SUPPORTED_2500baseX_Full SUPPORTED_1000baseKX_Full SUPPORTED_10000baseT_Full SUPPORTED_10000baseKX4_Full SUPPORTED_10000baseKR_Full SUPPORTED_10000baseR_FEC SUPPORTED_Pause SUPPORTED_Asym_Pause SUPPORTED_Backplane
Returns a sorted list of supported speed/duplex settings suitable for showing to the user.
Returns a list of ports on this interface suitable for showing to the user.
NOTE: This is unrelated to cards that have multiple interfaces on them, this is for (old fashioned) cards that have multiple ports (AUI, BNC, etc) for the same interface,only one of which may be used at a time. See the port method for more information.
port
Gets or sets the modes being advertised for auto-negotiation as a bit field. Returns the current/new value.
The following constants are useful here:
ADVERTISED_10baseT_Half ADVERTISED_10baseT_Full ADVERTISED_100baseT_Half ADVERTISED_100baseT_Full ADVERTISED_1000baseT_Half ADVERTISED_1000baseT_Full ADVERTISED_2500baseX_Full ADVERTISED_1000baseKX_Full ADVERTISED_10000baseT_Full ADVERTISED_10000baseKX4_Full ADVERTISED_10000baseKR_Full ADVERTISED_10000baseR_FEC ADVERTISED_Pause ADVERTISED_Asym_Pause
Returns a sorted list of advertised speed/duplex settings suitable for showing to the user.
Get or set the link speed in Mbps. Returns the current/new value.
Setting this field will only have an effect if auto-negotiation is also disabled before calling apply.
Get or set the duplex of the link, full is true, half is false and unknown is undefined. Returns the current/new value.
Get or set the auto-negotiation flag. Returns the current/new value.
Get or set the port type. Returns the current/new value.
PORT_TP (Twisted Pair) PORT_AUI PORT_MII (Media Independent Interface) PORT_FIBRE PORT_BNC PORT_OTHER
Return a user-friendly name for the port type.
Get or set the transceiver type. Returns the current/new value.
XCVR_INTERNAL XCVR_EXTERNAL XCVR_DUMMY1 XCVR_DUMMY2 XCVR_DUMMY3
Return a user-friendly name for the transceiver type.
Gets the modes being advertised for auto-negotiation by the other end of the link as a bit field.
Returns a sorted list of speed/duplex settings advertised by the other end of the link suitable for showing to the user.
Linux::Ethtool, Linux::Ethtool::WOL
To install Linux::Ethtool, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Linux::Ethtool
CPAN shell
perl -MCPAN -e shell install Linux::Ethtool
For more information on module installation, please visit the detailed CPAN module installation guide.