Network Command Line
Network Command Line
When you troubleshoot a TCP/IP networking problem, begin by checking the TCP/IP
configuration on the computer that is experiencing the problem. You can use the ipconfig
command to get host computer configuration information, including the IP address, subnet mask,
and default gateway.
Note
• For Windows 95 and Windows 98 clients, use the winipcfg command instead of
ipconfig.
When you use the ipconfig command with the /all option, a detailed configuration report is
produced for all interfaces, including any configured serial ports. With ipconfig /all, you can
redirect command output to a file and paste the output into other documents. You can also use
this output to confirm the TCP/IP configuration of each computer on the network or to further
investigate of TCP/IP network problems.
The following example shows the output of the ipconfig /all command on a computer that is
configured to use the DHCP server for automatic TCP/IP configuration, and WINS and DNS
servers for name resolution.
If no problems appear in the TCP/IP configuration, the next step is testing the ability to connect
to other host computers on the TCP/IP network.
Refreshing configuration by using ipconfig /renew
When you troubleshoot a TCP/IP networking problem, begin by checking the TCP/IP
configuration on the computer that is experiencing the problem. If the computer is DHCP-
enabled and is using a DHCP server to obtain configuration, you can initiate a refresh of the
lease by using the ipconfig /renew command.
When you use ipconfig /renew, all network adapters on the computer that uses DHCP (except
those that are manually configured) try to contact a DHCP server and renew their existing
configuration or obtain a new configuration.
You can also use the ipconfig command with the /release option to immediately release the
current DHCP configuration for a host.
Note
• For Windows 95 and Windows 98 DHCP-enabled clients, use the release and renew
options of the winipcfg command instead of ipconfig /release and ipconfig /renew to
perform manual release or renewal of the IP configuration lease for a client.
The ping command helps to verify IP-level connectivity. When troubleshooting, you can use
ping to send an ICMP echo request to a target host name or IP address. Use ping whenever you
need to verify that a host computer can connect to the TCP/IP network and network resources.
You can also use ping to isolate network hardware problems and incompatible configurations.
It is usually best to verify that a route exists between the local computer and a network host by
first using the ping command and the IP address of the network host to which you want to
connect. Try pinging the IP address of the target host to see if it responds, as follows:
ping IP_address
1. Ping the loopback address to verify that TCP/IP is installed and configured correctly on
the local computer.
ping 127.0.0.1
2. Ping the IP address of the local computer to verify that it was added to the network
correctly.
ping IP_address_of_local_host
3. Ping the IP address of the default gateway to verify that the default gateway is
functioning and that you can communicate with a local host on the local network.
ping IP_address_of_default_gateway
4. Ping the IP address of a remote host to verify that you can communicate through a router.
ping IP_address_of_remote_host
The ping command uses Windows Sockets–style name resolution to resolve a computer name to
an IP address, so if pinging by address succeeds, but pinging by name fails, then the problem lies
in address or name resolution, not network connectivity.
• The computer was restarted after TCP/IP was installed and configured.
• The IP address of the local computer is valid and appears correctly on the General tab of
the Internet Protocol (TCP/IP) Properties dialog box.
• IP routing is enabled and the link between routers is operational.
You can use different options with the ping command to specify the size of packets to use, how
many packets to send, whether to record the route used, what Time-to-Live (TTL) value to use,
and whether to set the "don't fragment" flag. You can type ping –? to see these options.
The following example illustrates how to send two pings, each 1,450 bytes in size, to IP address
192.168.0.1:
By default, ping waits 1,000 ms (1 second) for each response to be returned before displaying
the "Request Timed Out" message. If the remote system being pinged is across a high-delay link,
such as a satellite link, responses may take longer to be returned. You can use the –w (wait)
option to specify a longer time-out.
For example, if you recently used the ping command to test and verify connectivity from this computer to a host computer at IP
address 10.0.0.99, the ARP cache displays the following entry:
In this example, the cache entry indicates that the remote host computer at 10.0.0.99 resolved to a media access control address
of 00-e0-98-00-7c-dc assigned in the network adapter hardware of the remote computer. The media access control address is the
address that your computer used to physically communicate with this remote TCP/IP host on your network.
Notes
• To open a command prompt, click Start, point to All programs, point to Accessories, and
then click Command prompt.
• To minimize ARP broadcast traffic on your network, a cache of hardware-to-software
address mappings is maintained for future use. This cache contains the following two types
of entries:
These entries are added and deleted automatically during normal use of TCP/IP
sessions with remote computers. Dynamic entries age and expire from the cache if
not reused within 2 minutes. If a dynamic entry is reused within 2 minutes, it may
remain in the cache and age up to a maximum cache life of 10 minutes before being
removed or requiring cache renewal by using the ARP broadcast process.
• Static ARP cache entries
These entries are added manually by using the arp command with the -s option.
Static entries remain in the ARP cache until either the computer is restarted, or the
interface is reinitiated. Examples of some of the events that cause an interface to be
reinitiated are:
1. The interface is Disabled, and then Enabled.
5. You removed and replugged a network cable or moved a computer out of and back into wireless range.
6. ARP cache entries can be deleted manually by using the arp command with the -d option.
The Address Resolution Protocol (ARP) allows a host to find the media access control address of
a host on the same physical network, given the IP address of the host. To make ARP efficient,
each computer caches IP–to–media access control address mappings to eliminate repetitive ARP
broadcast requests.
You can use the arp command to view and modify the ARP table entries on the local computer.
The arp command is useful for viewing the ARP cache and resolving address resolution
problems.
NetBIOS over TCP/IP (NetBT) resolves NetBIOS names to IP addresses. TCP/IP provides many
options for NetBIOS name resolution, including local cache lookup, WINS server query,
broadcast, DNS server query, and Lmhosts and Hosts file lookup.
Nbtstat is a useful tool for troubleshooting NetBIOS name resolution problems. You can use the
nbtstat command to remove or correct preloaded entries:
• nbtstat –n displays the names that were registered locally on the system by programs
such as the server and redirector.
• nbtstat –c shows the NetBIOS name cache, which contains name-to-address mappings
for other computers.
• nbtstat –R purges the name cache and reloads it from the Lmhosts file.
• nbtstat –RR releases NetBIOS names registered with a WINS server and then renews
their registration.
• nbtstat –a name performs a NetBIOS adapter status command against the computer
specified by name. The adapter status command returns the local NetBIOS name table
for that computer plus the media access control address of the adapter.
• nbtstat –S lists the current NetBIOS sessions and their status, including statistics, as
shown in the following example:
• NetBIOS connection table
•
• Local name State In/out Remote Host Input Output
• ------------------------------------------------------------------
• CORP1 <00> Connected Out CORPSUP1<20> 6MB 5MB
• CORP1 <00> Connected Out CORPPRINT<20> 108KB 116KB
• CORP1 <00> Connected Out CORPSRC1<20> 299KB 19KB
• CORP1 <00> Connected Out CORPEMAIL1<20> 324KB 19KB
CORP1 <03> Listening
You can use the netstat command to display protocol statistics and current TCP/IP connections.
The netstat –a command displays all connections, and netstat –r displays the route table plus
active connections. The netstat –e command displays Ethernet statistics, and netstat –s displays
per-protocol statistics. If you use netstat –n, addresses and port numbers are not converted to
names. The following shows sample output for netstat:
C:\>netstat -e
Interface Statistics
Received Sent
Bytes 3995837940 47224622
Unicast packets 120099 131015
Non-unicast packets 7579544 3823
Discards 0 0
Errors 0 0
Unknown protocols 363054211
C:\>netstat -a
Active Connections
ICMP Statistics
Received Sent
Messages 693 4
Errors 0 0
Destination Unreachable 685 0
Time Exceeded 0 0
Parameter Problems 0 0
Source Quenches 0 0
Redirects 0 0
Echoes 4 0
Echo Replies 0 4
Timestamps 0 0
Timestamp Replies 0 0
Address Masks 0 0
Address Mask Replies 0 0
TCP Statistics
UDP Statistics
Tracert (Trace Route) is a route-tracing utility that is used to determine the path that an IP
datagram takes to reach a destination. The tracert command uses the IP Time-to-Live (TTL)
field and ICMP error messages to determine the route from one host to another through a
network.
The Tracert diagnostic utility determines the route taken to a destination by sending Internet
Control Message Protocol (ICMP) echo packets with varying IP Time-to-Live (TTL) values to
the destination. Each router along the path is required to decrement the TTL on a packet by at
least 1 before forwarding it. When the TTL on a packet reaches 0, the router should send an
"ICMP Time Exceeded" message back to the source computer.
Tracert determines the route by sending the first echo packet with a TTL of 1 and incrementing
the TTL by 1 on each subsequent transmission until the target responds or the maximum TTL is
reached. The route is determined by examining the "ICMP Time Exceeded" messages sent back
by intermediate routers. Some routers silently drop packets with expired TTLs and are invisible
to the Tracert utility.
The tracert command prints out an ordered list of the near-side interface of the routers in the
path that returned the "ICMP Time Exceeded" message. If the –d option is used, the Tracert
utility does not perform a DNS lookup on each IP address.
In the following example, the packet must travel through routers (192.168.0.2, 202.144.158.206,
202.144.159.195 and 202.144.129.2) to get to host 202.144.128.22. The default gateway of the
host is 192.168.0.2 and the IP address of the router on the 192.168.0.0 network is 192.168.0.2.
C:\>tracert 202.144.128.22
Tracing route to 202.144.128.22 over a maximum of 30 hops:
1 6 ms 2 ms 2 ms 192.168.0.2
2 4 ms 3 ms 4 ms 202.144.158.206
3 78 ms 78 ms 78 ms 202.144.159.195
4 78 ms 78 ms 78 ms 202.144.129.2
5 227 ms 163 ms 83 ms 202.144.128.220
Trace complete.
You can use the tracert command to determine where a packet stopped on the network. In the
following example, the default gateway has determined that there is not a valid path for the host
on 192.168.10.99. There is probably a router configuration problem or the 192.168.10.0 network
does not exist (a bad IP address).
C:\>tracert www.grape-info.com
Tracing route to www.grape-info.com [202.144.128.220]
over a maximum of 30 hops:
1 6 ms 2 ms 2 ms 192.168.0.2
2 4 ms 3 ms 4 ms gw.grape-info.com [202.144.158.206]
3 tpu-gw1.grape-info.com [202.144.159.195] reports: Destination net
unreachable.
Trace complete.
The Tracert utility is useful for troubleshooting large networks where several paths can be taken
to arrive at the same point.
The tracert command supports several options, as shown in the following table.
Option Description
–d Specifies that IP addresses are not resolved to host names.
–h Specifies the number of hops to allow in tracing a route to the host named in
maximum_hops target_name.
Specifies the list of router interfaces in the path taken by the Tracert utility
–j host-list
packets.
–w timeout Waits the number of milliseconds specified by timeout for each reply.
target_name Name or IP address of the target host.
The pathping command is a route tracing tool that combines features of the ping and tracert
commands with additional information that neither of those tools provides. The pathping
command sends packets to each router on the way to a final destination over a period of time,
and then computes results based on the packets returned from each hop. Since the command
shows the degree of packet loss at any given router or link, it is easy to determine which routers
or links might be causing network problems. A number of options are available, as shown in the
following table.
The default number of hops is 30, and the default wait time before a time-out is 3 seconds. The
default period is 250 milliseconds, and the default number of queries to each router along the
path is 100.
The following is a typical pathping report. The compiled statistics that follow the hop list
indicate packet loss at each individual router.
D:\>pathping www.grape-info.com
When pathping is run, you first see the results for the route as it is tested for problems. This is
the same path that is shown by the tracert command. The pathping command then displays a
busy message for the next 125 seconds (this time varies by the hop count). During this time,
pathping gathers information from all the routers previously listed and from the links between
them. At the end of this period, it displays the test results.
The two rightmost columns—This Node/Link Lost/Sent=Pct and Address—contain the most
useful information. The link between gw-dit.grape-info.com (hop 2), and tpu-gw1.grape-
info.com (hop 3) is dropping 13 percent of the packets. All other links are working normally.
The routers at hops 3 and 4 also drop packets addressed to them (as shown in the This
Node/Link column), but this loss does not affect their forwarding path.
The loss rates displayed for the links (marked as a | in the rightmost column) indicate losses of
packets being forwarded along the path. This loss indicates link congestion. The loss rates
displayed for routers (indicated by their IP addresses in the rightmost column) indicate that those
routers' CPUs might be overloaded. These congested routers might also be a factor in end-to-end
problems, especially if packets are forwarded by software routers.