Net::Ifconfig::Wrapper

Net::Ifconfig::Wrapper is a Perl module that provides a unified way to configure network interfaces on FreeBSD and Linux OSes.
Download

Net::Ifconfig::Wrapper Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Daniel Podolsky
  • Publisher web site:
  • http://search.cpan.org/~tpaba/Net-Socket-NonBlock-0.15/NonBlock.pm

Net::Ifconfig::Wrapper Tags


Net::Ifconfig::Wrapper Description

Net::Ifconfig::Wrapper is a Perl module that provides a unified way to configure network interfaces on FreeBSD and Linux OSes. Net::Ifconfig::Wrapper is a Perl module that provides a unified way to configure network interfaces on FreeBSD, OpenBSD, Solaris, Linux, OS X, and WinNT (from Win2K).SYNOPSIS #!/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 'inet' and 'down' commands # are not working on WinNT. +/-alias are working, of course. use strict; use Net::Ifconfig::Wrapper; my $Usage = {$ARGV} or die "Interface '$ARGV' is unknownn"; if (!defined($ARGV)) { print IfaceInfo($Info, $ARGV); exit 0; } my $CmdLine = join(' ', @ARGV); my $Result = undef; if ($CmdLine =~ m/As*(+)s+downs*Z/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('down', $1, '', ''); } elsif ($CmdLine =~ m/As*(+)s+inets+(d{1,3}(?:.d{1,3}){3})s+masks+(d{1,3}(?:.d{1,3}){3})s*Z/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('inet', $1, $2, $3); } elsif ($CmdLine =~ m/As*(+)s+inets+(d{1,3}(?:.d{1,3}){3})s+masks+(d{1,3}(?:.d{1,3}){3})s++?aliass*Z/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('+alias', $1, $2, $3); } elsif ($CmdLine =~ m/As*(+)s+inets+(d{1,3}(?:.d{1,3}){3})s+(:?masks+(d{1,3}(?:.d{1,3}){3})s+)?-aliass*Z/i) { $Result = Net::Ifconfig::Wrapper::Ifconfig('-alias', $1, $2, ''); } else { die $Usage; }; $Result or die $@; exit 0; sub IfaceInfo { my ($Info, $Iface) = @_; my $Res = "$Iface:t".($Info->{$Iface}{'status'} ? 'UP' : 'DOWN')."n"; while (my ($Addr, $Mask) = each(%{$Info->{$Iface}{'inet'}})) { $Res .= sprintf("tinet %-15s mask $Maskn", $Addr); }; $Info->{$Iface}{'ether'} and $Res .= "tether ".$Info->{$Iface}{'ether'}."n"; $Info->{$Iface}{'descr'} and $Res .= "tdescr '".$Info->{$Iface}{'descr'}."'n"; return $Res; };Requirements:· Perl Requirements: · Perl


Net::Ifconfig::Wrapper Related Software