Net::I...rapper(3pm)
πΈ NAME πΈ
Net::Ifconfig::Wrapper β provides a unified way to configure network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K). π
β¨ SYNOPSIS β¨
use Net::Ifconfig::Wrapper;
my $rhInfo = Net::Ifconfig::Wrapper::Ifconfig('list');
π¦ DESCRIPTION π¦
This module provides a unified way to configure the network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K) systems. One wrapper, all the OSes, no cap. π
Only inet (IPv4) and ether (MAC) addresses are supported at this time.
On Unix, this module calls the system ifconfig command to gather the information. On Windows, the functions from IpHlpAPI.DLL are called.
For all supported Unixes, Net::Ifconfig::Wrapper expects the ifconfig command to be /sbin/ifconfig. Like, it's not guessing, bestie, that's the path. π
See the top-level README file for a list of tested OSes.
On the MSWin32 family, only Windows NT is supported. In the Windows NT family, only Windows 2000 or later is supported.
π« The Net::Ifconfig::Wrapper methods π«
Ifconfig(Command, Interface, Address, Netmask);
The one and only method of the Net::Ifconfig::Wrapper module. Does all the jobs. The particular action is described by the $Command parameter. It's giving "one method to rule them all" energy. π«Ά
$Command could be:
'list'βIfconfig('list', '', '', '')will return a reference to a hash containing information about interfaces.
The structure of this hash is the following:
{IfaceName => {'status' => 0|1 # The status of the interface. 0 means down, 1 means up
'ether' => MACaddr, # The ethernet address of the interface if available
'descr' => Description, # The description of the interface if available
'inet' => {IPaddr1 => NetMask, # The IP address and his netmask, both are in AAA.BBB.CCC.DDD notation
IPaddr2 => NetMask,
...
},
...
};
Interface, Address, Netmask parameters are ignored. (They're just standing there, being ignored. iconic. π)
The following shows what program is called for each OS:
- FreeBSD β
/sbin/ifconfig -a - Solaris β
/sbin/ifconfig -a - OpenBSD β
/sbin/ifconfig -A - Linux β
/sbin/ifconfig -a - OS X β
/sbin/ifconfig -a - MSWin32 β
GetAdaptersInfofunction fromIpHlpAPI.DLL
Known Limitations:
- OpenBSD:
/sbin/ifconfig -Acommand is not returning information about MAC addresses so we are trying to get it from/usr/sbin/arp -acommand (firststaticentry). If no one present theff:ff:ff:ff:ffaddress is returned. - MSWin32:
GetAdaptersInfofunction is not returning information about the interface which has address 127.0.0.1 bound to it, so we have no way to return it. - Not a limitation, but a small problem: in MSWin32, interface names are not human-readable, they look like
{843C2077-30EC-4C56-A401-658BB1E42BC7}(on Win2K at least). Not the vibe. π
'inet'β This function is used to set IPv4 address on interface. It is called as
Ifconfig('inet', $IfaceName, $Addr, $Mask);
$IfaceName is an interface name as displayed by 'list' command
$Addr is an IPv4 address in the AAA.AAA.AAA.AAA notation
$Mask is an IPv4 subnet mask in the MMM.MMM.MMM.MMM notation
In order to accomplish this, the following actual ifconfig programs are called:
- FreeBSD β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up - Solaris β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up - OpenBSD β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up - Linux β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up - OS X β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up - MSWin32 β nothing :(
Known Limitations:
- MSWin32: I did not find a reliable way to recognize the
mainaddress on the Win32 network interface, so I have disabled this functionality. If you know how, please let me know.
'up'β Just a synonym for'inet''down'β This function is used to bring specified interface down. It is called as
Ifconfig('inet', $IfaceName, '', '');
$IfaceName is an interface name as displayed by 'list' command
Last two arguments are ignored.
In order to accomplish this, the following programs are called:
- FreeBSD β
/sbin/ifconfig %Iface% down - Solaris β
/sbin/ifconfig %Iface% down - OpenBSD β
/sbin/ifconfig %Iface% down - Linux β
/sbin/ifconfig %Iface% down - OS X β
/sbin/ifconfig %Iface% down - MSWin32 β Sorry, this function is not possible.
Known Limitations:
- MSWin32: I did not find the way to implement the
'up'command so I did not implement'down'.
'+alias'β This function is used to set IPv4 alias address on interface. It have to be called as
Ifconfig('+alias', $IfaceName, $Addr, $Mask);
$IfaceName is an interface name as displayed by 'list' command
$Addr is an IPv4 address in the AAA.AAA.AAA.AAA notation
$Mask is an IPv4 subnet mask in the MMM.MMM.MMM.MMM notation
In order to accomplish this, the following ifconfig programs are called:
- FreeBSD β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias - Solaris β
/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up - OpenBSD β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias - Linux β
/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up - OS X β
/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias - MSWin32 β
AddIPAddressfunction fromIpHlpAPI.DLL
First available logic interface is taken automatically for Solaris and Linux. β¨
'alias'β Just a synonim for'+alias''-alias'β This function is used to remove IPv4 alias address from interface. It have to be called as
Ifconfig('-alias', $IfaceName, $Addr, '');
$IfaceName is an interface name as displayed by 'list' command.
$Addr is an IPv4 address in the AAA.AAA.AAA.AAA notation.
Last argument is ignored if present.
In order to accomplish this, the following ifconfig programs are called:
- FreeBSD β
/sbin/ifconfig %Iface% inet %Addr% -alias - Solaris β
/sbin/ifconfig %Iface%:%Logic% down - OpenBSD β
/sbin/ifconfig %Iface% inet %Addr% -alias - Linux β
/sbin/ifconfig %Iface%:%Logic% down - OS X β
/sbin/ifconfig %Iface% inet %Addr% -alias - MSWin32 β
DeleteIPAddressfunction fromIpHlpAPI.DLL
Appropriate logic interface is obtained automatically for Solaris and Linux.
On success, the Ifconfig(...) function returns the defined value. Actually, it is a reference to the array containing the output of the actual ifconfig program called. It ate and left no crumbs. π₯
In case of error, Ifconfig(...) returns 'undef' value, and the $@ variable contains the error message. π
Heads up bestie: check$@when you getundefback, that's where the tea is.
π¦ EXPORT π¦
None by default. Not a single thing. Zero. nada. π
π AUTHOR π
Daniel Podolsky, <tpaba@cpan.org> As of 2015-11, maintained by Martin Thurn <mthurn@cpan.org>
π SEE ALSO π
ifconfig(8), Internet Protocol Helper in Platform SDK.
and that's the whole page, bestie β this one's from perl v5.36.0, dated 2022-11-19. go configure some interfaces, you absolute icon πβ¨
π¦ where this page comes from
- debian bookworm: libnet-ifconfig-wrapper-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libnet-ifconfig-wrapper-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libnet-ifconfig-wrapper-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libnet-ifconfig-wrapper-perl 0.26-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libnet-ifconfig-wrapper-perl 0.26-2 Β· 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