Command Line Networking Tools (Windows)

Posted: August 13, 2011 in Notes
Tags:

I didn’t realize that Windows has such a bunch of networking tools until recently. These tools, available on the command line and free to use, can be used to configure, test, and troubleshoot a network. Although these tools are useful mostly to those technical people, (I might say) the average PC users may also find some useful command line tips here.

To run these tools, you need a Command Prompt. Go to Start-Run and enter “cmd” to open a Command Prompt.

  1. Windows IP Configuration Tool (ipconfig)
    The Windows IP Configuration Tool (ipconfig) is used to display TCP/IP network configuration values. If you are connected to a network, it will show your all your connections along with the IP address, subnet mask, and default gateway.

    C:\>ipconfig
    
    Windows IP Configuration
    
    Wireless LAN adapter Wireless Network Connection:
    
       Connection-specific DNS Suffix  . :
       Link-local IPv6 Address . . . . . : fe80::daf:1320:ac4b:4d71%11
       IPv4 Address. . . . . . . . . . . : 172.16.6.6
       Subnet Mask . . . . . . . . . . . : 255.255.0.0
       Default Gateway . . . . . . . . . : 172.16.0.1
    
    Ethernet adapter Local Area Connection:
    
       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :

    Besides, ipconfig might output more information or functions if you provide it with options. You may see a list of valid options by running ipconfig /?

    C:\>ipconfig /?
    
    USAGE:
        ipconfig [/allcompartments] [/? | /all |
                                     /renew [adapter] | /release [adapter] |
                                     /renew6 [adapter] | /release6 [adapter] |
                                     /flushdns | /displaydns | /registerdns |
                                     /showclassid adapter |
                                     /setclassid adapter [classid] |
                                     /showclassid6 adapter |
                                     /setclassid6 adapter [classid] ]
    
    where
        adapter             Connection name
                           (wildcard characters * and ? allowed, see examples)
    
        Options:
           /?               Display this help message
           /all             Display full configuration information.
           /release         Release the IPv4 address for the specified adapter.
           /release6        Release the IPv6 address for the specified adapter.
           /renew           Renew the IPv4 address for the specified adapter.
           /renew6          Renew the IPv6 address for the specified adapter.
           /flushdns        Purges the DNS Resolver cache.
           /registerdns     Refreshes all DHCP leases and re-registers DNS names
           /displaydns      Display the contents of the DNS Resolver Cache.
           /showclassid     Displays all the dhcp class IDs allowed for adapter.
           /setclassid      Modifies the dhcp class id.
           /showclassid6    Displays all the IPv6 DHCP class IDs allowed for adapter
    .
           /setclassid6     Modifies the IPv6 DHCP class id.
  2. Ping
    Technically, to ping a host is to send Internet Control Message Protocol (ICMP) Echo Request messages to the host  and wait for an Echo Reply message from the host. You may ping a target to check the connectivity to a remote site, for example, ping http://www.google.com. By default, four packets will be sent, or you could force unlimited packet using ping /t http://www.google.com. The server should reply within fractions of a second (depending on the speed of your connection), and the output should look like below.

    C:\>ping www.google.com
    
    Pinging www.l.google.com [209.85.175.104] with 32 bytes of data:
    Reply from 209.85.175.104: bytes=32 time=69ms TTL=231
    Reply from 209.85.175.104: bytes=32 time=70ms TTL=231
    Reply from 209.85.175.104: bytes=32 time=68ms TTL=231
    Reply from 209.85.175.104: bytes=32 time=69ms TTL=231
    
    Ping statistics for 209.85.175.104:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 68ms, Maximum = 70ms, Average = 69ms
  3. Tracert
    Tracert(traceroute) is used to determine the path taken from your PC to a destination. The path displayed is the list of near-side router interfaces of the routers in the path between a source host and a destination. The near-side interface is the interface of the router that is closest to the sending host in the path. For example, try enter tracert http://www.google.com.

    C:\>tracert www.google.com
    
    Tracing route to www.l.google.com [209.85.225.104]
    over a maximum of 30 hops:
    
       1    <1 ms    <1 ms    <1 ms  10.1.0.1
       2    35 ms    19 ms    29 ms  98.245.140.1
       3    11 ms    27 ms     9 ms  te-0-3.dnv.comcast.net [68.85.105.201]
       ...
      13    81 ms    76 ms    75 ms  209.85.241.37
      14    84 ms    91 ms    87 ms  209.85.248.102
      15    76 ms   112 ms    76 ms  iy-f104.1e100.net [209.85.225.104]
    
    Trace complete.
  4. Pathping
    Pathping combines the functionality of ping with that of tracert. Pathping will first output the details of the path between your computer and the destination; and subsequently it will display Ping-like statistics for each node in the path based on samples taken over a time period.
    The advantages of Pathping over ping and traceroute are that each node is pinged as the result of a single command, and that the behavior of nodes is studied over an extended time period, rather than the default ping sample of four messages or default traceroute single route trace.
  5. Netstat
    Netstat displays a list of active connections on your computer, including all inbound and outbound connections. Besides, it can also display Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6 and UDP over IPv6 protocols).
    Shown below is a list of options. The options must be prefixed with a hyphen (-) rather than a slash (/).

    C:\>netstat /?
    
    Displays protocol statistics and current TCP/IP network connections.
    
    NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-t] [interval]
    
      -a            Displays all connections and listening ports.
      -b            Displays the executable involved in creating each connection or
                    listening port. In some cases well-known executables host
                    multiple independent components, and in these cases the
                    sequence of components involved in creating the connection
                    or listening port is displayed. In this case the executable
                    name is in [] at the bottom, on top is the component it called,
                    and so forth until TCP/IP was reached. Note that this option
                    can be time-consuming and will fail unless you have sufficient
                    permissions.
      -e            Displays Ethernet statistics. This may be combined with the -s
                    option.
      -f            Displays Fully Qualified Domain Names (FQDN) for foreign
                    addresses.
      -n            Displays addresses and port numbers in numerical form.
      -o            Displays the owning process ID associated with each connection.
      -p proto      Shows connections for the protocol specified by proto; proto
                    may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s
                    option to display per-protocol statistics, proto may be any of:
                    IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
      -r            Displays the routing table.
      -s            Displays per-protocol statistics.  By default, statistics are
                    shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
                    the -p option may be used to specify a subset of the default.
      -t            Displays the current connection offload state.
      interval      Redisplays selected statistics, pausing interval seconds
                    between each display.  Press CTRL+C to stop redisplaying
                    statistics.  If omitted, netstat will print the current
                    configuration information once.
  6. Nslookup
    Known as Name Server Lookup in full, this tool is available to query the Domain Name System (DNS) to obtain the domain name or IP address of any specific DNS record. To run a query, type nslookup followed by the domain to query and the name server (optional). For example:

    C:\>nslookup www.google.com 161.139.250.2
    Server:  ns1.utm.my
    Address:  161.139.250.2
    
    Non-authoritative answer:
    Name:    www.l.google.com
    Addresses:  209.85.175.104
              209.85.175.105
              209.85.175.106
              209.85.175.147
              209.85.175.99
              209.85.175.103
    Aliases:  www.google.com
    
    C:\>nslookup 8.8.8.8 161.139.250.2
    Server:  ns1.utm.my
    Address:  161.139.250.2
    
    Name:    google-public-dns-a.google.com
    Address:  8.8.8.8
  7. Netsh
    Netsh is a powerful tool to perform the following task:

    • Configure interfaces.
    • Configure routing protocols.
    • Configure filters.
    • Configure routes.
    • Configure remote access behavior for Windows-based remote access routers that are running the Routing and Remote Access Server (RRAS) Service.
    • Display the configuration of a currently running router on any computer.
    • Use the scripting feature to run a collection of commands in batch mode against a specified router.

    The features available apply mostly to system administrators and are beyond the scope of this article. More information is available at Microsoft’s web site here.

Advertisements
Comments
  1. My family all the time say that I am wasting my time here at net, however I know I am getting experience
    all the time by reading such good posts.

  2. Hershel says:

    What’s Going down i am new to this, I stumbled upon this I’ve discovered It positively useful and it
    has helped me out loads. I am hoping to contribute & help other users like its helped me.
    Great job.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s