Networking For DevOps
Networking For DevOps
Tags Networking
What is a Network?
When two or more computers and computing devices connected together with
each other through communication channels, such as cables or wireless media
and sharing some files, then it is called a Network.
A network is used to:
Enable multiple users to share devices over the network, such as music and
video servers, printers and scanners.
The Internet is the largest network in the world and can be called "the network
of networks".
Types of Networks
There are different types of networks. But the main two are LAN and WAN
3. WAN (Wide Area Network) - extends LAN over a large geographic area.
e.g:- optical fiber cable
Network Components:
1. Switch:
3. Modem:
4. Hub:
5. NIC:
6. Bridge:
What is Protocol?
A network protocol is a set of rules which is set up by people that determine
how a particular data is transmitted between different devices in the same
network. e.g.: HTTP, TCP, IP, FTP, SMTP etc.
Types of IP Addresses
1. IPv4:
2. IPv6:
4. Private IP:
5. Static IP:
Often used for servers and devices that need a consistent address.
6. Dynamic IP:
240.0.0.0 -
E Experimental, used for research.
255.255.255.255
Note:
0.0.0.0 is a special address, not part of the usable IP address range in Class
A.
It’s often used for testing network software on the local machine.
Key Points:
127.0.0.1 is commonly known as "localhost."
Any IP address in the 127.x.x.x range will loop back to the same device.
Class C: 1st, 2nd, and 3rd octets are the Network ID.
Direct Connection: Devices with the same Network ID can connect without
a router.
We will try to break it with text based structural diagram for a better
understanding:
+---------------------+---------------------+-----------------
| IP Address Class | Network ID | Host ID
+---------------------+---------------------+-----------------
| Class A | 1st Octet | 2nd, 3rd, 4th
| | Example: 17.0.0.1 | (0.0.1)
+---------------------+---------------------+-----------------
| Class B | 1st & 2nd Octets | 3rd, 4th
| | Example: 172.16.0.1| (0.1)
Connection Summary:
+-----------------------+---------------------------+---------
| Device A IP | Device B IP | Connec
+-----------------------+---------------------------+---------
| 17.0.0.1 | 17.0.4.2 | Direct
+-----------------------+---------------------------+---------
| 17.0.0.1 | 192.168.1.5 | Requir
+-----------------------+---------------------------+---------
Explanation:
- If Device A and Device B are in the same network (same Netwo
- If they are on different networks (different Network IDs), a
Router Usage:
+-----------------------+---------------------------+---------
| Different Networks | Example: | Connec
+-----------------------+---------------------------+---------
| Device A Network ID | 17 (Class A) |
| Device B Network ID | 192.168 (Class C) |
| Router Needed | Yes | Requir
+-----------------------+---------------------------+---------
Example of Subnetting:
Given network: 192.168.1.0/24
/24 indicates a subnet mask of 255.255.255.0, meaning there are 8 bits for
hosts (32 total bits in IPv4 - 24 bits for the network portion = 8 bits for
hosts).
1. Subnet 1: 192.168.1.0/25
Total IPs: 128 addresses (126 usable for hosts, as the first address is the
network address and the last is the broadcast address).
2. Subnet 2: 192.168.1.128/25
Summary Table
Subnet Range Subnet Mask Total IPs Usable Host IPs
192.168.1.0 -
192.168.1.0/25 255.255.255.128 128 126
192.168.1.127
Explanation:
By using a /25 mask instead of /24, we split the network into two subnets
with 128 IP addresses each.
This creates smaller segments within the original network, making it easier
to manage specific groups of hosts separately.
Benefits of Subnetting:
1. Improves Network Performance: Reduces broadcast domains, limiting
broadcast traffic to specific subnets.
Number of Relation to
Prefix Netmask Comment
addresses class
Single host in a
/32 255.255.255.255 1 Class C/256
network
Class C*256 =
/16 255.255.0.0 65,536
Class B
Class B*256 =
/8 255.0.0.0 16,777,216
Class A
Network Models
There are mainly two types of network model -
2. TCP/IP Model
2. Data Link Layer: Manages data transfer between directly connected nodes.
It handles error detection and flow control. Examples: Ethernet, Wi-Fi.
4. Transport Layer: Ensures reliable data transfer with error correction and
flow control. Examples: TCP, UDP.
7. Application Layer: Interfaces directly with the user and provides network
services like HTTP, FTP, SMTP.
Port numbers are used primarily in the Application and Transport Layers to
ensure data is delivered to the correct services and applications running on a
computer.
2. TCP/IP Model:
The
TCP/IP model, also known as the Internet Protocol Suite, is a simplified version
of the OSI model with only 4 layers instead of 7.
This model is a real model which actually works in real. This model consists of 4
layers.
2. Transport Layer
3. Network Layer
It is a client server stateless (means it never stores any data of client) protocol,
and it tells us how it requests any data from the server and also tells us how the
server will send the data back to the client.
- Status Codes
2. 300s: Redirects
Moved
Permanently, The URI of the requested resource has been
301, 308
Permanent changed permanently.
Redirect
404 Not Found The server can’t find the requested resource.
Find the complete list of status codes with detailed explanations by Mr.
Abhishek Veeramalla (Thank you!):
iam-veeramalla/http-status-codes: Repo to demonstrate HTTP status codes
I have said that HTTP is a stateless protocol, means it never store any data of
client in server. Then suppose when you will search for the second
time amazon.com then it should be logged out from the server, and you have to log
in again for second time visit, but you don't. In second time, it's automatically
logged in, and you can see all of your saved carts 🛒 and all data. So how it is
possible?? Here, cookies come into the picture.
SMTP is used in sending and receiving any email from senders SMTP server to
Receiver's SMTP server
FTP is used to download, upload and transfer files from one host to another
host.
Before transmitting packets, TCP must ensure that a stable connection has
been set up between the sender and the recipient. This is where the three-
way handshake (or SYN-SYN-ACK) comes in.
Find the link below for Common Ports and Protocols Cheat Sheet (Thanks to
Stationx):
Common Ports Cheat Sheet: The Ultimate List
Routing:
So how do we get a packet of information from a host on one network to a host
in another? In one word: Routing.
We use tables to help us determine the routes we want to take. This screenshot
demonstrates a typical route table in AWS:
When making a routing decision, more narrow rules are evaluated first:
If a packet destination does not fall in any of these ranges, the widest one is
evaluated which is 0.0.0.0/0 which means it is internet traffic. And the
packet will be redirected to the Network Address Translation (NAT)
interface.
DNS works like the phonebook of the internet, allowing humans to use readable
names while machines use numerical addresses.
The DNS process involves looking up the domain name and finding the
corresponding IP address through multiple DNS servers.
2. DNS Query:
3. DNS Resolution:
The DNS server checks if it has the IP address cached. If not, it contacts
other DNS servers (root, TLD, and authoritative servers) to find the IP
address.
The browser uses this IP address to connect to the web server, and the
website loads on your screen.
For example, ICANN controls the root domain and delegates .com to
Verisign.
DHCP
DHCP (Dynamic Host Configuration Protocol) is a network management
protocol that automatically assigns IP addresses and other network
configurations (such as subnet mask, gateway, DNS servers) to devices on a
network.
Example:
When you connect your laptop to a Wi-Fi network, a DHCP server assigns it
an IP address automatically, allowing it to communicate with other devices
on the network without manual configuration.
Switches: Connect devices within the same network and use MAC
addresses to forward data to the correct device.
Firewalls
Firewalls control incoming and outgoing network traffic based on predetermined
security rules.
Load Balancers
Load balancers distribute incoming network traffic across multiple servers to
ensure no single server becomes overwhelmed.
VPN
VPN (Virtual Private Network) provides a secure connection between remote
users and the corporate network over the internet.
Usage: For basic troubleshooting, you can run ping www.google.com to check
network connectivity and see response times and packet loss.
How It Works: Sends UDP probes with increasing TTL values, showing each
router along the route and the delay in reaching it.
3. telnet
Purpose: Test network connections and protocols.
4. curl
Purpose: Transfer data using multiple protocols, often for HTTP requests.
Usage:
Usage: dig google.com to get information like IP addresses, TTL, and DNS
record types.
Usage:
How It Works: Sends raw packets to identify hosts, services, and operating
systems.
Usage:
Usage:
Secure and encrypted, used for remote management and file transfers.
Usage:
user@remote:/path/to/destination .