You can use WMI to query this type of information.
Consult the documentation for Win32_NetworkAdapterConfiguration
Here's something I very quickly threw together:
use strict; use warnings; use Win32::OLE qw(in); $|++; my $object = Win32::OLE->GetObject('winmgmts:{impersonationLevel=imper +sonate}!//' . '.' ); foreach my $nic ( in $object->InstancesOf('Win32_NetworkAdapterConfigu +ration') ) { 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;
In reply to Re: How can I get current IP,DNS,MAC,GW under XP?
by bingos
in thread How can I get current IP,DNS,MAC,GW under XP?
by perllee
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |