.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::Ifconfig::Wrapper 3pm" .TH Net::Ifconfig::Wrapper 3pm "2012-01-19" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::Ifconfig::Wrapper \- provides a unified way to configure network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K). .PP Version 0.11 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& #!/usr/local/bin/perl \-w \& # uni\-ifconfig.pl \& # The unified ifconfig command. \& # Works the same way on FreeBSD, OpenBSD, Solaris, Linux, OS X, WinNT (from Win2K). \& # Note: due of Net::Ifconfig::Wrapper limitations \*(Aqinet\*(Aq and \*(Aqdown\*(Aq commands \& # are not working on WinNT. +/\-alias are working, of course. \& \& use strict; \& \& use Net::Ifconfig::Wrapper; \& \& my $Usage = << \*(AqEndOfText\*(Aq; \& uni\-ifconfig.pl # Print this notice \& uni\-ifconfig.pl \-a # Print info about all interfaces \& uni\-ifconfig.pl # Print info obout specified interface \& uni\-ifconfig.pl down \& # Bring specified interface down \& uni\-ifconfig.pl inet mask \& # Set the specified address on the specified interface \& # and bring this interface up \& uni\-ifconfig.pl inet mask [+]alias \& # Set the specified alias address \& # on the specified interface \& uni\-ifconfig.pl inet [mask ] \-alias \& # Remove specified alias address \& # from the specified interface \& EndOfText \& \& my $Info = Net::Ifconfig::Wrapper::Ifconfig(\*(Aqlist\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq) \& or die $@; \& \& scalar(keys(%{$Info})) \& or die "No one interface found. Something wrong?\en"; \& \& if (!scalar(@ARGV)) \& { \& print $Usage; \& exit 0; \& } \& \& if ($ARGV[0] eq \*(Aq\-a\*(Aq) \& { \& defined($ARGV[1]) \& and die $Usage; \& foreach (sort(keys(%{$Info}))) \& { print IfaceInfo($Info, $_); }; \& exit 0; \& }; \& \& $Info\->{$ARGV[0]} \& or die "Interface \*(Aq$ARGV[0]\*(Aq is unknown\en"; \& \& if (!defined($ARGV[1])) \& { \& print IfaceInfo($Info, $ARGV[0]); \& exit 0; \& } \& \& my $CmdLine = join(\*(Aq \*(Aq, @ARGV); \& my $Result = undef; \& \& if ($CmdLine =~ m/\eA\es*([\ew\e{\e}\e\-]+)\es+down\es*\eZ/i) \& { \& $Result = Net::Ifconfig::Wrapper::Ifconfig(\*(Aqdown\*(Aq, $1, \*(Aq\*(Aq, \*(Aq\*(Aq); \& } \& elsif ($CmdLine =~ m/\eA\es*([\ew\e{\e}\e\-]+)\es+inet\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es+mask\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es*\eZ/i) \& { \& $Result = Net::Ifconfig::Wrapper::Ifconfig(\*(Aqinet\*(Aq, $1, $2, $3); \& } \& elsif ($CmdLine =~ m/\eA\es*([\ew\e{\e}\e\-]+)\es+inet\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es+mask\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es+\e+?alias\es*\eZ/i) \& { \& $Result = Net::Ifconfig::Wrapper::Ifconfig(\*(Aq+alias\*(Aq, $1, $2, $3); \& } \& elsif ($CmdLine =~ m/\eA\es*([\ew\e{\e}\e\-]+)\es+inet\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es+(:?mask\es+(\ed{1,3}(?:\e.\ed{1,3}){3})\es+)?\e\-alias\es*\eZ/i) \& { \& $Result = Net::Ifconfig::Wrapper::Ifconfig(\*(Aq\-alias\*(Aq, $1, $2, \*(Aq\*(Aq); \& } \& else \& { die $Usage; }; \& \& $Result \& or die $@; \& \& exit 0; \& \& sub IfaceInfo \& { \& my ($Info, $Iface) = @_; \& \& my $Res = "$Iface:\et".($Info\->{$Iface}{\*(Aqstatus\*(Aq} ? \*(AqUP\*(Aq : \*(AqDOWN\*(Aq)."\en"; \& \& while (my ($Addr, $Mask) = each(%{$Info\->{$Iface}{\*(Aqinet\*(Aq}})) \& { $Res .= sprintf("\etinet %\-15s mask $Mask\en", $Addr); }; \& \& $Info\->{$Iface}{\*(Aqether\*(Aq} \& and $Res .= "\etether ".$Info\->{$Iface}{\*(Aqether\*(Aq}."\en"; \& \& $Info\->{$Iface}{\*(Aqdescr\*(Aq} \& and $Res .= "\etdescr \*(Aq".$Info\->{$Iface}{\*(Aqdescr\*(Aq}."\*(Aq\en"; \& \& return $Res; \& }; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a unified way to configure the network interfaces on FreeBSD, OpenBSD, Solaris, Linux, \s-1OS\s0 X, and WinNT (from Win2K) systems. .PP \&\fI\f(BIOnly \f(CB\*(C`inet\*(C'\f(BI (IPv4) and \f(CB\*(C`ether\*(C'\f(BI (\s-1MAC\s0) addresses are supported at the moment\fI\fR .PP On Unixes this module calls the system \f(CW\*(C`ifconfig\*(C'\fR command to perform the actions. On Windows the functions from IpHlpAPI.DLL are called. .PP For all supported Unixes \f(CW\*(C`Net::Ifconfig::Wrapper\*(C'\fR expect \f(CW\*(C`ifconfig\*(C'\fR command to be \f(CW\*(C`/sbin/ifconfig\*(C'\fR. .PP Module was tested on FreeBSD 4.7,4.8,5.3 (Intel), RedHat 6.2,7.3,8.0 (Intel), Win2000 Pro (Intel), OpenBSD 3.1 (\s-1SPARC\s0), Solaris 7 (\s-1SPARC\s0), \&\s-1OS\s0 X 10.3 (aka Panther), \s-1OS\s0 X 10.4 (aka Tiger). .PP \&\fIIn MSWin32 family only WinNT is supported. In WinNT family only Win2K or later is supported.\fR .SH "The Net::Ifconfig::Wrapper methods" .IX Header "The Net::Ifconfig::Wrapper methods" .ie n .IP """Ifconfig(\f(CICommand\f(CW, \f(CIInterface\f(CW, \f(CIAddress\f(CW, \f(CINetmask\f(CW);""" 4 .el .IP "\f(CWIfconfig(\f(CICommand\f(CW, \f(CIInterface\f(CW, \f(CIAddress\f(CW, \f(CINetmask\f(CW);\fR" 4 .IX Item "Ifconfig(Command, Interface, Address, Netmask);" The first and the last method of the \f(CW\*(C`Net::Ifconfig::Wrapper\*(C'\fR module. Do all the job. The particular action is described by the \f(CW$Command\fR parameter. .Sp \&\f(CW$Command\fR could be: .RS 4 .IP "'list'" 8 .IX Item "'list'" \&\f(CW\*(C`Ifconfig(\*(Aqlist\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq)\*(C'\fR will return the reference to the hash contains the information about interfaces. .Sp The structure of this hash is the following: .Sp .Vb 9 \& {IfaceName => {\*(Aqstatus\*(Aq => 0|1 # The status of the interface. 0 means down, 1 means up \& \*(Aqether\*(Aq => MACaddr, # The ethernet address of the interface if available \& \*(Aqdescr\*(Aq => Description, # The description of the interface if available \& \*(Aqinet\*(Aq => {IPaddr1 => NetMask, # The IP address and his netmask, both are in AAA.BBB.CCC.DDD notation \& IPaddr2 => NetMask, \& ... \& }, \& ... \& }; .Ve .Sp \&\fIInterface\fR, \fIAddress\fR, \fINetmask\fR parameters are ignored. .Sp The following programs are called: .RS 8 .IP "FreeBSD" 12 .IX Item "FreeBSD" \&\f(CW\*(C`/sbin/ifconfig \-a\*(C'\fR .IP "Solaris" 12 .IX Item "Solaris" \&\f(CW\*(C`/sbin/ifconfig \-a\*(C'\fR .IP "OpenBSD" 12 .IX Item "OpenBSD" \&\f(CW\*(C`/sbin/ifconfig \-A\*(C'\fR .IP "Linux" 12 .IX Item "Linux" \&\f(CW\*(C`/sbin/ifconfig \-a\*(C'\fR .IP "\s-1OS\s0 X" 12 .IX Item "OS X" \&\f(CW\*(C`/sbin/ifconfig \-a\*(C'\fR .IP "MSWin32" 12 .IX Item "MSWin32" \&\f(CW\*(C`GetAdaptersInfo\*(C'\fR function from \f(CW\*(C`IpHlpAPI.DLL\*(C'\fR .RE .RS 8 .Sp Limitations: .Sp OpenBSD: \f(CW\*(C`/sbin/ifconfig \-A\*(C'\fR command is not returning information about \s-1MAC\s0 addresses so we are trying to get it from \f(CW\*(Aq/usr/sbin/arp \-a\*(Aq\fR command (first \fI\f(CI\*(Aqstatic\*(Aq\fI\fR entry). If no one present the \fI\f(CI\*(Aqff:ff:ff:ff:ff\*(Aq\fI\fR address is returned. .Sp MSWin32: \f(CW\*(C`GetAdaptersInfo\*(C'\fR function is not returning information about interface which have address \f(CW127.0.0.1\fR binded so \f(CW\*(C`Net::Ifconfig::Wrapper\*(C'\fR have no ability to display it. .Sp Not limitation but little problem: MSWin32 interface names are not human-readable, they looks like \f(CW\*(C`{843C2077\-30EC\-4C56\-A401\-658BB1E42BC7}\*(C'\fR (on Win2K at least). .RE .IP "'inet'" 8 .IX Item "'inet'" This function is used to set IPv4 address on interface. It have to be called as .Sp .Vb 1 \& Ifconfig(\*(Aqinet\*(Aq, $IfaceName, $Addr, $Mask); .Ve .Sp \&\fI\f(CI$IfaceName\fI\fR is an interface name as displayed by \f(CW\*(Aqlist\*(Aq\fR command .Sp \&\fI\f(CI$Addr\fI\fR is an IPv4 address in the \f(CW\*(C`AAA.AAA.AAA.AAA\*(C'\fR notation .Sp \&\fI\f(CI$Mask\fI\fR is an IPv4 subnet mask in the \f(CW\*(C`MMM.MMM.MMM.MMM\*(C'\fR notation .Sp The following actual \f(CW\*(C`ifconfig\*(C'\fR programs are called .RS 8 .IP "FreeBSD" 12 .IX Item "FreeBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up\*(C'\fR .IP "Solaris" 12 .IX Item "Solaris" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up\*(C'\fR .IP "OpenBSD" 12 .IX Item "OpenBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up\*(C'\fR .IP "Linux" 12 .IX Item "Linux" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up\*(C'\fR .IP "\s-1OS\s0 X" 12 .IX Item "OS X" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% up\*(C'\fR .IP "MSWin32:" 12 .IX Item "MSWin32:" nothing :( .RE .RS 8 .Sp Limitations: .Sp MSWin32: I did not find the relaible way to recognize the \*(L"main\*(R" address on the Win32 network interface, so I have disabled this functionality. If you know the way please let me know. .RE .IP "'up'" 8 .IX Item "'up'" Just a synonym for \f(CW\*(Aqinet\*(Aq\fR .IP "'down'" 8 .IX Item "'down'" This function is used to bring specified interface down. It have to be called as .Sp .Vb 1 \& Ifconfig(\*(Aqinet\*(Aq, $IfaceName, \*(Aq\*(Aq, \*(Aq\*(Aq); .Ve .Sp \&\fI\f(CI$IfaceName\fI\fR is an interface name as displayed by \f(CW\*(Aqlist\*(Aq\fR command .Sp \&\fIAddress\fR and \fINetmask\fR are ignored. .Sp The following actual \f(CW\*(C`ifconfig\*(C'\fR programs are called .RS 8 .IP "FreeBSD" 12 .IX Item "FreeBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% down\*(C'\fR .IP "Solaris" 12 .IX Item "Solaris" \&\f(CW\*(C`/sbin/ifconfig %Iface% down\*(C'\fR .IP "OpenBSD" 12 .IX Item "OpenBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% down\*(C'\fR .IP "Linux" 12 .IX Item "Linux" \&\f(CW\*(C`/sbin/ifconfig %Iface% down\*(C'\fR .IP "\s-1OS\s0 X" 12 .IX Item "OS X" \&\f(CW\*(C`/sbin/ifconfig %Iface% down\*(C'\fR .IP "MSWin32" 12 .IX Item "MSWin32" nothing :( .RE .RS 8 .Sp Limitations: .Sp MSWin32: I did not find the way to implement the \f(CW\*(Aqup\*(Aq\fR command so I did not implement \f(CW\*(Aqdown\*(Aq\fR. .RE .IP "'+alias'" 8 .IX Item "'+alias'" This function is used to set IPv4 alias address on interface. It have to be called as .Sp .Vb 1 \& Ifconfig(\*(Aq+alias\*(Aq, $IfaceName, $Addr, $Mask); .Ve .Sp \&\fI\f(CI$IfaceName\fI\fR is an interface name as displayed by \f(CW\*(Aqlist\*(Aq\fR command .Sp \&\fI\f(CI$Addr\fI\fR is an IPv4 address in the \f(CW\*(C`AAA.AAA.AAA.AAA\*(C'\fR notation .Sp \&\fI\f(CI$Mask\fI\fR is an IPv4 subnet mask in the \f(CW\*(C`MMM.MMM.MMM.MMM\*(C'\fR notation .Sp The following actual \f(CW\*(C`ifconfig\*(C'\fR programs are called .RS 8 .IP "FreeBSD" 12 .IX Item "FreeBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias\*(C'\fR .IP "Solaris" 12 .IX Item "Solaris" \&\f(CW\*(C`/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up\*(C'\fR .IP "OpenBSD" 12 .IX Item "OpenBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias\*(C'\fR .IP "Linux" 12 .IX Item "Linux" \&\f(CW\*(C`/sbin/ifconfig %Iface%:%Logic% inet %Addr% netmask %Mask% up\*(C'\fR .IP "\s-1OS\s0 X" 12 .IX Item "OS X" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% netmask %Mask% alias\*(C'\fR .IP "MSWin32" 12 .IX Item "MSWin32" \&\f(CW\*(C`AddIPAddress\*(C'\fR function from \f(CW\*(C`IpHlpAPI.DLL\*(C'\fR .RE .RS 8 .Sp \&\fIFirst available logic interface is taken automatically for Solaris and Linux\fR .RE .IP "'alias'" 8 .IX Item "'alias'" Just a synonim for \f(CW\*(Aq+alias\*(Aq\fR .IP "'\-alias'" 8 .IX Item "'-alias'" This function is used to remove IPv4 alias address from interface. It have to be called as .Sp .Vb 1 \& Ifconfig(\*(Aq\-alias\*(Aq, $IfaceName, $Addr, \*(Aq\*(Aq); .Ve .Sp \&\fI\f(CI$IfaceName\fI\fR is an interface name as displayed by \f(CW\*(Aqlist\*(Aq\fR command .Sp \&\fI\f(CI$Addr\fI\fR is an IPv4 address in the \f(CW\*(C`AAA.AAA.AAA.AAA\*(C'\fR notation .Sp \&\fINetmask\fR> parameter is ignored .Sp The following actual \f(CW\*(C`ifconfig\*(C'\fR programs are called .RS 8 .IP "FreeBSD" 12 .IX Item "FreeBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% \-alias\*(C'\fR .IP "Solaris" 12 .IX Item "Solaris" \&\f(CW\*(C`/sbin/ifconfig %Iface%:%Logic% down\*(C'\fR .IP "OpenBSD" 12 .IX Item "OpenBSD" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% \-alias\*(C'\fR .IP "Linux" 12 .IX Item "Linux" \&\f(CW\*(C`/sbin/ifconfig %Iface%:%Logic% down\*(C'\fR .IP "\s-1OS\s0 X" 12 .IX Item "OS X" \&\f(CW\*(C`/sbin/ifconfig %Iface% inet %Addr% \-alias\*(C'\fR .IP "MSWin32" 12 .IX Item "MSWin32" \&\f(CW\*(C`DeleteIPAddress\*(C'\fR function from \f(CW\*(C`IpHlpAPI.DLL\*(C'\fR .RE .RS 8 .Sp \&\fIAppropriate logic interface is obtained automatically for Solaris and Linux\fR .RE .RE .RS 4 .Sp On success \f(CW\*(C`Ifconfig(...)\*(C'\fR returns the defined value. Actually, it is a reference to the array contains the output of the actual \fI\f(CI\*(C`ifconfig\*(C'\fI\fR program called. .Sp In case of troubles \f(CW\*(C`Ifconfig(...)\*(C'\fR returns \f(CW\*(Aqundef\*(Aq\fR value, \&\f(CW$@\fR variable contains the error message. .RE .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" None by default. .SH "AUTHOR" .IX Header "AUTHOR" Daniel Podolsky, .SH "SEE ALSO" .IX Header "SEE ALSO" ifconfig(8), \fIInternet Protocol Helper\fR in \fIPlatform \s-1SDK\s0\fR.