Managing TCPIP Settings

 < Day Day Up > 



Managing TCP/IP Settings

Computers use IP addresses to communicate over TCP/IP. IP addressing can be configured manually or dynamically at the command line. With a manual configuration, you assign the computer a static IP address. Static IP addresses are fixed and don’t change unless you change them. With a dynamic configuration, you configure the computer to get its IP address assignment from a DHCP server on the network. This IP address is assigned when the computer starts and might change over time. In domains, Windows servers use static IP addresses and Windows workstations used dynamic IP addresses.

Setting a Static IP Address

When you set a static IP address, you tell the computer the IP address to use, the subnet mask for this IP address, and, if necessary, the default gateway to use for internetwork communications. After you configure these IP settings, you will also need to configure name-resolution settings for Domain Name System (DNS) and possibly WINS.

You assign a static IP address using the Netsh Interface IP context. The command is SET ADDRESS and its syntax is

set address [name=]InterfaceName source=static addr=IPAddress 
mask=SubnetMask [gateway={none | DefaultGateway
[[gwmetric=]GatewayMetric]}

In most cases, the interface name you are working with is “Local Area Connection.” You can check to see the available interfaces by typing netsh interface ip show interface at the command prompt or, if you are in the Netsh Interface IP context, by typing show interface. The IP address you assign to the computer must not be used anywhere else on the network. The subnet mask field ensures that the computer communicates over the network properly. If the network uses subnets, the value you use may be different on each network segment within the company. If the computer needs to access other TCP/IP networks, the Internet, or other subnets, you must specify a default gateway. Use the IP address of the network’s default router.

The gateway metric indicates the relative cost of using a gateway. If multiple default routes are available for a particular IP address, the gateway with the lowest cost is used first. If the computer can’t communicate with the initial gateway, Windows Server 2003 tries to use the gateway with the next lowest metric. Unlike the GUI, Windows Server 2003 doesn’t automatically assign a metric to the gateway. You must assign the metric manually.

Consider the following example:

set address name="Local Area Connection" source=static 
addr=192.168.1.50 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=1

Here you specify that you are working with the “Local Area Connection” interface, setting a static IP address of 192.168.1.50 with a network mask of 255.255.255.0. The default gateway is 192.168.1.1 and the gateway metric is 1.

Tip

You can confirm the settings you just made by typing netsh interface ip show address at the command prompt or, if you are in the Netsh Interface IP context, by typing show address.

Setting a Dynamic IP Address

You can assign a dynamic IP address to any of the network adapters on a computer, provided there is a DHCP server available on the network. Afterward, you rely on the DHCP server to supply the necessary IP addressing information. Because the dynamic IP address can change, you shouldn’t use a dynamic IP address for servers running Windows Server 2003.

You assign a dynamic IP address using the Netsh Interface IP context. The command is SET ADDRESS and its syntax is

set address name=InterfaceName source=dhcp 
Note

If the computer already had an IP address configuration, using SET ADDRESS replaces the existing values. To add to the existing settings instead of replacing them, use the ADD ADDRESS command.

Consider the following example:

set address name="Local Area Connection" source=dhcp

Here you are working in the Netsh Interface IP context and specify that you want to set a dynamic IP address for the “Local Area Connection” interface.

Adding IP Addresses and Gateways

Both Windows XP Professional and Windows Server 2003 systems can have multiple IP addresses, even if the computer only has a single network adapter. Multiple IP addresses are useful if you want a single computer to appear as several computers or your network is divided into subnets and the computer needs access to these subnets to route information or provide other internetworking services.

Note

Keep in mind that when you use a single network adapter, IP addresses must be assigned to the same network segment or segments that are part of a single logical network. If your network consists of multiple physical networks, you must use multiple network adapters, with each network adapter being assigned an IP address in a different physical network segment.

You assign multiple IP addresses and gateways to a single network adapter using the ADD ADDRESS command of the Netsh Interface IP context. The syntax for this command is similar to that of SET ADDRESS. It is

add address [name=]InterfaceName addr=IPAddress mask=SubnetMask 
[[gateway=]DefaultGateway [gwmetric=]GatewayMetric]

Consider the following example:

add address name="Local Area Connection" addr=192.168.2.12 
mask=255.255.255.0 gateway=192.168.2.1 gwmetric=1

Note

If you specify a gateway, you must also specify the gateway metric. As before, you can confirm the settings you just made by typing show address.

Here you specify that you are working with the “Local Area Connection” interface and adding the IP address of 192.168.2.12 with a network mask of 255.255.255.0. The default gateway for this IP address is 192.168.2.1 and the gateway metric is 1.

Setting DNS Servers to Use

Computers use DNS to determine a computer’s IP address from its host name or its host name from an IP address. For computers using static IP addresses, you must tell them which DNS servers to use; you can do this using the Netsh Interface IP context. The syntax for setting a specific DNS server to use is

set dns name=InterfaceName source=static addr=DNSAddress 

Consider the following example:

set dns name="Local Area Connection" source=static addr=192.168.1.56

Here you specify that you are working with the “Local Area Connection” interface and specifying the DNS server address as 192.168.1.56.

If a computer is using DHCP and you want DHCP to provide the DNS server address, you can provide the DNS server address as well or specify that the IP address should be obtained from DHCP. You tell the computer to get the DNS server settings from DHCP by typing

set dns name=InterfaceName source=dhcp

Consider the following example:

set dns name="Local Area Connection" source=dhcp

Here you specify that the “Local Area Connection” interface should get its DNS server address settings from DHCP.

Note

If the computer already had DNS server IP addresses set, using SET DNS replaces the existing values. To add DNS server IP addresses instead of replacing them, use the ADD DNS command. You can confirm the DNS server settings by typing show dns.

Other optional parameters:

  • ddns= enabled | disabled By default, all IP addresses for interfaces are registered in DNS under the computer’s fully qualified domain name. This automatic registration uses the DNS dynamic update protocol. If you want to disable this behavior, add the value by including ddns=disabled.

  • suffix= interface | primary By default, the computer’s full name is registered only in its primary domain. When using dynamic DNS, you can also specify that the connection-specific DNS name should be registered with DNS. Type the parameter suffix=interface. This allows for occasions when the computer has multiple network adapters that connect to multiple domains.

Specifying Additional DNS Servers to Use

Most networks have multiple DNS servers that are used for resolving domain names. This allows for name resolution if one DNS server isn’t available. When you use DHCP to specify the DNS servers, it can automatically tell computers about other DNS servers that may be available. This isn’t the case when you manually specify DNS servers to be used.

To tell a computer about other DNS servers that may be available in addition to the primary DNS server specified previously, you can use the Netsh Interface IP context and the ADD DNS command. The syntax is

add dns name=InterfaceName addr=DNSAddress 

Consider the following example:

add dns name="Local Area Connection" addr=192.168.1.75

Here you specify that you are working with the “Local Area Connection” interface and designating an alternate DNS server with an IP address of 192.168.1.75.

By default, a DNS server is added to the end of the DNS server’s list in the TCP/ IP configuration. If you want the DNS server to be in a specific position in the list use the Index= parameter. For example, if you wanted an additional server to be listed first (making it the primary) you’d set an index of 1, such as:

add dns name="Local Area Connection" addr=192.168.1.75 index=1

Setting WINS Servers to Use

WINS is used to resolve NetBIOS computer names to IP addresses. You can use WINS to help computers on a network determine the address of pre–Windows 2000 computers on the network. Although WINS is supported in all versions of Windows, Windows Server 2003 primarily uses WINS for backward compatibility.

For computers using static IP addresses you must specify which WINS servers are to be used. Within the Netsh Interface IP context, the syntax for specifying the use of a specific WINS server is

set wins name=InterfaceName source=static addr=WINSAddress 

Consider the following example:

set wins name="Local Area Connection" source=static addr=192.168.1.64

Here you specify that you are working with the “Local Area Connection” interface and specifying the WINS server address as 192.168.1.64.

If a computer is using DHCP and you want DHCP to provide the WINS server address, you can provide the WINS server address as well or specify that the IP address should be obtained from DHCP. You tell the computer to get the WINS server settings from DHCP by typing

set wins name=InterfaceName source=dhcp

Consider the following example:

set wins name="Local Area Connection" source=dhcp

Here you specify that the “Local Area Connection” interface should get its WINS server address settings from DHCP.

Note

If the WINS server IP addresses were already set, using SET WINS replaces the existing values. To add WINS server IP addresses instead of replacing them, use the ADD WINS command. You can confirm the WINS server settings by typing show wins.

Specifying Additional WINS Servers to Use

Most networks have a primary and a backup WINS server. This allows for name resolution if one WINS server isn’t available. If you use DHCP to specify the WINS servers, DHCP can automatically tell computers about other WINS servers that may be available. This isn’t the case when you manually specify which WINS servers to use.

To tell a computer about other WINS servers that may be available in addition to the primary WINS server specified previously, you can use the Netsh Interface IP context and the ADD WINS command. The syntax is

add wins name=InterfaceName addr=WINSAddress 

Consider the following example:

add wins name="Local Area Connection" addr=192.168.1.155

Here you specify that you are working with the “Local Area Connection” interface and designating an alternate WINS server with an IP address of 192.168.1.155.

By default, a WINS server is added to the end of the WINS server’s list in the TCP/IP configuration. If you want a WINS server to be in a specific position in the list use the Index= parameter. For example, if you wanted an additional server to be listed first (making it the primary) you’d set an index of 1, such as

add wins name="Local Area Connection" addr=192.168.1.155 index=1

Deleting Address Resolution Protocol Cache

When computers look up domain name information, the related information is stored in the Address Resolution Protocol (ARP) cache so that the next time the information is needed no name lookup is necessary. The address resolution information expires according to a time-to-live (TTL) value set when the information was received, after which time it must again be looked up to get current information and a new TTL. In general, this automated system of obtaining, clearing out, and renewing name information works well. Sometimes, however, old name-resolution information on a system will cause problems before the information is purged. For example, if a computer changes its name information and the TTL hasn’t expired on a previous lookup, temporarily you won’t be able to find the computer.

DNS administrators have several tricks they can use to reduce the impact of name changes, such as setting an increasingly shorter TTL just prior to a name change to ensure that old information is deleted more quickly and doesn’t cause a problem. However, you may find that it’s easier just to get rid of the old information and force a computer to make new DNS lookups. You can do this by typing netsh interface ip delete arpcache at the command prompt or, if you are in the Netsh Interface IP context, by typing delete arpcache. This deletes name information for all interfaces configured on the computer you are working with. When there are multiple interfaces and you only want name-resolution information purged for one interface, you can name the interface to work with by including name=InterfaceName, such as

delete arpcache name="Local Area Connection"

Deleting TCP/IP Settings

Using the Netsh Interface IP context, you can delete TCP/IP configuration settings as well. Table 15-1 summarizes the available commands according to the task to be performed.

Table 15-1: Netsh Interface IP Commands for Deleting TCP/IP Settings

Task

Syntax

Example

Delete a designated IP address from the named interface.

delete address
name=InterfaceName
addr=IPAddress

delete address name=“Local Area Network”
address=192.168.1.56

Delete a static gateway IP address from the named interface.

delete address
name=InterfaceName
gateway=GatewayAddress

delete address name=“Local Area Network”
gateway=192.168.1.1

Delete all static gateway IP addresses from the named interface.

delete address
name=InterfaceName
gateway=all

delete address name=“Local Area Network”
gateway=all

Delete a DNS server from the named interface.

delete dns
name=InterfaceName
addr=IPAddress

delete dns name=“Local Area Network” address=192.168.1.56

Delete all DNS servers from the named interface.

delete dns
name=InterfaceName
addr=all

delete dns name=“Local Area Network” address=all

Delete a WINS server from the named interface.

delete wins
name=InterfaceName
addr=IPAddress

delete wins name=“Local Area Network”
address=192.168.1.56

Delete all WINS servers from the named interface.

delete wins
name=InterfaceName
addr=all

delete wins name=“Local Area Network”
address=all



 < Day Day Up > 



Microsoft Windows Command-Line Administrator's Pocket Consultant
MicrosoftВ® WindowsВ® Command-Line Administrators Pocket Consultant
ISBN: 0735620385
EAN: 2147483647
Year: 2004
Pages: 114

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net