O'Reilly logo

Windows Server Cookbook by Robbie Allen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.3. Configuring an IP Address

Problem

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

Solution

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> 
                  <Mask> 
                  <GateWayIP> 
                  <Metric>

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

> netsh int ip set address name="Local Area Connection" source=static 10.3.53.3
255.255.255.0 10.3.53.1 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required