10.3. Configuring an IP Address


You want to configure a static IP address or DHCP for a connection.


Using a graphical user interface

  1. From the Control Panel, open the Network Connections applet.

  2. Double-click the connection you want to configure.

  3. Click the Properties button.

  4. Double-click Internet Protocol (TCP/IP).

  5. To enable DHCP, select Obtain an IP address automatically. To use a static address, select Use the following IP address. Then configure the IP address, subnet mask, and default gateway.

  6. Click OK until all windows are closed.

Using a command-line interface

The following command configures DHCP for a connection:

> netsh int ip set address name="<ConnectionName>" source=dhcp

Here is an example for configuring the connection named "Local Area Connection" to use DHCP:

> netsh int ip set address name="Local Area Connection" source=dhcp

This configures a connection with a static IP and default gateway:

> netsh int ip set address name="<ConnectionName>" source=static <IP> 

This example configures a static IP address for "Local Area Connection":

> netsh int ip set address name="Local Area Connection" source=static 1

Using VBScript

' This code enables DHCP for the specified connection. ' ------ SCRIPT CONFIGURATION ------ strComputer = "." strConnection = "Local Area Connection" ' ------ END CONFIGURATION --------- set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") set colNA = objWMI.ExecQuery("select ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.