Experiment No 2
AIM: Execution of Basic Networking Commands.
ipconfig, nslookup, tracert, ping, route, arp, netstat
1. ipconfig
ipconfig displays Internet Protocol version 4 (IPv4) and IPv6 addresses, subnet mask, and default
gateway for all adapters.
Syntax:
ipconfig [/allcompartments] [/? | /all | /renew [adapter] | /release [adapter] | /renew6 [adapter] |
/release6 [adapter] | /flushdns | /displaydns | /registerdns | /showclassid adapter | /setclassid
adapter [classid] | /showclassid6 adapter | /setclassid6 adapter [classid] ]
Options:
/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. nslookup
Nslookup (stands for “Name Server Lookup”) is a useful command for getting information from DNS
server. It is a network administration tool for querying the Domain Name System (DNS) to obtain
domain name or IP address mapping or any other specific DNS record. It is also used to troubleshoot
DNS related problems.
Syntax
nslookup [exit | finger | help | ls | lserver | root | server | set | view] [options]
Parameters
Parameter Description
nslookup exit Exits the nslookup command-line tool.
nslookup Connects with the finger server on the current computer.
finger
nslookup help Displays a short summary of subcommands.
nslookup ls Lists information for a DNS domain.
nslookup Changes the default server to the specified DNS domain.
lserver
nslookup root Changes the default server to the server for the root of the DNS domain
name space.
nslookup Changes the default server to the specified DNS domain.
server
nslookup set Changes configuration settings that affect how lookups function.
nslookup set Prints the current values of the configuration settings.
all
nslookup set Changes the query class. The class specifies the protocol group of the
class information.
nslookup set Turns exhaustive Debugging mode on or off. All fields of every packet are
d2 printed.
nslookup set Turns Debugging mode on or off.
debug
nslookup set Changes the default DNS domain name to the name specified.
domain
nslookup set Changes the default TCP/UDP DNS name server port to the value
port specified.
nslookup set Changes the resource record type for the query.
querytype
nslookup set Tells the DNS name server to query other servers if it doesn't have the
recurse information.
nslookup set Sets the number of retries.
retry
nslookup set Changes the name of the root server used for queries.
root
nslookup set Appends the DNS domain names in the DNS domain search list to the
search request until an answer is received. This applies when the set and the
lookup request contain at least one period, but do not end with a trailing
period.
nslookup set Changes the default DNS domain name and search list.
srchlist
nslookup set Changes the initial number of seconds to wait for a reply to a request.
timeout
nslookup set Changes the resource record type for the query.
type
nslookup set Specifies to use or not use a virtual circuit when sending requests to the
vc server.
nslookup Sorts and lists the output of the previous ls subcommand or commands.
view
If the lookup request fails, the command-line tool provides an error message, including:
Error message Description
timed out The server didn't respond to a request after a certain amount of time
and a certain number of retries. You can set the time-out period with
the nslookup set timeout command. You can set the number of retries
with the nslookup set retry command.
No response from No DNS name server is running on the server computer.
server
No records The DNS name server doesn't have resource records of the current
query type for the computer, although the computer name is valid.
The query type is specified with the nslookup set
querytype command.
Nonexistent The computer or DNS domain name doesn't exist.
domain
Connection The connection to the DNS name server or finger server could not be
refused or made. This error commonly occurs with the ls and finger requests.
Network is
unreachable
Server failure The DNS name server found an internal inconsistency in its database
and could not return a valid answer.
Refused The DNS name server refused to service the request.
format error The DNS name server found that the request packet was not in the
proper format. It may indicate an error in nslookup.
3. tracert
The tracert command is used to visually see a network packet being sent and received and the
number of hops required for that packet to get to its destination.
Syntax:
tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6]
target_name
Options:
-d Do not resolve addresses to hostnames.
-h maximum_hops Maximum number of hops to search for target.
-j host-list Loose source route along host-list (IPv4-only).
-w timeout Wait timeout milliseconds for each reply.
-R Trace round-trip path (IPv6-only).
-S srcaddr Source address to use (IPv6-only).
-4 Force using IPv4.
-6 Force using IPv6.
4. Ping
Ping is a command-line utility, available on virtually any operating system with network
connectivity, that acts as a test to see if a networked device is reachable.
The ping command sends out an echo request. If it finds the target system, the remote host
sends back an echo reply. The distance (number of hops) to the remote system can be
determined from the reply, as well as the conditions in-between (packet loss and time to
respond).
Syntax:
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] [-R] [-S srcaddr] [-4] [-6 target_name
Options:
-t Pings the specified host until stopped.
To see statistics and continue - Type Control-Break;
To stop - press Ctrl + C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in the packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated and has no
effect on the type of service field in the IP Header).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host- Loose source route along host-list (IPv4-only).
list
-k host- Strict source route along host-list (IPv4-only).
list
-w Timeout in milliseconds to wait for each reply.
timeout
-R Use routing header to test reverse route also (IPv6-only).
Per RFC 5095 the use of this routing header has been deprecated. Some systems
may drop echo requests if this header is used.
-S The source address to use.
srcaddr
-4 Force using IPv4.
-6 Force using IPv6.
5. route
Command to manually configure the routes in the routing table
Syntax:
ROUTE [-f] [-p] [-4|-6] command [destination] [MASK netmask] [gateway] [METRIC metric]
[IF interface]
Options:
-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
-4 Force using IPv4.
-6 Force using IPv6.
command One of these:
PRINT Prints a route
ADD Adds a route
DELETE Deletes a route
CHANGE Modifies an existing route destination
destination Specifies the host.
MASK Specifies that the next parameter is the 'netmask' value.
netmask Specifies a subnet mask value for this route entry. If not specified, it defaults
to [Link].
gateway Specifies gateway.
interface the interface number for the specified route.
METRIC Specifies the metric, ie. cost for the destination.
6. arp
ARP Command is a TCP/IP utility and Microsoft Windows command for viewing and
modifying the local Address Resolution Protocol (ARP) cache, which contains recently
resolved MAC addresses of Internet Protocol (IP) hosts on the network. When one host on a
TCP/IP network wants to communicate with a second host, the first host begins by using the
ARP to resolve the IP address of the second host into its associated MAC address. The MAC
address is needed for communication to take place over the network.
Typing arp -a displays the MAC addresses of recently resolved IP addresses.
Syntax:
ARP -s inet_addr eth_adr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr]
Options:
-a Displays current ARP entries by interrogating 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.
-g Same as -a
inet_addr Specifies an Internet address.
-N if Displays the ARP entries for the network interface specified by if_addr.
addr
-d Deletes the host specified by inet_addr.
-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 separated
by hyphens. The entry is permanent.
eth_addr Specifies a physical address
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.
7. netstat
Netstat — derived from the words network and delivers basic statistics on all network activities
and informs users on which ports and addresses the corresponding connections (TCP, UDP)
are running and which ports are open for tasks.
The netstat command is used to display the TCP/IP network protocol statistics and information.
Syntax:
NETSTAT [-a] [-b] [-e] [-f] [-n] [-o] [-p proto] [-r] [-s] [-x] [-t] [interval]
Options:
-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 Shows connections for the protocol specified by proto; proto may be any of: TCP,
proto 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.
-x Displays NetworkDirect connections, listeners, and shared endpoints.
-y Displays the TCP connection template for all connections. Cannot be combined
with the other options.
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.