Computer Networking

Module 01 - Networking Basics
1. What is Computer Networking?2. Types of Computer Networks3. Internet vs Computer Network4. How Does The Internet Work?5. Network Architectures (Client...6. Host vs Node7. Network Interface Card (NIC)8. MAC Address9. IP Address
ProfileProfile
Akkal DhamiFull Stack Developer

Building modern web experiences with a focus on performance, scalability, and clean architecture.

© 2026 | Akkal Dhami | All rights reserved

Built with
byAkkal Dhami

Navigation

  • Projects
  • Dev Setup
  • Playbook
  • Templates
  • Networking
  • SQL - MySQL
  • SQL Playground
  • System Design
  • DSA
AKKAL DHAMIAKKAL DHAMIAKKAL DHAMI

IP Address

An IP (Internet Protocol) address is a unique numerical identifier assigned to a device on a network.

It operates at Layer 3 (Network Layer) of the OSI model and is used to identify where a device is on a network so data can be routed to it — even across the entire internet.

It serves two main purposes:

  • Identifies a device on a network.
  • Locates the device so data can be delivered to it.

Think of it like a postal address:

  • Your home address tells the postal service where to deliver mail.
  • An IP address tells the internet where to deliver data packets.

1. Why Do We Need IP Addresses?

Suppose your laptop wants to open a website.

  • You type www.example.com.
  • The domain name is translated into an IP address using DNS.
  • Your computer sends packets to that IP address.
  • The web server sends the response back to your IP address.

Without IP addresses, devices wouldn't know where to send or receive information.


3. Types of IP Addresses

1. IPv4

IPv4 is the older and most widely used version.

  • 32-bit address
  • Four decimal numbers separated by dots
  • Each number ranges from 0 to 255

Example:

192.168.1.10
 
172.16.0.5

Structure:

192 . 168 . 1 . 10
 ↑     ↑    ↑    ↑
8bit  8bit 8bit 8bit  = 32 bits total

Each section is called an octet.

Each address is split conceptually into two parts:

192.168.1.10
└─────┘ └──┘
Network   Host
 part     part
  • Network part — identifies which network the device belongs to.
  • Host part — identifies the specific device within that network.

Where this split happens is determined by the subnet mask.

Example in binary:

192 = 11000000 168 = 10101000 1 = 00000001 10 = 00001010

IP to Binary Converter


2. IPv6

IPv6 was introduced because IPv4 addresses were running out.

  • 128-bit address
  • Written in hexadecimal
  • Eight groups separated by colons

Rules that make them shorter to write:

  • Leading zeros in a group can be dropped: 0db8 → db8
  • One run of consecutive all-zero groups can be collapsed to :: (only once per address):

IPv6 exists mainly because IPv4's ~4.3 billion addresses aren't enough for all the devices in the world today.

Example:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

Shortened form:

2001:db8:85a3::8a2e:370:7334

4. Difference Between IPv4 and IPv6

FeatureIPv4IPv6
Full FormInternet Protocol Version 4Internet Protocol Version 6
Address Size32-bit128-bit
FormatDecimal (192.168.1.1)Hexadecimal (2001:db8::1)
Number of AddressesAbout 4.3 BillionAbout 3.4 × 10³⁸
SecurityIPSec OptionalIPSec Built-in
BroadcastSupportedNot Supported
ConfigurationManual or DHCPAuto Configuration or DHCPv6
Example192.168.1.12001:db8::1

5. Special IPv4 Addresses

AddressPurpose
127.0.0.1Loopback
0.0.0.0Unspecified/default route
255.255.255.255Broadcast
169.254.x.xAutomatic Private IP (APIPA)

6. IP Address Classes (Classful Addressing)

Older networking used five classes.

ClassFirst OctetDefault Mask
A1-126255.0.0.0
B128-191255.255.0.0
C192-223255.255.255.0
D224-239Multicast
E240-255Experimental

7. Subnet Mask

A subnet mask tells you how many bits belong to the network part vs. the host part.

It's often written in CIDR(Classless Inter-Domain Routing) notation (a slash followed by a number):

192.168.1.10/24

The /24 means the first 24 bits (3 full octets) are the network part, leaving the last 8 bits for hosts.

Example:

IP Address: 192.168.1.20   Subnet Mask: 255.255.255.0

This means:

Network: 192.168.1.0   Host: 20


8. Default Gateway

A default gateway is the router that forwards traffic to other networks.

Example:

Computer: 192.168.1.20   Gateway: 192.168.1.1

When the computer wants to reach a website on the internet, it sends the data to the gateway first.


9. Loopback Address

Used for testing the local machine.

IPv4: 127.0.0.1

Also called: localhost

It refers to your own computer.


10. Public IP vs Private IP Addresses

FeaturePublic IPPrivate IP
DefinitionUsed on the InternetUsed within a Local Network
Assigned ByInternet Service Provider (ISP)Router or DHCP Server
Internet AccessDirectly AccessibleNot Directly Accessible
UniquenessGlobally UniqueCan Be Reused
SecurityLess SecureMore Secure
Main UseWebsites, ServersHome and Office Networks
Example8.8.8.8192.168.1.10
  • Public IP — globally unique, routable across the internet. Assigned by your ISP.
  • Private IP — only unique within your local network (home, office). Not routable on the public internet.

Reserved Private Ranges (won't ever appear on the public internet)

  • 10.0.0.0 - 10.255.255.255
  • 172.16.0.0 - 172.31.255.255
  • 192.168.0.0 - 192.168.255.255

Private IP addresses are not directly reachable from the public internet.

Your home router uses NAT (Network Address Translation) to let many devices with private IPs share one public IP when talking to the internet.


11. Static IP vs Dynamic IP

FeatureStatic IPDynamic IP
DefinitionFixed IP AddressAutomatically Assigned IP Address
AssignmentManual ConfigurationDHCP Server
ChangesDoes Not ChangeChanges Automatically
CostUsually HigherUsually Lower
Best ForServers, CCTV, PrintersComputers, Smartphones
MaintenanceManualAutomatic
Example203.0.113.25192.168.1.25
  • Static IP — fixed IP address that remains constant over time. Common for servers.
  • Dynamic IP — automatically assigned by a DHCP server (usually your router) and may change over time. Most home devices use this.

Dynamic Host Configuration Protocol (DHCP)

It is a network management protocol used on Internet Protocol (IP) networks for automatically assigning IP addresses and other communication parameters to devices connected to the network using a client-server architecture.

This process simplifies connecting devices without the need for manual configuration.


12. How IP Addresses Work With MAC Addresses

When your device sends data:

  1. It checks if the destination IP is on the same network or a different network.
  2. If same network → uses ARP (Address Address Resolution Protocol) to find the destination's MAC address and sends directly.
  3. If different network → sends the data to the default gateway (your router), which forwards it onward.
You (192.168.1.10) → Router (192.168.1.1) → Internet → Destination server

The IP address gets the data to the right network; the MAC address gets it to the right device once it arrives.


13. MAC Address vs IP Address

FeatureMAC AddressIP Address
Full FormMedia Access Control AddressInternet Protocol Address
DefinitionA unique physical address assigned to a network interface card (NIC).A logical address assigned to identify a device on a network.
Address TypePhysical (Hardware) AddressLogical Address
Assigned ByDevice ManufacturerISP, Network Administrator, or DHCP Server
Address Length48-bit (6 Bytes)32-bit (IPv4) or 128-bit (IPv6)
FormatHexadecimal (00:1A:2B:3C:4D:5E)IPv4: 192.168.1.1
IPv6: 2001:db8::1
OSI LayerData Link Layer (Layer 2)Network Layer (Layer 3)
PurposeIdentifies a device within a local network.Identifies and locates a device across networks.
Can It Change?Usually No (can be spoofed)Yes, depending on network configuration.
UniquenessGlobally unique for each network interface.Unique within the network or Internet while assigned.
Main UseLocal communication between devices.Communication over local and external networks.
Example00:1A:2B:3C:4D:5E192.168.1.10

14. Key Takeaways

  • IP address: Identifies and locates a device on a network.
  • IPv4: 32-bit, e.g., 192.168.1.1.
  • IPv6: 128-bit, e.g., 2001:db8::1.
  • Public IP: Reachable on the internet.
  • Private IP: Used within local networks.
  • Static IP: Fixed address.
  • Dynamic IP: Assigned automatically by DHCP.
  • Subnet mask: Separates network and host portions.
  • Gateway: Router used to reach other networks.
  • Loopback: 127.0.
  • MAC address: Physical device address; IP address Logical network address.
MAC Address