Information Technology Reference
In-Depth Information
Set adapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each a in adapters
errIP = a.EnableStatic(strIPAddress, strSubnetMask)
errGateways = a.SetGateways(strGateway, strGatewaymetric)
If errIP = 0 Then
WScript.Echo "Success! The IP address has been changed."
Else
WScript.Echo "Error! The IP address could not be changed."
End If
Next
How It Works
While you can use the Dynamic Host Configuration Protocol (DHCP) to automatically assign
IP address information to multiple computers, many administrators choose to use static IP
configurations for the servers on their networks. Using a static IP ensures that the server will
always maintain the same IP address even if a DHCP server cannot be contacted, so other
computers will be able to locate it using one consistent address.
When using a statically assigned IP address, keep in mind that you need to manually
configure all IP configuration options, particularly the subnet mask and default gateway, as well as
the IP addresses of DNS and WINS servers on your network. If any of these addresses change, you'll
need to manually update the configuration of any computer with a static IP address. (Refer to
Recipe 1-9 for information on statically configuring DNS servers and Recipe 1-13 to configure
WINS server information.)
Note Because of this need to manually configure and update statically configured computers, the increasingly
preferred approach is instead to configure DHCP reservations for those computers that require a consistent
IP address.
If a computer is multi-homed, that is, it has more than one NIC installed that needs to
be configured for TCP/IP, you can use any of these solutions to configure IP information for
each adapter.
See Also
Recipe 1-3 for more on configuring the gateway metric
1-3. Configuring Dead-Gateway Detection
Problem
You want to configure dead-gateway detection on a Windows Server 2003 computer so that the
computer can continue to route traffic even if its default gateway becomes unavailable.
Search WWH ::




Custom Search