The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Win32::IPConfig::Adapter - Windows NT/2000 Network Adapter IP Configuration Settings

SYNOPSIS

    use Win32::IPConfig;

    $host = shift || "";
    if ($ipconfig = Win32::IPConfig->new($host)) {
        print "hostname=", $ipconfig->get_hostname, "\n";
        print "domain=", $ipconfig->get_domain, "\n";
        print "nodetype=", $ipconfig->get_nodetype, "\n";

        for $adapter (@{$ipconfig->get_adapters}) {
            print "\nAdapter ";
            print $adapter->get_id, "\n";
            print $adapter->get_description, "\n";

            if ($adapter->is_dhcp_enabled) {
                print "DHCP is enabled\n";
            } else {
                print "DHCP is not enabled\n";
            }

            @ipaddresses = @{$adapter->get_ipaddresses};
            print "ipaddresses=@ipaddresses (", scalar @ipaddresses, ")\n";

            @gateways = @{$adapter->get_gateways};
            print "gateways=@gateways (", scalar @gateways, ")\n";

            print "domain=", $adapter->get_domain, "\n";

            @dns = @{$adapter->get_dns};
            print "dns=@dns (", scalar @dns, ")\n";

            @wins = @{$adapter->get_wins};
            print "wins=@wins (", scalar @wins, ")\n";
        }
    }

DESCRIPTION

Win32::IPConfig::Adapter encapsulates the TCP/IP configuration settings for a Windows NT/2000 network adapter.

METHODS

$adapter->is_dhcp_enabled

Returns 1 if DHCP is enabled, 0 if it is not. If DHCP is enabled, the values returned from the get_ipaddresses, get_gateways, get_dns, and get_wins methods will be retrieved from the dhcp-specific registry keys.

$adapter->get_ipaddresses

Returns a reference to a list of ip addresses for this adapter.

$adapter->get_gateways

Returns a reference to a list containing default gateway ip addresses. (Bet you didn't realise Windows NT/2000 allowed you to have multiple default gateways.) If no default gateways are configured, a reference to an empty list will be returned.

$adapter->get_dns

Returns a reference to a list containing DNS server ip addresses. If no DNS servers are configured, a reference to an empty list will be returned.

$adapter->get_wins

Returns a reference to a list containing WINS server ip addresses. If no WINS servers are configured, a reference to an empty list will be returned.

AUTHOR

James Macfarlane, <jmacfarla@cpan.org>