Please Support by checking out some of the sponsors to the right

Thursday, March 5, 2009

Description of netstat command

Netstat

Netstat displays protocol statistics and current TCP/IP connections. From a command prompt, type Netstat -a to display all connections and listening ports. Type netstat -r to display the contents of the IP routing table and any persistent routes. The -n switch tells Netstat not to convert addresses and port numbers to names, which speeds up execution. The netstat -s option shows all protocol statistics. The netstat-p < protocol > option can be used to show statistics for a specific protocol or together with the -s option to show connections only for the protocol specified. The -e switch displays interface statistics. Sample output for the netstat -e command is shown here:

C:\>netstat -e

Interface Statistics

Received Sent

Bytes 372959625 123567086

Unicast packets 134302 145204

Non-unicast packets 55937 886

Discards 0 0

Errors 0 0

Unknown protocols 1757381

Discards are the packets received that contained errors or could not be processed. Errors indicate packets that are damaged, including packets sent by the local computer that were damaged while in the buffer.

Both of these types of errors should be at or near zero. If not, errors in the Sent column indicate that the local network might be overloaded or that there might be a bad physical connection between the local host and the network. High errors and discards in the Receive column indicate an overloaded local net, an overloaded local host, or a physical problem with the network.

The following output shows a sample report for the netstat -a -n command.

C:\>netstat -a -n

Active Connections

Proto Local Address Foreign Address State

TCP 0.0.0.0:42 0.0.0.0:0 LISTENING

TCP 0.0.0.0:88 0.0.0.0:0 LISTENING

TCP 0.0.0.0:135 0.0.0.0:0 LISTENING

TCP 0.0.0.0:389 0.0.0.0:0 LISTENING

TCP 0.0.0.0:445 0.0.0.0:0 LISTENING

TCP 0.0.0.0:593 0.0.0.0:0 LISTENING

TCP 0.0.0.0:1038 0.0.0.0:0 LISTENING

TCP 0.0.0.0:1041 0.0.0.0:0 LISTENING

TCP 0.0.0.0:1048 0.0.0.0:0 LISTENING

TCP 0.0.0.0:1723 0.0.0.0:0 LISTENING

TCP 0.0.0.0:3268 0.0.0.0:0 LISTENING

TCP 10.99.99.1:53 0.0.0.0:0 LISTENING

TCP 10.99.99.1:139 0.0.0.0:0 LISTENING

TCP 10.99.99.1:389 10.99.99.1:1092 ESTABLISHED

TCP 10.99.99.1:1092 10.99.99.1:389 ESTABLISHED

TCP 10.99.99.1:3604 10.99.99.1:135 TIME_WAIT

TCP 10.99.99.1:3605 10.99.99.1:1077 TIME_WAIT

UDP 0.0.0.0:135 *:*

UDP 0.0.0.0:445 *:*

UDP 0.0.0.0:1087 *:*

UDP 10.99.99.1:53 *:*

UDP 10.99.99.1:137 *:*

UDP 10.99.99.1:138 *:*

The number after the colon indicates which port number each connection is using. For a complete port reference list, see the appendix "TCP and UDP Port Assignments" in this book.

The following output shows the TCP, IP, ICMP, and UDP statistics for the local host.

D:\>netstat -s

IP Statistics

Packets Received = 3175996

Received Header Errors = 0

Received Address Errors = 38054

Datagrams Forwarded = 0

Unknown Protocols Received = 0

Received Packets Discarded = 0

Received Packets Delivered = 3142564

Output Requests = 3523906

Routing Discards = 0

Discarded Output Packets = 0

Output Packet No Route = 0

Reassembly Required = 0

Reassembly Successful = 0

Reassembly Failures = 0

Datagrams Successfully Fragmented = 0

Datagrams Failing Fragmentation = 0

Fragments Created = 0

ICMP Statistics

Received Sent

Messages 462 33

Errors 0 0

Destination Unreachable 392 4

Time Exceeded 0 0

Parameter Problems 0 0

Source Quenchs 0 0

Redirects 0 0

Echos 1 22

Echo Replies 12 1

Timestamps 0 0

Timestamp Replies 0 0

Address Masks 0 0

Address Mask Replies 0 0

TCP Statistics

Active Opens = 12164

Passive Opens = 12

Failed Connection Attempts = 79

Reset Connections = 11923

Current Connections = 1

Segments Received = 2970519

Segments Sent = 3505992

Segments Retransmitted = 18

UDP Statistics

