Get Subnetmask/GW of a remote System ?

R

ronny.kluge

Hallo @all,

i want to get a list of informations about any network interfaces from
~60 server. I need to know each Gateway and Subnetmask.

How can i do this with Perl ?

Thanks, Greets, Ronny .
 
T

Thomas Kratz

Hallo @all,

i want to get a list of informations about any network interfaces from
~60 server. I need to know each Gateway and Subnetmask.

How can i do this with Perl ?

Thanks, Greets, Ronny .

"server" is a bit unspecific. What OSes are you talking about?

Thomas

--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 
T

Thomas Kratz

Hi Thomas,

these are Windows 2003 / 2000 Server.

Thank you, Ronny.

Please read the posting guidelines posted here regularly. You should quote
the relevant context in a reply.

Here is an example how to get at the network adapter configuration with
WMI. For further information get the WMI Tools from M$ and read the docs
for Win32::OLE

Thomas

use strict;
use warnings;

use Win32::OLE qw/in/;
Win32::OLE->Option(Warn => 1);


for my $mach ( @ARGV ) {
print "$mach:\n";
for my $nwa ( GetNWA($mach) ) {
no warnings 'uninitialized';
print " MAC Address: $nwa->{MACAddress}\n";
print " IPAddresses: ",
join(', ', in($nwa->{IPAddress})),
"\n";
print " Gateways: ",
join(', ', in($nwa->{DefaultIPGateway})),
"\n";
}
}

sub GetNWA {
my($machine) = @_;

my $wmi = Win32::OLE->GetObject(
"winmgmts:{impersonationLevel=impersonate}\\\\$machine\\root\\cimv2"
) or
die 'error initializing WMI interface for $machine',
Win32::OLE->LastError;

my @nwa = grep {
$_->{IPEnabled}
} in($wmi->InstancesOf('Win32_NetworkAdapterConfiguration'));

return(@nwa);
}


--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
 
J

Joe Smith

i want to get a list of informations about any network interfaces from
~60 server. I need to know each Gateway and Subnetmask.

If you want the Subnetmask/GW of the local System instead of a remote
System, try Win32::IPHelper.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top