Kali DragonNETMASTER
OP
moduł / ipv4

Nauka adresowania IPv4

Klasy, maski, CIDR, podsieci, broadcast i hosty — z wizualizacją na poziomie bitów.

IPv4 Basics

An IPv4 address is 32 bits, written as 4 octets (0–255) separated by dots: 192.168.1.10. Each octet = 8 bits.

Every device on an IP network needs a unique address + a subnet mask that tells the network portion vs the host portion.

Total IPv4 space = 2³² ≈ 4.29 billion addresses. Due to exhaustion, IPv6 and NAT (Network Address Translation) are widely used.

Address Classes

Class A0.0.0.0 – 126.255.255.255 — /8 default
Class B128.0.0.0 – 191.255.255.255 — /16 default
Class C192.0.0.0 – 223.255.255.255 — /24 default
Class D224.0.0.0 – 239.255.255.255 — Multicast
Class E240.0.0.0 – 255.255.255.255 — Reserved
Loopback127.0.0.0/8 — local host
Private A10.0.0.0/8
Private B172.16.0.0/12
Private C192.168.0.0/16
APIPA169.254.0.0/16 — link-local

CIDR & Subnet Masks

CIDR (Classless Inter-Domain Routing) writes the prefix length after a slash, e.g. /26 = first 26 bits are network.

Mask /24 = 255.255.255.0 → 256 addresses, 254 usable hosts.

Formula: usable hosts = 2^(32 − prefix) − 2.

Wildcard mask = inverse of subnet mask (used in ACLs): /24 → 0.0.0.255.

Binary System

Computers store IP addresses in binary (base‑2). Each octet has 8 bits with weights:

128 · 64 · 32 · 16 · 8 · 4 · 2 · 1

To convert a decimal octet → binary, subtract the largest power of 2 that fits, mark 1, repeat with the remainder, mark 0 when a weight doesn't fit.

Example: 192 = 128 + 64 → 11000000.

Bitwise operations

The router determines the network address using bitwise AND between the IP and the mask. Truth table:

AND
0 AND x = 0
1 AND 1 = 1
OR
1 OR x = 1
0 OR 0 = 0
XOR
a XOR a = 0
a XOR 0 = a
NOT
NOT 0 = 1
NOT 1 = 0

OR is used to build broadcast; NOT builds the wildcard mask.

Subnetting & VLSM

Subnetting = borrowing host bits to create more, smaller networks. Each borrowed bit doubles the number of subnets and halves the hosts.

VLSM (Variable Length Subnet Masks) lets you assign different prefix lengths per subnet to avoid wasting addresses — start with the LARGEST subnet first.

/24 → 1×256 (254 hosts)
/25 → 2×128 (126 hosts)
/26 → 4×64 (62 hosts)
/27 → 8×32 (30 hosts)
/30 → 64×4 (2 hosts — P2P links)

Interaktywny kalkulator podsieci

Adres sieci
192.168.1.128
Broadcast
192.168.1.191
Pierwszy host
192.168.1.129
Ostatni host
192.168.1.190
Maska podsieci
255.255.255.192 (/26)
Wildcard
0.0.0.63
Hosty użyteczne
62
Klasa
C · prywatny
Wszystkich adresów
64
IP binarnie (bity sieci podświetlone)
11000000.10101000.00000001.10000010
Maska podsieci binarnie
11111111.11111111.11111111.11000000

Decimal → Binary (octet 192)

WeightBitStep
1281192 ≥ 128 → mark 1, remainder 64
64164 ≥ 64 → mark 1, remainder 0
3200 < 32 → 0
1600 < 16 → 0
800 < 8 → 0
400 < 4 → 0
200 < 2 → 0
100 < 1 → 0
192 = 11000000₂

Binary → Decimal (10101100)

WeightBitStep
1281+128
640+0
321+32
160+0
81+8
41+4
20+0
10+0
10101100₂ = 172

Interactive Binary ↔ Decimal Converter

Binary result:
10101100
Decimal result:
172

Bitwise operations on IP addresses

AND — Network address
IP 192.168.10.130
11000000.10101000.00001010.10000010
Mask /26 = 255.255.255.192
11111111.11111111.11111111.11000000
Network = 192.168.10.128
11000000.10101000.00001010.10000000
OR — Broadcast address
Network 192.168.10.128
11000000.10101000.00001010.10000000
Wildcard 0.0.0.63
00000000.00000000.00000000.00111111
Broadcast = 192.168.10.191
11000000.10101000.00001010.10111111
NOT — Wildcard from mask
Mask /26 = 255.255.255.192
11111111.11111111.11111111.11000000
(invert each bit)
—
Wildcard = 0.0.0.63
00000000.00000000.00000000.00111111
XOR — Differing bits
172.16.5.10
10101100.00010000.00000101.00001010
172.16.5.42
10101100.00010000.00000101.00101010
Diff = 0.0.0.32
00000000.00000000.00000000.00100000