Datagrams Received = 155620

No Ports = 16578

Receive Errors = 0

Datagrams Sent = 17822

Table 3.7 summarizes the switches available for use with Netstat.

Table 3.7 Netstat Switches

Switch Function

-a

Displays all connections and listening ports.

-r

Displays the contents of the routing table.

-n

Speeds execution by telling Netstat not to convert addresses and port numbers to names.

-s

Shows per-protocol statistics for IP, ICMP, TCP, and UDP.

-p < protocol >

Shows connection information for the specified protocol. The protocol can be TCP, UDP, or IP. When used with the -s option, shows statistics for the specified protocol. In this case, the protocol can be TCP, UDP, IP, or ICMP.

-e

Shows Ethernet statistics, and can be combined with -s.

Interval

Shows a new set of statistics each interval (in seconds). You can stop the redisplaying of Netstat statistics by typing CTRL-C. Without specifying an interval, Netstat shows the statistics once.



Source
Microsoft Technet Netstat

Description of Netdiag command

Netdiag

Netdiag is a utility that helps isolate networking and connectivity problems by performing a series of tests to determine the state of your network client and whether it is functional. These tests and the key network status information they expose give network administrators and support personnel a more direct means of identifying and isolating network problems. Moreover, because this tool does not require parameters or switches to be specified, support personnel and network administrators can focus on analyzing the output, rather than training users about tool usage.

Netdiag diagnoses network problems by checking all aspects of a host computer's network configuration and connections. Beyond troubleshooting TCP/IP issues, it also examines a host computer's Internetwork Packet Exchange (IPX) and NetWare configurations.

Run Netdiag whenever a computer is having network problems. The utility tries to diagnose the problem and can even flag problem areas for closer inspection. It can fix simple DNS problems with the optional /fix switch.

For more information about Netdiag, see Windows 2000 Support Tools Help. For information about installing and using the Windows 2000 Support Tools and Support Tools Help, see the file Sreadme.doc in the \Support\Tools folder of the Windows 2000 operating system CD.

Netdiag performs its tests by examining .dll files, output from other tools, and the system registry to find potential problem spots. It checks to see which network services or functions are enabled and then runs the network configuration tests listed in Table 3.5, in the order presented. If a computer is not running one of the services listed, the test is skipped.

Table 3.5 Netdiag Tests

Test Name Function Details

NDIS

Network Adapter Status

Lists the network adapter configuration details, including the adapter name, configuration, media, globally unique identifier (GUID), and statistics. If this test shows an unresponsive network adapter, the remaining tests are aborted.

IPConfig

IP Configuration

This test provides most of the TCP/IP information normally obtained from ipconfig /all , pings the DHCP and WINS servers, and checks that the default gateway is on the same subnet as the IP address.

Member

Domain Membership

Checks to confirm details of the primary domain, including computer role, domain name, and domain GUID. Checks to see if NetLogon service is started, adds the primary domain to the domain list, and queries the primary domain security identifier (SID).

NetBTTransports

Transports Test

Lists NetBT transports managed by the redirector. Prints error information if no NetBT transports are found.

Automatic Private IP Addressing (APIPA)

APIPA Address

Checks if any interface is using Automatic Private IP Addressing (APIPA).

IPLoopBk

IP Loopback Ping

Pings the IP loopback address of 127.0.0.1.

DefGw

Default Gateway

Pings all the default gateways for each interface.

NbtNm

NetBT Name Test

Similar to the nbtstat -n command. It checks that the workstation service name <00> is equal to the computer name. It also checks that the messenger service name <03>, and server service name <20> are present on all interfaces and that none of these names are in conflict.

WINS

WINS Service Test

Sends NetBT name queries to all the configured WINS servers.

Winsock

Winsock Test

Uses Windows Sockets WSAEnumProtocols () function to retrieve available transport protocols.

DNS

DNS Test

Checks whether DNS cache service is running, and whether this computer is correctly registered on the configured DNS servers. If the computer is a domain controller, DNS Test checks to see whether all the DNS entries in Netlogon.dns are registered on the DNS server. If the entries are incorrect and the /fix option is on, try to re-register the domain controller record on a DNS server.

Browser

Redirector and Browser Test

Checks whether the workstation service is running. Retrieves the transport lists from the redirector and from the browser. Checks whether the NetBT transports are in the list of NetBT transports test. Checks whether the browser is bound to all the NetBT transports. Checks whether the computer can send mailslot messages. Tests both via browser and redirector.

