Skip to content

🌐 01-04: IPv4 Addressing Basics


📌 What Is an IP Address?

An IP Address (Internet Protocol Address) uniquely identifies a device on a network.

  • Works like a home address for devices
  • Used for communication between devices
  • Example: 192.168.1.1

Without IP addresses, packets would have no way to know where to go or where they came from — every device that wants to send or receive traffic needs one.


🔹 IPv4 vs. IPv6 (Quick Comparison)

  • IPv4 — 32-bit addresses, written as 4 decimal octets (192.168.1.1). Still the most common on most networks today.
  • IPv6 — 128-bit addresses, written as 8 hexadecimal blocks (2001:0db8:85a3:0000:0000:8a2e:0370:7334). Created because the world ran out of IPv4 addresses.

This lesson focuses on IPv4; see 01-06: IPv6 Basics & Security for the IPv6 deep dive.


🔹 IPv4 Address Structure

An IPv4 address consists of:

  • 32 bits total
  • Divided into 4 octets (8 bits each)
  • Written in dotted-decimal format

Example: 192.168.60.5

Binary representation: 11000000.10101000.00111100.00000101

Each octet ranges from 0 to 255 (since 8 bits gives 2⁸ = 256 possible values).


🔹 Network ID vs. Host ID

Every IP address has two logical parts:

Part Description
Network ID Identifies which network the device is on
Host ID Identifies which device on that network

Example: 192.168.60.5/24

  • /24 → the first 24 bits are the network portion
  • The remaining 8 bits are the host portion

This is exactly why two devices need to be on the "same network" (same network ID) to talk directly to each other without a router in between.


🔹 Subnet Mask (The Concept)

A subnet mask is how a computer knows where the network part ends and the host part begins. It's a 32-bit pattern of 1s and 0s laid over the IP address:

  • 1 bits → network portion
  • 0 bits → host portion

Example: /2211111111.11111111.11111100.00000000255.255.252.0

💡 Trick worth memorizing: - Network ID → set all host bits to 0 - Broadcast ID → set all host bits to 1

The full math for calculating ranges from a subnet mask is covered in 01-05: IPv4 Subnetting & CIDR.


🔒 Special IP Addresses

Private IP Ranges

Reserved for use inside private networks — never routed on the public internet.

Range CIDR
10.0.0.0 – 10.255.255.255 10.0.0.0/8
172.16.0.0 – 172.31.255.255 172.16.0.0/12
192.168.0.0 – 192.168.255.255 192.168.0.0/16

Public vs. Private IP

Type Description
Public IP Globally unique, routable on the internet
Private IP Used inside local networks only, not routable

💡 Private IPs need NAT (Network Address Translation) on a router/firewall to reach the internet — this is also a security benefit, since internal hosts aren't directly reachable from the outside.

Loopback Address

The loopback address refers to the device itself (localhost):

  • Range: 127.0.0.0/8
  • Most common: 127.0.0.1
  • Packets sent here never leave the device — useful for testing local services.

⚙️ Static vs. Dynamic IP

Type Description
Static IP Manually assigned, does not change
Dynamic IP Assigned automatically by DHCP, may change over time

💡 Most home and enterprise client devices use dynamic IPs (via DHCP); servers and network infrastructure usually get static IPs so they can always be found at the same address.


🔍 Viewing and Assigning an IP (Linux)

View current addresses:

ip address
# or, a shorter table view:
ip -br addr

Manually assign an IP:

sudo ip addr add 192.168.60.6/24 dev enp0s3

Automatic assignment (DHCP = Dynamic Host Configuration Protocol) hands out an IP address, subnet mask, and default gateway without any manual steps — a DHCP client on the host requests this configuration from a DHCP server on the network.


⚠️ Why Addressing Matters for Security

Nearly every network attack in this course depends on IP addressing in some way:

  • Spoofing (Module 03/04) forges the source IP address in a packet.
  • Firewalls (Module 05) filter traffic based on source/destination IP.
  • DNS (Module 06) exists specifically to map names to IP addresses.
  • VPNs (Module 08) create a private, tunneled IP space over the public internet.

Understanding addressing well is the foundation everything else in this course builds on.


📌 Key Takeaways

  • An IP address uniquely identifies a device for communication.
  • IPv4 = 32-bit address, 4 octets, dotted-decimal notation.
  • Every address has a Network ID portion and a Host ID portion, split by the subnet mask/prefix length.
  • Network ID = all host bits 0; Broadcast ID = all host bits 1.
  • Private IP ranges (10/8, 172.16/12, 192.168/16) require NAT to reach the internet.
  • 127.0.0.1 is the loopback address — traffic never leaves the device.
  • DHCP automates IP configuration; static IPs are set by hand.