Networks Basic Commands
Networks Basic Commands
1.ping
Use ping to see if a host is alive. This super simple command helps you check the status of a host or
a network segment. Ping command sends an ICMP ECHO_REQUEST packet to the target host and
However, some hosts block ICMP echo requests with a firewall. Some sites on the internet may also
do the same.
By default, ping runs in an infinite loop. To send a defined number of packets, use -c flag.
$ ping -c 3 google.com
PING google.com (172.217.167.238): 56 data bytes
64 bytes from 172.217.167.238: icmp_seq=0 ttl=118 time=7.898 ms
64 bytes from 172.217.167.238: icmp_seq=1 ttl=118 time=7.960 ms
64 bytes from 172.217.167.238: icmp_seq=2 ttl=118 time=6.247 ms
Traceroute shows the sequence of gateways through which the packets travel to reach their
Line 4 in this output shows a * in the round trip times. This indicates no response was
received. This can be due to many reasons – as the traceroute ICMP packets are low-
priority, these may be dropped by a router. Or there could be simply congestion. If you
see a * in all the time fields for a given gateway, then possibly the gateway is down.
3.netstat
Most useful and very versatile for finding a connection to and from the host. You can find out all the
multicast groups (network) subscribed by this host by issuing "netstat -g"
netstat -nap | grep port will display process id of application which is using
that port
netstat -a or netstat –all will displayall connections including TCP and UDP
netstat --tcp or netstat –twill display only TCP connection
netstat --udp or netstat –u will display only UDP connection
netstat -g will display all multicastnetworksubscribed by this host
Here is an example:
$ netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-
OVR Flg
eth0 1500 0 4001 0 0 0 2283 0 0
0 BMRU
eth1 1500 0 27154 0 0 0 838962 0 0
0 BMRU
lo 65536 0 0 0 0 0 0 0 0
0 LRU
Copy
Using-r flag will display the routing table. This shows the path configured for sending network
packets.
$ netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt
Iface
default 10.0.2.2 0.0.0.0 UG 0 0 0
eth0
10.0.0.0 * 255.255.255.0 U 0 0 0
eth1
10.0.2.0 * 255.255.255.0 U 0 0 0
eth0
Copy
An asterisk in the last two lines indicates that no gateway is required to send packets to any host on
these networks. This host is directly connected to the networks 10.0.0.0 and 10.0.2.0.
Inthe first line, the destination is the default, which means any packet destined for a
network not listed in this table is handled by the router 10.0.2,2.
netstat command without any options displays a list of open sockets. Use -I flag to show only
listening sockets, which by default, are not shown. You can use -a flag to show listening and non-
listening sockets.
2. Peer-peer communication
Peer-To-Peer network
Peer-To-Peer network is a network in which all the computers are linked together with
equal privilege and responsibilities for processing the data.
Special permissions are assigned to each computer for sharing the resources, but this can
lead to a problem if the computer with the resource is down.
•Cost efficiency: There is no central server or network operating system (NOS) to maintain and pay for,
making P2P economical.
•Low failure rate: There is no single point of failure unless the network is very tiny.
•Robust and agile: P2P networks are highly resistant to changes. If one peer quits, the entire network suffers
little. When many peers join the network simultaneously, the network can easily manage the additional
demand. Additionally, the absence of a centralized server means that P2P networks may withstand attacks
quite effectively due to their decentralized structure.
•Enhanced accessibility: Because the file library is readily accessible, clients may access any file at any
moment.
•Efficient and straightforward retrieval: In P2P networking, the retrieval procedure is uncomplicated. For
example, when a system is abruptly short down or connection is lost during downloads, the network resumes
the download from the point where it was interrupted once the connection is re-established.
3.Client/Server Network
Client/Server network is a network model designed for the end users called clients, to
access the resources such as songs, video, etc. from a central computer known as Server.
The central controller is known as a server while all other computers in the network are
called clients.
A server performs all the major operations such as security and network management.
A server is responsible for managing all the resources such as files, directories, printer,
etc.
All the clients communicate with each other through a server. For example, if client1
wants to send some data to client 2, then it first sends the request to the server for the
permission. The server sends the response to the client 1 to initiate its communication with
the client 2.
Some Examples of Client-Server Architecture
1.Email servers
2. File servers
3.Web servers