DsGetDc

DC Discovery Test

First finds a generic domain controller from directory service, then finds the primary domain controller. Then, finds a Windows 2000 domain controller (DC). If the tested domain is the primary domain, checks whether the domain GUID stored in Local Security Authority (LSA) is the same as the domain GUID stored in the DC. If not, the test returns a fatal error; if the /fix option is on, DsGetDC tries to fix the GUID in LSA.

DcList

DC List Test

Gets a list of domain controllers in the domain from the directory services on an active domain controller (DC). If there is no DC info for this domain, tries to get a DC from DS (similar to the DsGetDc test). Tries to get an active DC as the target DC. Gets the DC list from the target DC. Checks the status of each DC. Adds all the DCs into the DC list of the tested domain.
If the above sequence fails, uses the browser to obtain the DCs. Checks the status of all DCs and adds them to the DC list.
If the DcAccountEnum registry entry option is enabled, Netdiag tries to get a DC list from the Security Accounts Manager (SAM) on the discovered DC.

Trust

Trust Relationship Test

Test trust relationships to the primary domain only if the computer is a member workstation, member server, or a Backup Domain Controller (BDC) domain controller that is not a PDC emulator Checks that the primary domain security identifier (SID) is correct. Contacts an active DC. Connects to the SAM server on the DC. Uses the domain SID to open the domain to verify whether the domain SID is correct Queries info of the secure channel for the primary domain. If the computer is a BDCDC, reconnects to the PDC emulator. If the computer is a member workstation or server, sets secure channel to each DC on the DC list for this domain.

Kerberos

Kerberos Test

Tests Kerberos protocols only if the computer is a member computer or DC and the user is not logged onto a local account. Tests Kerberos protocols only when the user is logged onto a Windows 2000 domain account. Connects to LSA and looks up the Kerberos package. Gets the ticket cache of the Kerberos package. Checks if Kerberos package has a ticket for the primary domain and the local computer.

LDAP

Lightweight Directory Access Protocol (LDAP) Test

This per-domain test is run only if the DC is running DS. The computer must be a member computer or DC. NetDiag tests LDAP on all the active DCs found in the domain. It creates an LDAP connection block to the DC, then does a trivial search in the LDAP directory with three types of authentication: "unauthenticated", NTLM, and "Negotiate." If the /v (verbose) option is on, the LDAP test prints out the details of each entry retrieved.

Route

Route test

Displays the static and persistent entries in the routing table, including a destination address, subnet mask, gateway address, interface, and metric.

NetStat

NetStat test

Similar to Netstat tool. Displays statistics of protocols and current TCP/IP network connections.

Bindings

Bindings test

Lists all bindings, including interface name, lower module name, upper module name, whether the binding is currently enabled, and the owner of the binding.

WAN

WAN test

Displays the settings and status of current active remote access connections.

Modem

Modem test

Retrieves all the line devices that are available. Displays the configuration of each line device.

NetWare

NetWare test

Determines whether NetWare is using the directory tree or bindery logon process, determines the default context if Netware is using the directory tree logon process, and finds the server to which the host attaches itself at startup.

IPX

IPX test

Examines the network's IPX configuration, including Frame Type, Network ID, RouterMTU and whether packet burst or source routing are enabled.

IPSec

IP Security test

Tests whether IP security is enabled and displays a list of active IPSec policies.

Netdiag Syntax

The required syntax for Netdiag is simple. The tool can be configured to perform any subset of its exhaustive list of tests by careful use of the /test or /skip options.

Although no parameters or syntax need be specified, several options are available for Netdiag, primarily to increase or decrease the level of detail in its reports. These switches are shown in the Table 3.6. Complete details on the /test and /skip options can be found by typing netdiag /? at a command prompt; this returns a complete list of more than 20 tests that can be singled out or skipped.

Table 3.6 Netdiag Switches

Switch Name Function

/q

Quiet output

Lists only tests that return errors.

/v

Verbose output

More extensive listing of test data as tests are performed.

/l

Log output

Stores output in NetDiag.log, in the default directory.

/debug

Most verbose output

Complete list of test data with reasons for success or failure.

/d:< DomainName >

Find DC

Finds a domain controller in the specified domain.

/fix

Fix DNS problems

Compares DNS value to host file.

/DcAccountEnum

Enumerate DC

Enumerates Domain Controller computer accounts.

/test:

Single test

Runs only the test specified by < test name >. For a complete list, type netdiag /? .

