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->get_id

Returns the service name where the adapter settings are stored.

$adapter->get_description

Returns the Network Adapter Description.

$adapter->is_dhcp_enabled

Returns 1 if DHCP is enabled, 0 otherwise. If DHCP is enabled, the values returned from the get_ipaddresses, get_gateways, get_domain, 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. Statically configured default gateways will override any assigned by DHCP.

$adapter->get_domain

Returns the connection-specific domain suffix. This is only available on Windows 2000 and later. A statically configured domain will override any assigned by DHCP.

(As a convenience, this will return the host-specific DNS suffix on Windows NT machines.)

$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. Statically configured DNS Servers will override any assigned by DHCP.

$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. Statically configured WINS Servers will override any assigned by DHCP.

$adapter->set_domain($domainsuffix)

On Windows 2000, sets the connection-specific DNS suffix. On Windows NT, as a convenience, sets the host-specific DNS suffix.

You will not be allowed to set this value if the host adapter is configured through DHCP.

On Windows NT systems, the setting appears to take effect immediately. On Windows 2000 systems, the setting does not appear to take effect until the DNS Client service is restarted or the machine is rebooted.

$adapter->set_dns(@dnsservers)

Sets the DNS servers to @dnsservers. You can use an empty list to remove all configured DNS servers.

You will not be allowed to set this value if the host adapter is configured through DHCP.

On Windows NT systems, you will need to reboot for this setting to take effect. On Windws 2000 systems, you will need to restart the DNS Client service or reboot the machine.

$adapter->set_wins(@winsservers)

Set the host's WINS servers to @winsservers, which should be a list of contactable WINS servers on the network. You can use an empty list to remove all configured WINS servers.

You will not be allowed to set this value if the host adapter is configured through DHCP.

On Windows NT systems, you will need to reboot for this change to take effect. On Windows 2000, you also appear to need to reboot the host machine.

AUTHOR

James Macfarlane, <jmacfarla@cpan.org>

SEE ALSO

Win32::IPConfig