TCP/IP Troubleshooting
Windows XP Professional and Windows Server 2003 offer several native programs that an administrator can use to troubleshoot TCP/IP issues. Some are full-fledged tools in their own right, such as FTP, but they can help in determining what might be affecting a TCP/IP network. Many of these TCP/IP troubleshooting tools are discussed in the sections that follow.
The PING Command
The PING command can be used to test network connectivity from a local system by sending an ICMP message to a remote host or gateway. On external networks such as the Internet, the use of PING might be somewhat limited, depending on how routers and firewalls are configured; many do not allow ICMP traffic. If the remote host receives the message, it responds with a reply message. PING notes the IP address, the number of bytes in the message, how long it took to reply (in milliseconds ], and the length of Time to Live (TTL) in seconds and shows any packet loss in terms of percentages, as shown here:
D:\>ping 192.168.1.225 Pinging 192.168.1.225 with 32 bytes of data: Reply from 192.168.1.225: bytes=32 time<10ms TTL=128 Reply from 192.168.1.225: bytes=32 time<10ms TTL=128 Reply from 192.168.1.225: bytes=32 time<10ms TTL=128 Reply from 192.168.1.225: bytes=32 time<10ms TTL=128 Ping statistics for 192.168.1.225: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milliseconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] target_name
The following list describes the switches available for use with PING:
-tPing the specified host until stopped. To see statistics and to continue, type Ctrl+Break; to stop, type Ctrl+C.
-aResolve addresses to hostnames.
-n countThe number of echo requests to send.
-l sizeSend buffer size.
-fSet the Don't Fragment flag in the packet.
-i TTLTime to Live.
-v TOSType of Service.
-r countRecord route for count hops.
-s countTimestamp for count hops.
-j host-listLoose source route along host list.
-k host-listStrict source route along host list.
-w timeoutTime in milliseconds to wait for each reply.
The ARP Command
The ARP command displays and modifies the IP-to-physical address translation tables used by Address Resolution Protocol (ARP), as shown here:
ARP -s inet_addr eth_addr [if_addr] ARP -d inet_addr [if_addr] ARP -a [inet_addr] [-N if_addr]
The following list describes the switches available for use with ARP:
-aDisplays current ARP entries by referencing the current protocol data. If inet_addr is specified, the IP and physical addresses for only the specified computer are displayed. If more than one network interface uses ARP, entries for each ARP table are displayed.
-gSame as -a.
inet_addrSpecifies an Internet address.
-N if_addrDisplays ARP entries for the network interface specified by if_addr.
-dDeletes the host specified by inet_addr. You can use * as a wildcard with inet_addr to delete all hosts.
-sAdds the host and associates the Internet address inet_addr with the physical (MAC) address.
eth_addrUses the physical (MAC) address and is given as six hexadecimal bytes separated by hyphens.
if_addrSpecifies the Internet address of the interface that should have its address translation table modified. If if_addr is not entered, the first applicable interface is used.
For example, the following code adds a static entry:
> arp -s 157.55.85.212 00-aa-00-62-c6-09 ....
The following displays the ARP table:
> arp -a
The IPCONFIG Command
IPCONFIG is a command-line tool for getting basic IP configuration information, including the IP address, subnet mask, and default gateway. The IPCONFIG /all switch produces a detailed configuration report for all interfaces on a system, including any configured remote access adapters, as shown here:
ipconfig [/? | /all | /renew [adapter] | /release [adapter] | /flushdns | /displaydns | /registerdns | /showclassid adapter | /setclassid adapter [classid] ]
The following list describes the switches available for use with IPCONFIG:
/allDisplay full configuration information.
/releaseReleases the IP address for the specified adapter.
/renewRenews the IP address for the specified adapter.
/flushdnsPurges the DNS Resolver cache.
/registerdnsReregisters DNS names.
/displaydnsDisplays the contents of the DNS Resolver Cache.
/showclassidDisplays all the DHCP class IDs allowed for adapter.
/setclassidModifies the DHCP class ID.
The default is to display only the IP address, subnet mask, and default gateway for each adapter bound to TCP/IP. For /release and /renew, if no adapter name is specified, the IP address leases for all adapters bound to TCP/IP are released or renewed.
The NBTSTAT Command
NetBT Statistics (Nbtstat.exe) is a command-line tool that can be used to view and troubleshoot network NetBIOS over TCP/IP (NetBT) name resolution. It displays protocol statistics and current TCP/IP connections that are using NetBT.
NetBT resolves NetBIOS names to IP addresses by using several options for NetBIOS name resolution, including local cache lookup, WINS server query, broadcast, LMHOSTS and HOSTS file lookup, and DNS server query. It also displays protocol statistics and current TCP/IP connections using NetBT.
NBTSTAT [ [-a RemoteName] [-A IP address] [-c] [-n] [-r] [-R] [-RR] [-s] [-S] [interval] ]
The following list describes the switches available for use with NBTSTAT:
-a (adapter status)Lists the remote machine's name table given its name.
-A (adapter status)Lists the remote machine's name table given its IP address.
-c (cache)Lists NBT's cache of remote (machine) names and their IP addresses.
-n (names)Lists local NetBIOS names.
-r (resolved)Lists names resolved by broadcast and via WINS.
-R (Reload)Purges and reloads the cache name table and reloads the #PRE tagged entries from the LMHOST file if any are present.
-S (Sessions)Lists the sessions table with the destination IP addresses.
-s (sessions)Lists the sessions table, converting destination IP addresses to computer NetBIOS names.
-RR (ReleaseRefresh)Sends Name Release packets to WINS and then starts Refresh.
RemoteNameRemote host machine name.
IP addressDotted decimal representation of the IP address.
intervalRedisplays selected statistics, pausing the number of seconds specified by interval between each display. Press Ctrl+C to stop redisplaying statistics.
The NETSTAT Command
NETSTAT (Netstat.exe) is a command-line tool that displays TCP/IP statistics and active connections to and from the local system. It can also display all connections and listening ports and has an option to display the number of bytes sent and received and any network packets dropped (if applicable).
NETSTAT [-a] [-e] [-n] [-o] [-s] [-p protocol] [-r] [interval]
The following list describes the switches available for use with NETSTAT:
-aDisplays all connections and listening ports.
-eDisplays ethernet statistics. Can be combined with the -s option.
-nDisplays addresses and port numbers in numerical form.
-oDisplays the owning process ID associated with each connection.
-p protocolShows connections for the protocol specified by protocol, which can be TCP, UDP, TCPv6, or UDPv6. If used with the s option to display per-protocol statistics, protocol can be any of the following: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
-rDisplays the routing table.
-sDisplays per-protocol statistics. By default, statistics are shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6; the -p option can be used to specify a subset of the default.
intervalRedisplays selected statistics, pausing the number of seconds specified by interval between each display. Press Ctrl+C to stop redisplaying statistics. If this switch is omitted, NETSTAT prints the current configuration information once.
The ROUTE Command
The ROUTE command-line tool displays the current IP routing table for the local system, and it can be used to add or delete IP routes and to add persistent routes.
ROUTE [-f] [-p] [command] [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]
The following list describes the switches available for use with ROUTE:
-fClears the routing tables of all gateway entries. If it is used with one of the ROUTE commands (see the following list), the routing tables are cleared before running the command.
-pWhen used with the ADD command, it makes a route persistent across boots of the system. By default, routes are not preserved when the system is restarted. Ignored for all other commands, which always affect the appropriate persistent routes.
The following list describes the commands available for use with ROUTE:
PRINTPrints a route.
ADDAdds a route.
DELETEDeletes a route.
CHANGEModifies an existing route.
destinationSpecifies the host.
MASKSpecifies that the next parameter is the netmask value.
netmaskSpecifies a subnet mask value for this route entry. If not specified, it defaults to 255.255.255.255.
gatewaySpecifies the gateway.
interfaceSpecifies the interface number for the specified route.
METRICSpecifies the metricthat is, the cost for the destination.
Names used for the destination command are looked up in the NETWORKS file on the local system. Names used for the gateway command are looked up in the HOSTS file on the local system. If the command is PRINT or DELETE, the destination or gateway can be a wildcard (*), or the gateway entry can be left blank. Invalid MASK entries, such as (DEST & MASK) != DEST, generate an error.
The HOSTNAME Command
HOSTNAME is a command-line tool for showing the local computer's hostname. It can be used for authentication purposes by the Remote Copy Protocol (RCP), Remote Shell (RSH), and Remote Execution (REXEC) tools.
The TRACERT Command
TRACERT is sometimes used to verify that IP addressing has been correctly configured on a client. It basically shows the route taken to reach a remote system.
tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
Here is a list of available switches for the TRACERT command:
-dDo not resolve addresses to hostnames.
-h maximum_hopsMaximum number of hops to search for target.
-j host-listLoose source route along host list.
-w timeoutWait the number of milliseconds specified by timeout for each reply.
The PATHPING Command
Like TRACERT, PATHPING shows the route taken to reach a remote system, but PATHPING does so with more detail and offers more functionality.
pathping [-g host-list] [-h maximum_hops] [-i address] [-n] [-p period] [-q num_queries] [-w timeout] [-P] [-R] [-T] [-4] [-6] target_name
Here is a list of available switches for the PATHPING command:
-g host-listLoose source route along the host list.
-h maximum_hopsMaximum number of hops to search for target.
-i addressUse the specified source address.
-nDo not resolve addresses to hostnames.
-p periodWait the number of milliseconds specified by period between pings.
-q num_queriesNumber of queries per hop.
-w timeoutWait the number of milliseconds specified by timeout for each reply.
-PTest for RSVP PATH connectivity.
-RTest if each hop is RSVP aware.
-TTest connectivity to each hop with layer-2 priority tags.
-4Force using IPv4.
-6Force using IPv6.
The FTP Command
FTP is used to transfer files from system to system over TCP ports 20 and 21 (by default), but it can also help you diagnose problems on your TCP/IP network. By using Internet Explorer with FTP, users experience a Windows Explorertype of GUI environment for the FTP file transfer by having features such as file and folder views, drag-and-drop, and copy-and-paste available.
The command-line FTP allows for more functionality. FTP is considered a connected session that uses TCP. FTP commands are as follows: !, delete, literal, prompt, send ?, debug, ls, put, status append, dir, mdelete, pwd, trace ascii, disconnect, mdir, quit, type, bell, get, mget, quote, user, binary, glob, mkdir, recv, verbose, bye, hash, mls, remotehelp, cd, help, mput, rename, close, lcd, open, and rmdir. Here is an example of the syntax:
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]
The following list explains the options you can use with the FTP command:
-vSuppresses display of remote server responses.
-nSuppresses auto-login at initial connection.
-iTurns off interactive prompting during multiple file transfers.
-dEnables debugging.
-gDisables filename globing.
-s:filenameSpecifies a text file containing FTP commands; the commands automatically run after FTP starts.
-aUse any local interface when binding a data connection.
-ALog in as anonymous.
-w:buffersizeOverrides the default transfer buffer size of 4,096.
hostSpecifies the hostname or IP address of the remote host to connect to.
The TFTP Command
Trivial File Transfer Protocol allows for connectionless transfer of files to and from systems using UDP. Although TFTP is limited in functionality, there are still some command-line switches that can be used to tailor its performance:
TFTP [-i] host [GET | PUT] source [destination]
Definitions for these switches are as follows:
-iSpecifies binary image transfer mode (also called octet). In binary image mode, the file is moved literally byte by byte.
hostSpecifies the local or remote host by name.
GETTransfers the file destination on the remote host to the file source on the local host.
PUTTransfers the file source on the local host to the file destination on the remote host.
sourceSpecifies the file to transfer.
destinationSpecifies where to transfer the file.
The TELNET Command
Telnet is a command-line terminal emulation program that enables an administrator to perform commands on a remote computer from a command window on a local system. Here is an example of the syntax:
telnet [-a] [-e char] [-f filename] [-l user] [-t term] [host] [port]
Definitions for TELNET switches are as follows:
-aAttempts automatic logon. Same as -l option, except it uses the currently logged on user's name.
-e charEscape character to enter Telnet client prompt.
-f filenameFilename for client-side logging.
-l userSpecifies the username to log in with on the remote system. Requires that the remote system support the TELNET ENVIRON option.
-t termSpecifies terminal type. Supported term types are vt100, vt52, ansi, and vtnt only.
hostSpecifies the hostname or IP address of the remote computer to connect to.
portSpecifies a port number or service name.
The RCP Command
Remote Copy Protocol (RCP) uses TCP to copy files to and from systems running the RCP service. It can be scripted in a batch file and does not require a password. The remote host must be running the Remote Shell Daemon (RSHD) service, and the user's username must be configured in the remote host's .rhosts file. Microsoft's implementation of TCP/IP includes the RCP client software but not RSHD services. RCP is one of the r- commands available on all Unix systems.
RCP [-a | -b] [-h] [-r] [host][.user:]source [host][.user:] path\destination
The following list explains the options you can use with the RCP command:
-aThis is the default transfer mode that specifies ASCII transfer mode. This mode converts the end-of-line (EOL) characters to a carriage return for Unix and a carriage return/line feed for personal computers.
-bSpecifies binary image transfer mode.
-hTransfers hidden files.
-rCopies the contents of all subdirectories; destination must be a directory.
hostSpecifies the local or remote host. If the host is specified as an IP address or if the hostname contains dots, you must specify the user.
.user:Specifies a username to use instead of the current username.
sourceSpecifies the files to copy.
path\destinationSpecifies the path to the logon directory on the remote host.
The RSH Command
Remote Shell (RSH) enables clients to run commands directly on remote hosts running the RSH service without having to log on to the remote host. Microsoft's implementation of TCP/IP includes the RSH client software but not the RSH service. If a user on a computer running in a Windows domain tries to use RSH to run a command on a remote Unix server running RSH, the domain controller is required by the RSH client to resolve the user's username. RSH is one of the Unix r-commands that is available on all Unix systems.
The REXEC Command
Remote Execution (REXEC) runs commands on remote hosts running the REXEC service and authenticates the username on the remote host before executing the specified command.
REXEC host [-l username] [-n] command
The following list defines options to use with the REXEC command:
hostSpecifies the remote host on which to run the command.
-l usernameSpecifies the username on the remote host.
-nRedirects the input of REXEC to NULL.
commandSpecifies the command to run.