Get Subnetmask/GW of a remote System ?

Discussion in 'Perl Misc' started by ronny.kluge@barmenia.de, Jun 27, 2005.

  1. Guest

    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 .
    , Jun 27, 2005
    #1
    1. Advertising

  2. Thomas Kratz Guest

    wrote:
    > 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^.-
    Thomas Kratz, Jun 27, 2005
    #2
    1. Advertising

  3. Guest

    Hi Thomas,

    these are Windows 2003 / 2000 Server.

    Thank you, Ronny.
    , Jun 27, 2005
    #3
  4. Thomas Kratz Guest

    wrote:
    > 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^.-
    Thomas Kratz, Jun 28, 2005
    #4
  5. Joe Smith Guest

    wrote:

    > 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
    Joe Smith, Jun 28, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S3VtYXI=?=

    Get remote server system information using asp.net,c#

    =?Utf-8?B?S3VtYXI=?=, Feb 25, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    18,464
    vikastripathi
    Oct 6, 2012
  2. davidj411
    Replies:
    7
    Views:
    3,264
    Tim Golden
    Oct 8, 2009
  3. Tim Chandler
    Replies:
    0
    Views:
    210
    Tim Chandler
    Oct 7, 2003
  4. Jeff Wood
    Replies:
    7
    Views:
    194
    Jeff Wood
    Oct 18, 2005
  5. Markus Arike
    Replies:
    2
    Views:
    100
    Markus Arike
    Aug 19, 2008
Loading...

Share This Page