Networking Basics

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 19

Networking Basics –

IP = IP is a logical address to identify or locate your specific machine on a LAN.


e.g – student roll number is nothing but IP address

Swith = is a device which sits in your LAN and helps you to talk to the various devices present
in LAN.
e.g – Peon of ur school is nothing but switch.

Router = is a network device which sits between our LAN and outside network which is WAN.
E,g – router is nothing but mail security guard of your school.

SUBNET(sub network ) = Sits in your LAN and its define the range of your LAN. Its not an IP
address its set of flags.
E.g – our LAN device IP address are belows

192.168.10.20 -- ip of laptop
255.255.0.0 – it could be subnet (subnet is 192.168 which is common number in all LAN ip
assress)
192.168.5.10 -- ip of Printer

GATEWAY = IP address of router is called as GATEWAY. So router and IP address both are
same things.

WAN –
Router has basically 4 core functionality
1. NAT (Network Address Translator ) – While any LAN device wants to connect to WAN
through router then router will change that IPaddress or Subnet address to secure our
device in network through NAT.
2. Firewall - Firewall is nothing but a set of passive rules which are define to enable the set
standard to communication. If you want to allow any type of communication through this
firewall then what are the options you have ? you can either configure the DMZ or port
forwarding.
a) DMZ - DMZ (Demilitarized zone) – a DMZ is sub network that contains and exposes the
device to an untrusted, network such as Internet. The purpose of the DMZ is to protect
both sides from attack. DMZ is nothing but reception area of your school where parent
and student can meet to each others.

b) Port Forwarding – is the another mechanism through which we can allow the
communication from outside network within the local area network through the firewall
and router. In this concept we don’t create a separate DMZ rather you specify exactly on
which particular port of this particular device the communication needs to happen.

Port = Any machine which is there in the network talks to different machines through
different ports.

Bydefault port numbers –


8080 – Web server requests which are coming from browsers.
22 – TCP and SSH
25 – SMTP and mailing server
1521 – Oracle
1433 - SQL server
3306 - My sql server
53 – DNS , TCH/UDP
1. TCP/IP Internet protocol

TCP/IP is a set of protocols, and is the primary tech of the internet. When you browse the web,
send email, chat online, online gaming, TCP/IP is working internally.

Example:

Suppose you are sending email, or downloading a file, or chat with a friend online, or visiting a
web page. What happens underneath?

You application (email, chat, etc) breaks the data into thousands of tiny independent pieces.
Each piece is called a Datagram (aka packet). Each datagram has embedded with it the
destination IP address. Your computer send this datagram to your Router (aka “link”), and your
router send it to a appropriate node (another router or computer) on the network that's closer
to the destination.

That router again send it to a another node (router) on the network that's closer to the
destination. This process continues until the designated machine with the IP address receives it.
This is done for each and every datagram.

On the receiving machine, it re-assembles all these datagrams into the original whole piece in
the right order, and send it to the right application on that machine (the email server, or web
server, or chat server. (which in turn, repeat the same thing to send it to your friend's
machine.))

Computer/software follow a set of standardized rules of procedure when talking to each other.

This standardized rules of procedure used for internet is called the TCP/IP Internet protocol
suite.

2. Network Components

1. Network Interface Controller

First, you have Network interface controller (NIC)


(i.e. network interfacecard,
network adapter, LAN adapter, network card).
It's a piece of hardware that lets your computer talk to the internet.

2. Router

Then, the second most important hardware is Router. Router transfer packets between
computers.

3.MAC Address = Hardware Address = Physical Address

Each Network Adapter has a ID, called MAC address (aka hardware address, physical address).
This ID is burned into the hardware. (“MAC” is abbreviation for “Media Access Control” (the
name is historical).)

MAC address is a 48 bits number. Usually written as 6 groups of 2 hex digits. For example, 01-
23-45-67-89-abor 01:23:45:67:89:ab. Each 2 hex is a octet.

We can find the MAC address of the Network Adapters by using

ip link

4. IP Address

IP address is used to identify all internet devices. (Each internet device may have one or more
IPaddress.) It's part of the IP protocol. There are 2 versions of IP address: IPv4 and IPv6.

IPv4 address = 32 bits (4 octets).Usually written in 4 groups, each as a decimal. Forexample,


172.16.254.1 (for IPv4), each decimal group is 1 octet.

IPv6 address = 128 bits (16 octets). Usually written in 8 groups, 4 digits of hex per
group,separated by colon, with leading 0 omitted, for example, 2001:db8:0:1234:0:567:8:1.
Each group of hex represents 2 octets.
IPv4 is the older standard. Because it's only 32 bits, good for 2^32 unique address (about 4.2
billion). This is not enough since late 1990s. So, IPv6 was invented.

5. Host, Hostname

A “host” typically refers to a particular computer (or internet device). A Hostname is basically
just a name for a machine. It is used mostly as a human-friendly form to identify a machine.

A host/machine may have more than one IP address (because it can have multiple Network
Adapter, or, a computer can be setup to function as a router, etc.).

6.Port Number

