Network Command - Guide
Network Command - Guide
1. Ipconfig
The Windows IP Configuration tool (ipconfig) is the command-line tool. It is used to
display the TCP/IP network configuration values. To open it, enter "ipconfig" in the
command prompt. If you are connected directly to the Internet, you will obtain your IP
address.
The figure below shows the result for a broadband connection where the IP is assigned
automatically. Here the IP is your computer's temporary address on the Internet.
If you are on a local area network using a router, the information is different. You do not
obtain the IP corresponding to the network's address on the Internet. The IP given is the
local address on the network. This information can be helpful in diagnosing network
problems. Also listed is the "gateway" or router address on the local network. The figure
below illustrates the result.
There are also a variety of switches for ipconfig that add functions. These are invoked by
entering "ipconfig /{switch}". To obtain a list of switches, enter "ipconfig /?" or "ipconfig
-?". These are shown in the figure below.
The switches of most interest to everyday use are "release" and "renew". Note that IP
addresses are typically assigned or "leased" for a period of time, often a day or more. It
sometimes happens that IP addresses are no longer valid or are in conflict. Problems can
often be solved by first releasing the IP address and then renewing it. Sometimes cable or
DSL modems that seem to be disabled can be restored this way. If you travel and use
broadband connections elsewhere, you will often find this procedure of releasing and
renewing the IP address to be necessary.
/all
/release
/renew
/flushdns
/registerdns
/displaydns
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid
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, then the IP address leases for all
adapters bound to TCP/IP will be released or renewed.
For SetClassID, if no class id is specified, then the classid is removed.
Examples
To get your computers local network IP address, subnet mask, and default gateway typing
ipconfig alone will display this information as shown below. Keep in mind this is only
your local network information.
ipconfig
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . : hsd1.ut.comcast.net.
IP Address. . . . . . . . . . . . : 192.168.201.245
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.201.1
To get all local network information for your computer use the /all switch as shown
below, followed by the results that would be seen when using this command.
ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . : COMPUTERH1
DNS Servers . . . . . . . . : 123.45.67.8
111.111.111.1
111.111.111.1
Node Type . . . . . . . . . : Broadcast
NetBIOS Scope ID. . . . . . :
IP Routing Enabled. . . . . : No
WINS Proxy Enabled. . . . . : No
NetBIOS Resolution Uses DNS : No
0 Ethernet adapter :
Description . . . . . . . . : PPP Adapter.
Physical Address. . . . . . : 44-44-44-54-00-00
DHCP Enabled. . . . . . . . : Yes
IP Address. . . . . . . . . : 123.45.67.802
Subnet Mask . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . : 123.45.67.801
DHCP Server . . . . . . . . : 255.255.255.255
Primary WINS Server . . . . :
Secondary WINS Server . . . :
Lease Obtained. . . . . . . : 01 01 80 12:00:00 AM
Lease Expires . . . . . . . : 01 01 80 12:00:00 AM
1 Ethernet adapter :
Description . . . . . . . . : 3Com 3C90x Ethernet Adapter
Physical Address. . . . . . : 00-50-04-62-F7-23
DHCP Enabled. . . . . . . . : Yes
IP Address. . . . . . . . . : 111.111.111.108
The screen tells me that the IP for dell.com is 143.166.83.230 (For the moment, at least.
This can change.) It also tells me that the average round trip time for a packet was 69
milliseconds, which means I have a good connection to dell.com. Long reply times of
several hundred milliseconds are indicative of a slow connection. Note that some major
sites such as microsoft.com do not like being pinged and block pings. In that case you
will get a "Request timed out" message.
Syntax
ping
[-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] destination-list
Options:
-t
-a
-n count
-l size
-f
-i TTL
Time To Live.
-v TOS
Type Of Service.
-r count
-s count
-j host-list
-k host-list
-w timeout
Examples
ping localhost
Pings the local host, this will allow you to see if the computer is able to send
information out and receive the information back. Note that this does not send
information over a network but may allow you to see if the card is being seen.
ping xxx.xxx.xxx.xxx
Allows you to ping another computer where the x's are located are where you would
place the IP address of the computer you are attempting to ping. If this is not able to
complete, this should relay back an unsuccessful message, which could be an
indication of cable issues, network card issues, hub issue, etc.
ping google.com
PING google.com (204.228.150.3) 56(84) bytes of data.
64 bytes from www.google.com (204.228.150.3): icmp_seq=1 ttl=63 time=0.267 ms
--- google.com ping statistics --1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.267/0.267/0.267/0.000 ms
3. Tracert
Tracert (traceroute) is another old tool borrowed from Unix. The actual path between two
computers on the Internet is not a straight line but consists of numerous segments or
"hops" from one intermediate computer to another. Tracert shows each step of the path
taken. It can be interesting to see just how convoluted it is. The times for each hop and
the IP addresses for each intermediate computer are displayed. Tracert shows up to 30
hops. It is convenient for finding if there is one particular segment that is causing a slow
or bad connection. A typical command might be "tracert dell.com".
The tracert command in MS-DOS / Windows is another commonly used network
command to help determine network related issues or slowdowns. Using this command
you can view a listing of how a network packet travels through the network and where it
may fail or slow down. Using this information you can determine the computer, router,
switch or other network device possibly causing your network issues.
Syntax
tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name
Options:
-d
-w timeout
Examples
Below is an example when we used tracert on www.google.com. As you can see in the
below example, we had a very short list and time to get to its destination because of the
location we are.
tracert google.com
1169 ms190 ms160 msslc1-tc.xmission.com [166.70.1.20]
2159 ms160 ms190 mscisco0-tc.xmission.com [166.70.1.1]
3165 ms189 ms159 mswww.google.com [166.70.10.23]
4. Pathping
This command combines functions of Ping and Tracert. Pathping will first list the
number of hops required to reach the address you are testing and then send multiple pings
to each router between you and the destination. After that, it computes results based on
the packets returned from each router. Because pathping displays the degree of packet
loss at any given router or link, you can determine which routers or subnets might be
having network problems. Note that the whole process may consume 5-10 minutes
because many pings are being sent. There are switches to modify the process and these
can be seen by entering "pathping /?" in the command prompt.
Usage: pathping [-g host-list] [-h maximum_hops] [-i address] [-n]
[-p period] [-q num_queries] [-w timeout] [-P] [-R] [-T]
[-4] [-6] target_name
Options:
-g host-list
-n
-p period
-q num_queries
-w timeout
-P
-R
-T
-4
-6
Examples
pathping google.com
Tracing route to google.com [204.228.150.3]
over a maximum of 30 hops:
0 Hope [192.168.120.101]
1 192.168.120.254
2 ...
Computing statistics for 50 seconds...
Source to Here This Node/Link
HopRTT Lost/Sent = Pct Lost/Sent = Pct Address
0 Hope [192.168.120.101]
0/100 = 0%
|
0
0ms0/ 100 = 0%
0/100 = 0%
192.168.120.254
100/100 = 100% |
1
--- 100/100 = 100%0/100 = 0%
Hope [0.0.0.0]
2
Trace complete.
5. Netstat
Netstat displays the active TCP connections and ports on which the computer is listening,
Ethernet statistics, the IP routing table, statistics for the IP, ICMP, TCP, and UDP
protocols. It comes with a number of switches for displaying a variety of properties of the
network and TCP connections. (One tricky point: the switches must be prefixed with a
minus, not a slash.) More detail is at this page. One possible use for Netstat is to
determine if spyware or Trojans have established connections that you do not know
about. The command "netstat -a" will display all your connections. The command "netstat
-b" will show the executable files involved in creating a connection. A figure showing all
the switches and syntax is given below.
Syntax
NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval]
-a
-e
-n
-p
proto Shows connections for the protocol specified by proto; proto may be TCP
or UDP. If used with the -s option to display per-protocol statistics, proto may be
TCP, UDP, or IP.
-r
-s
Displays per-protocol statistics. By default, statistics are shown for TCP, UDP
and IP; the -p option may be used to specify a subset of the default.
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.
Examples
netstat
Displays all local network information. Below is an example of what may be displayed.
Proto
TCP
TCP
TCP
netstat 5
Local Address
hope:4409
hope:3708
hope:4750
Foreign Address
www.google.com:telnet
multicity.com:80
www.google.com:80
State
ESTABLISHED
CLOSE_WAIT
CLOSE_WAIT
Running netstat with a number after the command will continue to run the command
until stopped. In this case netstat would be refreshed ever five seconds. To cancel
press CTRL + C.
Notice: Keep in mind that if you have network applications open, such as the browser
you're using to view this page, additional items will be listed when you run "netstat"
and/or the "netstat -a" command. So you may see items from Computer Hope in your list;
if you want a true listing of what is running in the background, close all programs and run
the command.
6. Nslookup
This command helps diagnose the Domain Name System (DNS) infrastructure and comes
with a number of sub-commands. These are mainly for systems administrators. The
primary interest for average PC users is its use to find the computer name corresponding
to a numeric IP. For example, if you want to know who is "216.109.112.135" , enter
"nslookup 216.109.112.135" and you will find that it is (or was anyway) a Yahoo
computer. My firewall keeps a log of the IPs involved in the attempts to probe my
computer and I sometimes look a few up to see who they are.
Syntax
Commands: (identifiers are shown in uppercase, [] means optional)
NAME
NAME1
NAME2
help or ?
set OPTION
set an option
all
print options, current server and host
[no]debug
print debugging information
[no]d2
print exhaustive debugging information
[no]defname
append domain name to each query
[no]recurse
ask for recursive answer to query
[no]search
use domain search list
[no]vc
always use a virtual circuit
domain=NAME
set default domain name to NAME
srchlist=N1[/N2/.../N6]set domain to N1 and search list to N1,N2, etc.
root=NAME
set root server to NAME
retry=X
set number of retries to X
timeout=X
set initial time-out interval to X seconds
type=X
querytype=X
class=X
[no]msxfr
ixfrver=X
server NAME
ls [opt]
DOMAIN [>
FILE]
view FILE
exit
-a
-d
Examples
This command is often used to perform a reverse lookup on an IP address as shown in the
below example. The first section specifies the server and address of that server that
provided you with the domain name and IP address displayed in the second section.
nslookup 204.228.150.3
Server: ns.google.com
Address: 1.1.1.1
Name: www.google.com
Address: 204.228.150.3
7. ROUTE
The route MS-DOS utility enables computers to view and modify the computer's route
table.
ROUTE [-f] [-p] [command [destination] [MASK netmask] [gateway] [METRIC metric]
[IF interface]
-f
Clears the routing tables of all gateway entries. If this is used in conjunction
with one of the commands, the tables are cleared prior to running the
command.
-p
When used with the ADD command, makes a route persistent across boots of
the system. By default, routes are not preserved when the system is restarted.
When used with the PRINT command, displays the list of registered
persistent routes. Ignored for all other commands, which always affect the
appropriate persistent routes. This option is not supported Windows'95.
command
command
One of these:
PRINT Prints a route
ADD Adds a route
DELETE Deletes a route
CHANGE Modifies an existing route destination
netmask
Specifies a subnet mask value for this route entry. If not specified, it defaults
to 255.255.255.255.
gateway
Specifies gateway.
interface
METRIC
All symbolic names used for destination are looked up in the network database file
NETWORKS. The symbolic names for gateway are looked up in the host name database
file HOSTS.
If the command is PRINT or DELETE. Destination or gateway can be a wildcard,
(wildcard is specified as a star '*'), or the gateway argument may be omitted.
If Dest contains a * or ?, it is treated as a shell pattern, and only matching destination
routes are printed. The '*' matches any string, and '?' matches any one char. Examples:
157.*.1, 157.*, 127.*, *224*.
Diagnostic Notes:
Invalid MASK generates an error, that is when (DEST & MASK) != DEST.
Example> route ADD 157.0.0.0 MASK 155.0.0.0 157.55.80.1 IF 1
The route addition failed: The specified mask parameter is invalid.
(Destination & Mask) != Destination.
Examples
Examples:
> route PRINT
MASK 255.0.0.0
^mask
>route ADD 157.0.0.0
^destination
157.55.80.1 METRIC 3
IF 2
^metric ^Interface
^gateway
8. NBTSTAT
The nbtstat MS-DOS utility that displays protocol statistics and current TCP/IP
connections using NBT.
Syntax
NBTSTAT [ [-a RemoteName] [-A IP address] [-c] [-n] [-r] [-R] [-RR] [-s] [-S]
[interval] ]
-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
-n
-r
-R
-S
-s
-RR
interval
Examples
nbtstat -a 204.224.150.3
Local Area Connection:
Node IpAddress: [204.224.150.3] Scope Id: []
NetBIOS Remote Machine Name Table
Name Type Status
--------------------------------------------HOPE4
<00> UNIQUE Registered
CHGROUP
<00> GROUP Registered
HOPE4
<20> UNIQUE Registered
HOPE4
<03> UNIQUE Registered
CHGROUP
<1E> GROUP Registered
CHGROUP
<1D> UNIQUE Registered
..__MSBROWSE__.
<01> GROUP Registered
ADMINISTRATOR
<03> UNIQUE Registered
MAC Address = 00-00-00-00-00-00
9. ARP
Display or manipulate the ARP information on a network device or computer.
Additional information about the MS-DOS arp command can be found here.
Syntax
ARP -s inet_addr eth_adr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr]
-a
-g
Same as -a
Displays the ARP entries for the network interface specified by if_addr.
-d
-s
Adds the host and associates the Internet address inet_addr with the Physical
address eth_addr. The Physical address is given as 6 hexadecimal bytes
seperated by hyphens. The entry is permanent.
eth_addr
if_addr
If present, this specifies the Internet address of the interface whose address
translation table should be modified. If not present, the first applicable
interface will be used.
Examples
arp -a
Interface 220.0.0.80
Internet Address
220.0.0.160
Physical Address
00-50-04-62-F7-23
Type
static
The Physical Address or MAC address as shown above in the format aa-bb-cc-dd-ee-ff is
the unique manufacturer identification number. This number should always be a unique
address.
An example of how to change the above IP address 220.0.0.160 to 220.0.0.161 in this
case would be:
arp -s 220.0.0.161 00-50-04-62-F7-23
If an IP address has already been assigned to the specific network adapter it is not
possible to change that assigned IP address to a new address. In addition, networks
italicizing DHCP, BOOTP or RARP will automatically assign the card an IP address,
therefore, this command would not be utilized
Context
Sub-context
Commands
diag
Subcontext
Function
set address
show
address
The number of possible commands is quite large but two main sub-contexts are netsh
firewall set and netsh firewall show An extensive list of commands is in the knowledge
base article previously mentioned.