Check out Re: Checking my default gateway. It's something I whipped together for NT/2K. Also, someone on Activestate's Perl Win32 Admin mail list had a WMI version, prob. more portable within Win32 platforms.

For *nix, there is usually a pastle of files you could read to get the information, for instance on Solaris some include:

UPDATE: Here is the one from the AS list I mentioned. I cannot find the original post, so the author will remain anonymous. Please note that I take no credit for this.

use Win32::OLE qw(in); $WSQLQuery = "Select * From Win32_NetworkAdapterConfiguration"; $BOOL = { 0 => "FALSE", 1 => "TRUE", '' => "UNDEFINED" }; if ( @ARGV ){ $NodeName = @ARGV[0]; $NodeName =~ s/\\//g; print "Network Interfaces For Workstation $NodeName\n\n"; $NodeName = "//".$NodeName; } else { $NodeName = ""; print "Network Interfaces For Local Workstation\n\n"; } $WMI = Win32::OLE->GetObject("winmgmts:".$NodeName); $Enum = $WMI->ExecQuery($WSQLQuery); foreach $Interface ( in $Enum ){ if ($Interface eq undef){ "No Network Found"; } else { print "Caption = ".$Interface->Caption."\n"; print "Description = ".$Interface->Description."\n"; print "Service Name = ".$Interface->ServiceName."\n"; print "Setting ID = ".$Interface->SettingID."\n"; print "Index = ".$Interface->Index."\n"; print "Database Path = ".$Interface->DatabasePath."\n"; print "MTU = ".$Interface->MTU."\n\n"; print "IP Address = ".join(".",@{$Interface->IPAddress})."\n"; print "IP Subnet = ".join(".",@{$Interface->IPSubnet})."\n"; print "Default IP Gateway = ".join(".",@{$Interface->DefaultIPGateway})."\n"; print "MAC Address = ".$Interface->MACAddress."\n\n"; print "ARP Always Source Route = ".$BOOL->{$Interface->ArpAlwaysSourceRoute}."\n"; print "ARP Use Ether SNAP = ".$BOOL->{$Interface->ArpUseEtherSNAP}."\n\n"; print "WINS Host Lookup File = ".$Interface->WINSHostLookupFile."\n"; print "WINS Primary Server = ".$Interface->WINSPrimaryServer."\n"; print "WINS Scope ID = ".$Interface->WINSScopeID."\n"; print "WINS Secondary Server = ".$Interface->WINSSecondaryServer."\n"; print "WINS Enable LM Hosts Lookup = ".$BOOL->{$Interface->WINSEnableLMHostsLookup}."\n\n"; print "Full DNS Registration Enabled = ".$BOOL->{$Interface->FullDNSRegistrationEnabled}."\n"; print "DNS Domain = ".$Interface->DNSDomain."\n"; print "DNS Host Name = ".$Interface->DNSHostName."\n"; print "DNS Enabled For WINS Resolution = ".$BOOL->{$Interface->DNSEnabledForWINSResolution}."\n"; print "DNS Server Search Order = ".join(", ",@{$Interface->DNSServerSearchOrder})."\n"; print "Domain DNS Registration Enabled = ".$BOOL->{$Interface->DomainDNSRegistrationEnabled}."\n"; print "DNS Domain Suffix Search Order = ".join(", ",@{$Interface->DNSDomainSuffixSearchOrder})."\n\n"; print "DHCP Enabled = ".$BOOL->{$Interface->DHCPEnabled}."\n"; print "DHCP Server = ".$Interface->DHCPServer."\n"; print "DHCP Lease Expires = ".$Interface->DHCPLeaseExpires."\n"; print "DHCP Lease Obtained = ".$Interface->DHCPLeaseObtained."\n\n"; print "TCP/IP Netbios Options = ".$Interface->TcpipNetbiosOptions."\n"; print "TCP Maximum Connect Retransmissions = ".$Interface->TcpMaxConnectRetransmissions."\n"; print "TCP Maximum Data Retransmissions = ".$Interface->TcpMaxDataRetransmissions."\n"; print "TCP Number of Connections = ".$Interface->TcpNumConnections."\n"; print "TCP Window Size = ".$Interface->TcpWindowSize."\n"; print "PMTUBH Detect Enabled = ".$BOOL->{$Interface->PMTUBHDetectEnabled}."\n"; print "PMTU Discovery Enabled = ".$BOOL->{$Interface->PMTUDiscoveryEnabled}."\n"; print "TCP Use RFC1122 Urgent Pointer = ".$BOOL->{$Interface->TcpUseRFC1122UrgentPointer}."\n"; print "Forward Buffer Memory = ".$Interface->ForwardBufferMemory."\n\n"; print "IP Enabled = ".$BOOL->{$Interface->IPEnabled}."\n"; print "Gateway Cost Metric = ".join(", ",@{$Interface->GatewayCostMetric})."\n"; print "Dead Gateway Detect Enabled = ".$BOOL->{$Interface->DeadGWDetectEnabled}."\n"; print "IP Filter Security Enabled = ".$BOOL->{$Interface->IPFilterSecurityEnabled}."\n"; print "IP Port Security Enabled = ".$BOOL->{$Interface->IPPortSecurityEnabled}."\n"; print "IP Sec Permit IP Protocols = ".join(", ",@{$Interface->IPSecPermitIPProtocols})."\n"; print "IP Sec Permit TCP Ports = ".join(", ",@{$Interface->IPSecPermitTCPPorts})."\n"; print "IP Sec Permit UDP Ports = ".join(", ",@{$Interface->IPSecPermitUDPPorts})."\n"; print "IP Use Zero Broadcast = ".$BOOL->{$Interface->IPUseZeroBroadcast}."\n"; print "IP Connection Metric = ".$Interface->IPConnectionMetric."\n"; print "Number of Forwarded Packets = ".$Interface->NumForwardPackets."\n"; print "Default TOS = ".$Interface->DefaultTOS."\n"; print "Default TTL = ".$Interface->DefaultTTL."\n"; print "Keep Alive Interval = ".$Interface->KeepAliveInterval."\n"; print "Keep Alive Time = ".$Interface->KeepAliveTime."\n"; print "IGMP Level = ".$Interface->IGMPLevel."\n\n"; print "IPX Enabled = ".$BOOL->{$Interface->IPXEnabled}."\n"; print "IPX Network Number = ".join(".",@{$Interface->IPXNetworkNumber})."\n"; print "IPX Address = ".$Interface->IPXAddress."\n"; print "IPX Virtual Net Number = ".$Interface->IPXVirtualNetNumber."\n"; print "IPX Frame Type = ".$Interface->IPXFrameType."\n"; print "IPX Media Type = ".$Interface->IPXMediaType."\n\n"; } }

HTH
--
idnopheq
Apply yourself to new problems without preparation, develop confidence in your ability to to meet situations as they arrise.


In reply to Re: ifconfig / ipconfig replacement by idnopheq
in thread ifconfig / ipconfig replacement by djeezus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.