Friday, January 1, 2021

Use Linux Network tool to maintain network

 

Use Linux Network tool to maintain network

                                              
Combination of two more computers connected together to share their resources each other by means of communication like cable is called Network.

Media :-

Media is nothing but cable to connect two or systems. Example : RJ 45, CAT 5 and CAT 6, ....etc.

NIC card :-

A Network Interface Card or controller is hardware component that connects a computer to a computer network.
Each NIC card will be having MAC (Media Access Controller) address to avoid conflicts between same NIC adapters.
In Linux these NIC adapter is represented by the word "eth" .
Example if two NIC cards are there in a system then it will be denoted as "eho","eth1", .....etc

Topology :-

Topology is a design in which the computers in network will be connected to each other. Example for
topologies
are Bus, Ring, Star, Mesh, Tree topologies.

protocol :-

Protocols are TCP/IP (Transmission Control Protocol), UDP (User Datagram
Protocol), HTTP. The most widely and regularly used protocols for transferring data are TCP and UDP. Let’s analyze some basic differences between TCP/IP and UDP.

Difference b/w TCP and UDP protocol

TCP is a connection oriented protocol and contain the information of sender as well as receiver.
Example : HTTP, FTP, Telnet
Note . TCP is slower than UDP due to its error checking mechanism
UDP protocols are connection less packets have no information to where they are going.
These type of ports are generally used for broadcasting.
Example : DNS, DHCP

IP ADDRESS

Every Computer will be assigned an IP address to identify each one to communicate in the network.
Classes of IP address :
The IP addresses are further divided into classes. The classes are A, B, C, D, E and the ranges are given


Class -A    0.0.0.0        127.255.255.255           255.0.0.0                /8
Class -B    128.0.0.0    191.255.255.255           255.255.0.0           /16
Class -C    192.0.0.0    223.255.255.255           255.255.255.0       /25
Class -D    224.0.0.0    239.255.255.255      
Class -E    240.0.0.0    255.255.255.255

How to set IP address in Linux  :

Using nmcli command  ( Network Namager command line interface )
Setup In RHEL -7

root@server:~#nmcli con show         (to see all the network connection names)

root@server:~# nmcli device show      (It displays all the NIC devices network information of the system )

root@server:~# nmcli device show eth0  (to see all the network devices information of the eth0)

root@server:~# nmcli connection add con-name <connection name> ifname <NIC device name> type ethernet   (to create a new connection name for eth0)

root@server:~#nmcli con add con-name eth0 ifname ens33 type ethernet  (Enter)
root@server:~#nmcli con show        (show create connection)

root@server:# nmcli connection modify eth0  ipv4.address 192.168.105.10/24

root@server:#nmcli con up eth0  (to activate or up the specified connection)

root@server:# nmcli connection down  eth0  (to disable or down the specified connection)
root@server:# nmcli connection show eth0 (to see the information about the specified NIC)

root@server:# ping  192.168.105.10  (to check the connection from NIC device to IP address)

Loopback address:-

A special IP number (127.0.0.1) is designated for the software loopback interface of a machine.
127.0.0.0 and 127.255.255.255 is also reserved for loopback and is used for internal testing on local machines.

subnet mask :-

A subnet mask allows the users to identify which part of an IP address is reserved for the network and which part is available for host use.

Gateway :-

A Gateway is the network point that provides entrance into another network.
For example: Our network is 192.168. something and we want to
send a file to other computer on 10.10.network, so we need a gateway to communicate between two computers of different networks.

root@server:~# netstat -r        (to check the default gateway and routing table)

Some Important configuration files in Linux 

root@server:~# cat /etc/sysconfig/network-scripts/  This directory keep the configuration of network devices connected to the system.
Examples  ifcfg-eht0, ifcfg-eth1, ifcfg-eth2, .....etc.

# cat /etc/sysconfig/network

This file keeps the information about the hostname assigned to the system and  we want to change the hostname permanently using this file .

RHEL - 6 : To set hostname temporarily in linux
ex:
# hostname  server.example.com 

RHEL - 6 : To set the hostname permanently in linux

root@server:~# vim /etc/sysconfig/network
                            HOSTNAME=server.example.com            (save and exit this file)

root@server:~# service network restart

root@server:~# chkconfig network on   (to enable the connection at next reboot)

RHEL - 7 :To set hostname temporaril in linux

root@server:~# hostname   server.example.com   (set the hostname temporarily)

RHEL - 7 :To set hostname permanently in linux

root@server:~#hostnamectl set-hostname server.example.com 
                                                                            (to set the hostname permanently)

# hostname -i                         (to see the IP address of the system)
# hostname -d                        (to check the domain name of the system)
# hostname -s                        (to check the hostname without domain name)


# cat /etc/resolve.conf
This file keeps the address of the DNS server to which the clients will be accessing to resolve IP address to hostname and hostname to IP address .

You can edit this file and set server ip address and hostname
root@server:~# vim /etc/resolve.conf
                         #Generated by NetworkManager
                          search example.com
                          nameserver 192.168.105.10
      Save and quite .

Now using nslookup and dig command you can check it is resolve the ip to hostname and hostname to ip.

 nslookup command

root@server:~# nslookup 192.168.105.10
 server : 192.168.105.10
 Address  192.168.105.10#53

10.105.168.192.in-addr.arpa name=example.com                                 
10.105.168.192.in-addr.arpa name=server.example.com

The most common command used to check DNS function is “dig”

root@server:~#dig server.example.com

root@server:~#dig -x 192.168.105.10


How to check all the open ports of your machine?

root@server:~#nmap localhost

How to check all the open ports of remote machine?

root@server:~#nmap  192.168.105.110 (Remote machine ip address)

Check all the listening ports and services of your machine.

root@server:~# netstat -ntulp
                                -n -----> port no. (numeric no)
                                -t ----->tcp protocol
                                -u -----> upd protocol
                                -l -----> port is listening or not
                                -p -----> display the process ID

root@server:~# ifconfig              (to check the NIC card is enable or not)

root@server:~# ip addr show     (to show all NIC devices present on the system)

root@server:~# hostname -i       (to see the IP address of the system)

root@server:~# hostname -d      (to check the domain name of the system)

root@server:~# hostname -s      (to check the hostname without domain name)





No comments:

Post a Comment