use strict; use warnings; use Win32::OLE qw(in); $|++; my $object = Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}!//' . '.' ); foreach my $nic ( in $object->InstancesOf('Win32_NetworkAdapterConfiguration') ) { next unless $nic->{IPEnabled}; print "Adapter: "; print $nic->{Caption}, "\n"; print "Default gateway: ", join(' ', @{ $nic->{DefaultIPGateway} }), "\n" if $nic->{DefaultIPGateway}; my %addresses; @addresses{ @{ $nic->{IPAddress} } } = @{ $nic->{IPSubnet} }; print "IP Addresses: \n"; print "IP: $_ Mask: ", $addresses{$_}, "\n" for keys %addresses; print "DNS Servers: ", join(' ', @{ $nic->{DNSServerSearchOrder} } ), "\n" if $nic->{DNSServerSearchOrder}; } exit 0;