port→ a integer number.It serves as a address for software application to talk to TCP. IP
address is used to identify a computer.Once the packet arrived on the computer, the port
numberserves as a address to identify the software that send/receive messages

7. Network socket

Network Socket is basically a API for programs to talk to the network. A socket address is a
combination of IP address and a port number.

So, when a browser, or email app, want to talk to the internet, they speak to the socket. The
socket is usually provided by the Operating System as a API. The programmer don't have to
worry about TCP/IP details, he just create a socket (by calling a function or new object), specify
IP address, port number, and type of connection, and call functions/methods to send/receive
data on it.

8. Routing

Routingis one of the most important element in internet, because it is routing that moves
data.Routing specifies the path of how to forward data to the destination server.

By definition, a router has 2 or more network adapters, because a router is used to forward
data between different networks. For home routers, usually one end is connected to a cable
modem or DSL modem to the internet, and the other hand are Ethernet ports for the home
network.

receive data from one of its attached networks.


check the destination address in the IP header. If it's on the network from whence the data
came, the datagram is ignored. (because already reached its destination. (Ethernet sends it to
all in the same network))

If destination IP address for a different network, the router checks the routing table to
determine where to forward the datagram.

it dis-assemble and re-assemble the datagram and send it to the right adapter.

Routing Table

Routing table, or Routing Information Base (RIB), is a data table stored in a router or a
computer that lists the routes to particular network destinations, and in some cases, metrics
(distances) associated with those routes. The routing table contains information about the
topology of the network immediately around it.

[Sparktech@admin ~]$ip route

default via 217.182.88.1 dev eth0 proto static metric 100 217.182.88.1 dev eth0 proto static
scope link metric 100

217.182.92.164 dev eth0 proto kernel scope link src 217.182.92.164 metric 100
Ping command
ping – send ICMP ECHO_REQUEST to network hosts
PING (Packet INternet Groper) command is the best way to test connectivity between two
nodes. Whether it is Local Area Network (LAN) or Wide Area Network (WAN). Ping use ICMP
(Internet Control Message Protocol) to communicate to other devices. Once destination server
or gateway is Active then we will get ECHO_RESPONSE back, so that we can say the destination
server is running.

NETSTAT –

 It will list out the interface connection of a system.


 It will list out the TCP , UDP , Unix socket connections
 We can check which port are open and what connections are active and what ports
the system is listening.
 Netstat –ie will give us the same output as ifconfig
 Netstat –a will give us all the connection details
 Netstat –tu will give us tcp and udp connections only
 Netstat –lnt will show the system listening port details –
Ifconfig –

ifconfig – configure a network interface

e.g – If your laptop is connected to the internet but still you are unable to access internet then
in that case we need to check the configuration of that network through ifconfig command.
There are mainly two reason of this issue – one is we are not getting new IPAddress or the
other network DHCP server is talking with our old ipaddress. Then in that case we need to
release all the old ipaddress which is stored in our laptop through IPCONFIG/RELEASE
command. And we need to request new ipaddress trough IPCONFIG/RENEW command , In this
case DHCP will provide new ipaddress to your machine and we can access the Internet.

--If its windows server then we need to type IPCONFIG and if linux server then we need to
type Ifconfig.

Linux we need to type ifconfig –a = display all details like below.

DHCP – Dynamic Host Configuration Protocol = If your system did not get any new ipaddress
then we can take IPaddress of our machine from DHCP server.
eth0= its wired connected network

wlan0 means its wireless connection.

Lo means loopback connection to communicate itself.

Inet means local address of computer.

HWAddress means Hardware address means MAC address of computer.MAC address we


cannot change.

Bcast means broadcast address

Mask Address –

Inet6 addr means IPv6 address

Rx packet – and TX packet – received and transferred packet at the time while we hit the
command.

e.g – If we want to disconnect the internet of a server then we need to use below command

ifconfig eth0 down

if we want to connect back to the internet then we can use below command –

ifconfig eth0 up

TRACEROUTE –

This is used to trace the routes.

 Below picture is nothing but public network and one PC is wants to communicate to
any web application through internet. There are multiple route to reach to the
destination. Router can select then best / appropriate/available route to reach
destination.

 Once route is fixed then packets has been passed through that route. In below screen
shot connection between source and destination has been well established. Trace
route command will hit the adjacent router interfaces ip address and moving forward
to the destination. If in case of any router failed or disconnected then using trace
route command we will get to know where is our message has been passed.
- In below screen we want to trace the route from our home pc to the google server where
google.com page is location.

if we are using home pc then we need to write tracert command except trace route.

 Hops represents the no of routers and trace route command will trace the route until 30
routers. If our route contain more than 30 routers then trace route command will not
help.
NSLOOKUP – (Name server lookup)

 Through Name server we get to know where/on which server our website is
hosted(hosting server).
 Through name server we can connect to domain home to the hosting server.
TELNET – (TELecommunication Network)

 Through which we can take remote access of any other remote location server.
 Bydefault telnet use TCP 23 port
 We can do same things with SSH command and bydefault port of SSH is 22.
 We can use putty tool do telnet and SSH
 telnet is not a secure so that we can go with SSH.

You might also like