Ex - 7

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

CN22511 –COMPUTER NETWORKS LABORATORY

EX.NO:7
DATE:
Learn to use commands like tcpdump, netstat, ifconfig,
nslookup and traceroute

AIM:
To Learn to use commands like tcpdump, netstat, ifconfig, nslookup and traceroute

1. Tcpdump
The `tcpdump` utility allows you to capture packets that flow within your network to
assist in network troubleshooting. The following are several examples of using `tcpdump`
with differentoptions. Traffic is captured based on a specified filter

Options Description
-D: Print a list of network interfaces.
-i: Specify an interface on which to capture.
-c: Specify the number of packets to receive.
-v, -vv, -vvv: Increase the level of detail (verbosity).
-w: Write captured data to a file.
- r: Read captured data from a file.

Many other options and arguments can be used with

`tcpdump`.Specific Examples Using `tcpdump`

1. Display traffic between 2 hosts


To display all traffic between two hosts (represented by variables `host1` and
`host2`):# tcpdump host host1 and host2
2. Display traffic from a source or destination host only
To display traffic from only a source (src) or destination (dst)
host:# tcpdump src host
# tcpdump dst host
3. Display traffic for a specific protocol
Provide the protocol as an argument to display only traffic for a specific protocol, for
example
`tcp`, `udp`, `icmp`, `arp`:
# tcpdump protocol
For example, to display traffic only for the TCP
protocol:# tcpdump tcp
Filtering based on source or destination
portTo filter based on a source or
destination port: # tcpdump src port ftp
# tcpdump dst port http

Reg. Number: 2127220501031 Page No.:


2. Netstat

Netstat is a common command line TCP/IP networking tool available in most versions of
Windows, Linux, UNIX, and other operating systems. Netstat provides information and
statistics about protocols in use and current TCP/IP network connections. The Windows
help screen (analogous toa Linux or UNIX help screen) for netstat reads as follows:
"Displays protocol statistics and current TCP/IP network connections."

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. The executable name is in [] at the bottom; on top is the component it called, and
so forth until TCP/IP was reached. Notethat this option can be time-consuming and will fail
unless you have sufficient permissions.

Reg. Number: 2127220501031 Page No.:


-e Displays Ethernet statistics. This may be combined with the `-s` option.
-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 anyof: IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.

Reg. Number: 2127220501031 Page No.:


-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.

-v When used in conjunction with `-b`, will display the sequence of components
involved increating the connection or listening port for all executables.

Reg. Number: 2127220501031 Page No.:


3. Ifconfig
In Windows, `ipconfig` is a console application designed to run from the Windows
command prompt. This utility allows you to get the IP address information of a Windows
computer. It alsoallows some control over active TCP/IP connections. `ipconfig` replaced
the older `winipcfg` utility.

Using ipconfig
From the command prompt, type `ipconfig` to run the utility with default options. The output
of thedefault command contains the IP address, network mask, and gateway for all physical
and virtual network adapters.

Syntax
ipconfig [/all] [/renew [Adapter]] [/release [Adapter]] [/flushdns] [/displaydns]
[/registerdns][/showclassid Adapter] [/setclassid Adapter [ClassID]]

Parameters
-Used without parameters: displays the IP address, subnet mask, and default gateway for
alladapters.

-/all: Displays the full TCP/IP configuration for all adapters. Without this parameter,
`ipconfig` displays only the IP address, subnet mask, and default gateway values for each
adapter. Adapters can represent physical interfaces, such as installed network adapters, or
logical interfaces, such asdial-up connections.
- /renew [Adapter]: Renews DHCP configuration for all adapters (if an adapter is not
specified) orfor a specific adapter if the Adapter parameter is included. This parameter is
available only on computers with adapters that are configured to obtain an IP address
automatically. To specify an adapter name, type the adapter name that appears when you
use `ipconfig` without parameters.
- /release [Adapter]: Sends a DHCPRELEASE message to the DHCP server to release the
current DHCP configuration and discard the IP address configuration for either all adapters
(if an adapter isnot specified) or for a specific adapter if the Adapter parameter is included.
This parameter disablesTCP/IP for adapters configured to obtain an IP address
automatically. To specify an adapter name, type the adapter name that appears when you
use `ipconfig` without parameters.
- /flushdns: Flushes and resets the contents of the DNS client resolver cache. During
DNS troubleshooting, you can use this procedure to discard negative cache entries from
the cache, aswell as any other entries that have been added dynamically.
- /displaydns: Displays the contents of the DNS client resolver cache, which includes
both entriespreloaded from the local Hosts file and any recently obtained resource
records for name queries resolved by the computer. The DNS Client service uses this
information to resolve frequently queried names quickly, before querying its configured
DNS servers.
- /registerdns: Initiates manual dynamic registration for the DNS names and IP addresses
that are configured at a computer. You can use this parameter to troubleshoot a failed DNS
name registration or resolve a dynamic update problem between a client and the DNS
server without rebooting the client computer. The DNS settings in the advanced properties
of the TCP/IP protocoldetermine which names are registered in DNS.
Reg. Number: 2127220501031 Page No.:
is available only on computers with adapters that are configured to obtain an IP
addressautomatically.
- /setclassid Adapter [ClassID]: Configures the DHCP class ID for a specified adapter.
To set theDHCP class ID for all adapters, use the asterisk (*) wildcard character in place
of Adapter. This parameter is available only on computers with adapters that are
configured to obtain an IP address automatically. If a DHCP class ID is not specified, the
current class ID is removed.

Examples:

- ipconfig - To display the basic TCP/IP configuration for all adapters


- ipconfig /all - To display the full TCP/IP configuration for all adapters
- ipconfig /renew "Local Area Connection" - To renew a DHCP-assigned IP
addressconfiguration for only the Local Area Connection adapter
- ipconfig /flushdns - To flush the DNS resolver cache when troubleshooting DNS name
resolutionproblems
- ipconfig /showclassid Local- To display the DHCP class ID for all adapters with names
that startwith Local
- ipconfig /setclassid "Local Area Connection" TEST - To set the DHCP class ID for the
LocalArea Connection adapter to TEST

4. Nslookup
The nslookup (which stands for name server lookup) command is a network utility
programused to obtain information about internet servers. It finds name server information
for domains by querying the Domain Name System.

Reg. Number: 2127220501031 Page No.:


5. traceroute
Traceroute is a network diagnostic tool used to track the pathway taken by a packet
on an IPnetwork from source to destination. Traceroute also records the time taken for each
hop the packet makes during its route to the destination. Traceroute uses Internet Control
Message Protocol (ICMP) echo packets with variable time to live (TTL) values. The
response time of each hop is calculated. To guarantee accuracy, each hop is queried
multiple times (usually three times) to better measure the response of that particular hop.

tracert www.google.com

RESULT:
Thus use commands like tcpdump, netstat, ifconfig, nslookup and traceroute
executedsuccessfully.

Reg. Number: 2127220501031 Page No.:

You might also like