/skip:< test name >

Skip test

Skips the named test.

In general, Netdiag calls Ipconfig and returns a structure that contains most of the general information that ipconfig /all prints. It takes that information from the registry and by calling the various drivers.

Netdiag prints the string [FATAL] when it detects a condition that needs to be fixed immediately. By contrast, the string [WARNING] signals a failure condition that can be put off for a while.


Source

Microsoft Technet Netdiag


Nbtstat

Nbtstat is designed to help troubleshoot NetBIOS name resolution problems. When a network is functioning normally, NetBIOS over TCP/IP (NetBT) resolves NetBIOS names to IP addresses. It does this through several options for NetBIOS name resolution, including local cache lookup, WINS server query, broadcast, LMHOSTS lookup, Hosts lookup, and DNS server query.

The nbtstat command removes and corrects preloaded entries using a number of case-sensitive switches. The nbtstat - a <name> command performs a NetBIOS adapter status command on the computer name specified by < name> . The adapter status command returns the local NetBIOS name table for that computer as well as the MAC address of the adapter card. The nbtstat -A < IP address > command performs the same function using a target IP address rather than a name.

The nbtstat - c option shows the contents of the NetBIOS name cache, which contains NetBIOS name-to-IP address mappings.

nbtstat -n displays the names that have been registered locally on the system by NetBIOS applications such as the server and redirector.

The nbtstat -r command displays the count of all NetBIOS names resolved by broadcast and by querying a WINS server. The nbtstat -R command purges the name cache and reloads all #PRE entries from the LMHOSTS file. #PRE entries are the LMHOSTS name entries that are preloaded into the cache. For more information about the LMHOSTS file, see the appendix "LMHOSTS Files" in this book.

Nbtstat -RR sends name release packets to the WINS server and starts a refresh, thus re-registering all names with the name server without having to reboot. This is a new option in Windows NT 4.0 with Service Pack 4 as well as in Windows 2000.

You can use nbtstat -S to list the current NetBIOS sessions and their status, including statistics. Sample output looks like this:

C:\>nbtstat -S

Local Area Connection:

Node IpAddress: [172.16.0.142] Scope Id: []

NetBIOS Connection Table

Local Name State In/Out Remote Host Input Output

------------------------------------------------------------------

TESTPC1 <00> Connected Out 172.16.210.25 6MB 5MB

TESTPC1 <00> Connected Out 172.16.3.1 108KB 116KB

TESTPC1 <00> Connected Out 172.16.3.20 299KB 19KB

TESTPC1 <00> Connected Out 172.16.3.4 324KB 19KB

TESTPC1 <03> Listening

Finally, nbtstat -s provides a similar set of session listings, but provides the remote computer names, rather than their IP addresses.

note-icon

Note

The options for the Nbtstat command are case sensitive.

The Nbtstat switches are listed in Table 3.4.

Table 3.4 Nbtstat Switches

Switch Name Function

-a < name >

adapter status

Returns the NetBIOS name table and MAC address of the address card for the computer name specified.

-A < IP address >

Adapter status

Lists the same information as -a when given the target's IP address.

-c

cache

Lists the contents of the NetBIOS name cache.

[ Number ]

Interval

Typing a numerical value tells Nbtstat to redisplay selected statistics each interval seconds, pausing between each display. Press Ctrl+C to stop redisplaying statistics.

-n

names

Displays the names registered locally by NetBIOS applications such as the server and redirector.

-r

resolved

Displays a count of all names resolved by broadcast or WINS server.

-R

Reload

Purges the name cache and reloads all #PRE entries from LMHOSTS.

-RR

ReleaseRefresh

Releases and reregisters all names with the name server.

-s

sessions

Lists the NetBIOS sessions table converting destination IP addresses to computer NetBIOS names.

-S

Sessions

Lists the current NetBIOS sessions and their status, with the IP address.

/?

Help

Displays this list.



Source

Microsoft Nbstat

Description of Arp command

Arp

Arp allows you to view and modify the ARP cache. If two hosts on the same subnet cannot ping each other successfully, try running the arp -a command on each computer to see whether the computers have the correct media access control (MAC) addresses listed for each other. You can use Ipconfig to determine a host's correct MAC address.

You can also use Arp to view the contents of the ARP cache by typing arp -a at a command prompt. This displays a list of the ARP cache entries, including their MAC addresses. Following is an example list of ARP cache entries.

C:\>arp -a

Interface: 172.16.0.142 on Interface 0x2

Internet address Physical Address Type

172.16.0.1 00-e0-34-c0-a1-40 dynamic

172.16.1.231 00-00-f8-03-6d-65 dynamic

172.16.3.34 08-00-09-dc-82-4a dynamic

172.16.4.53 00-c0-4f-79-49-2b dynamic

172.16.5.102 00-00-f8-03-6c-30 dynamic

If another host with a duplicate IP address exists on the network, the ARP cache might have the MAC address for the other computer placed in it, and this can lead to intermittent problems with address resolution. When a computer on the local network sends an ARP Request to resolve the address, it forwards its data to the MAC address corresponding to the first ARP Reply it receives. Arp can help by listing, adding, and removing the relevant entries.

You can use arp -d < IP address > to delete incorrect entries. Use arp -s <MAC address> (where the MAC address is formatted as hexadecimal bytes separated by dashes) to add new static entries; these static entries do not expire from the ARP cache. However, static entries do not persist after a reboot. For persistent static ARP cache entries, you must create a batch file run from the Startup group.

Use arp -N < IP address > to list all the ARP entries for the network interface specified by < IP address>. Table 3.2 lists all Arp switches.

Table 3.2 Arp Switches

Switch Name Effect

-d < IP address >

Delete

Removes the listed entry from the ARP cache

-s < MAC address >

Static

Adds a static entry to the ARP cache

-N < Interface IP address >

Interface

Lists all ARP entries for the interface specified

-a

Display

Displays all the current ARP entries for all interfaces

-g

Display

Displays all the current ARP entries for all interfaces



Source

Microsoft Arp command description

Description of iponfig switches

IPConfig is a command-line tool that displays the current configuration of the installed IP stack on a networked computer.

When used with the /all switch, it displays a detailed configuration report for all interfaces, including any configured WAN miniports (typically used for remote access or VPN connections). Output can be redirected to a file and pasted into other documents. A sample report is shown here:

C:>\ipconfig /all

Windows 2000 IP Configuration

Host Name . . . . . . . . . . . . : TESTPC1

Primary DNS Suffix . . . . . . . : reskit.com

Node Type . . . . . . . . . . . . : Hybrid

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

DNS Suffix Search List. . . . . . : ntcorpdc1.reskit.com

dns.reskit.com

reskit.com

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : dns.reskit.com

Description . . . . . . . . . . . : Acme XL 10/100Mb Ethernet NIC

Physical Address. . . . . . . . . : 00-CC-44-79-C3-AA

DHCP Enabled. . . . . . . . . . . : Yes

IP Address. . . . . . . . . . . . : 172.16.245.111

Subnet Mask . . . . . . . . . . . : 255.255.248.0

Default Gateway . . . . . . . . . : 172.16.240.1

DHCP Server . . . . . . . . . . . : 172.16.248.8

DNS Servers . . . . . . . . . . . : 172.16.55.85

172.16.55.134

172.16.55.54

Primary WINS Server . . . . . . . : 172.16.248.10

Secondary WINS Server . . . . . . : 172.16.248.9

Lease Obtained. . . . . . . . . . : Friday, May 05, 1999 2:21:40 PM

Lease Expires . . . . . . . . . . : Monday, May 07, 1999 2:21:40 PM

A number of other useful parameters for Ipconfig include /flushdns , which deletes the DNS name cache; /registerdns , which refreshes all DHCP leases and re-registers DNS names; and /displaydns which displays the contents of the DNS resolver cache.

The /release < adapter > and /renew < adapter > options release and renew the DHCP-allocated IP address for a specified adapter. If no adapter name is specified, the DHCP leases for all adapters bound to TCP/IP are released or renewed.

For /setclassid , if no class ID is specified, then the Class ID is removed. Table 3.3 lists all Ipconfig switches.

Table 3.3 Ipconfig Switches

Switch Effect

/all

Produces a detailed configuration report for all interfaces.

/flushdns

Removes all entries from the DNS name cache.

/registerdns

Refreshes all DHCP leases and reregisters DNS names

/displaydns

Displays the contents of the DNS resolver cache.

/release < adapter >

Releases the IP address for a specified interface.

/renew < adapter >

Renews the IP address for a specified interface.

/showclassid < adapter >

Displays all the DHCP class IDs allowed for the adapter specified.

/setclassid < adapter > < classID to set >

Changes the DHCP class ID for the adapter specified.

/?

Displays this list.



Source

Microsoft Description of ipconfig