Subnetting y CIDR en profundidad
Domine la máscara de subred de longitud variable y la notación CIDR para planificar el espacio de direcciones, calcular rangos y agregar rutas de forma eficiente.
Subnetting y CIDR en profundidad es una lección gratuita de Linux Networking & TCP/IP for Developers en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Linux Networking & TCP/IP for Developers, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Linux Networking & TCP/IP for Developers incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Why Subnetting Matters
Subnetting splits a large network into smaller, manageable segments. It improves security, performance, and address efficiency.
CIDR (Classless Inter-Domain Routing) replaced rigid class A/B/C boundaries with flexible prefix lengths.
CIDR Notation
A CIDR block is written as address/prefix. The prefix counts the number of leading network bits.
192.168.1.0/24— 24 network bits, 8 host bits10.0.0.0/8— 8 network bits, 24 host bits
The Subnet Mask
A prefix maps directly to a dotted-decimal mask.
/24= 255.255.255.0/26= 255.255.255.192/30= 255.255.255.252
Each set bit in the mask is a network bit.
Counting Hosts
Host count = 2^(host bits) minus 2 (network and broadcast addresses).
/24-> 2^8 - 2 = 254 hosts/26-> 2^6 - 2 = 62 hosts/30-> 2^2 - 2 = 2 hosts (perfect for point-to-point links)
Finding the Network Address
Bitwise-AND the IP with the mask to get the network address. The example below computes it in Python.
import ipaddress
net = ipaddress.ip_network('192.168.5.130/26', strict=False)
print('network:', net.network_address)
print('broadcast:', net.broadcast_address)Determining the Range
For 192.168.5.130/26: block size is 64, so subnets start at .0, .64, .128, .192.
The .130 address falls in the 192.168.5.128/26 subnet (usable .129 to .190, broadcast .191).
Variable-Length Subnet Masking (VLSM)
VLSM lets different subnets use different prefix lengths from one block, matching size to need.
Allocate largest subnets first to avoid fragmentation and wasted address space.
Route Aggregation (Supernetting)
Adjacent subnets can be summarized into one larger prefix, shrinking routing tables.
192.168.0.0/24+192.168.1.0/24->192.168.0.0/23
Aggregation only works when blocks are contiguous and aligned.
Subnetting with Python
The ipaddress module can split a network into smaller subnets automatically.
import ipaddress
big = ipaddress.ip_network('10.0.0.0/24')
for sub in big.subnets(new_prefix=26):
print(sub)Checking Membership
Verify whether an address belongs to a network — essential for ACLs and routing decisions.
import ipaddress
addr = ipaddress.ip_address('10.0.0.45')
net = ipaddress.ip_network('10.0.0.0/26')
print(addr in net)Common Pitfalls
Watch out for:
- Forgetting to subtract network and broadcast addresses
- Misaligned aggregation that overlaps other blocks
- Using
/31links (valid per RFC 3021 for point-to-point) without device support
Quick Check
Test your subnetting math.
Recap
You can now plan address space confidently:
- Read and convert CIDR prefixes and masks
- Calculate network, broadcast, and host ranges
- Apply VLSM to size subnets to need
- Aggregate contiguous blocks to shrink routing tables
- Use Python's
ipaddressmodule for verification
This underpins the IPv6, routing, and NAT topics in this course.
Preguntas frecuentes
¿La lección «Subnetting y CIDR en profundidad» es gratis?
Sí — el texto completo de «Subnetting y CIDR en profundidad» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Linux Networking & TCP/IP for Developers, actualiza a CoddyKit PRO. El curso de Linux Networking & TCP/IP for Developers incluye 4 lecciones en total.
¿Qué aprenderé en «Subnetting y CIDR en profundidad»?
Domine la máscara de subred de longitud variable y la notación CIDR para planificar el espacio de direcciones, calcular rangos y agregar rutas de forma eficiente. Practicas Linux Networking & TCP/IP for Developers con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Linux Networking & TCP/IP for Developers?
No se requiere experiencia previa. Linux Networking & TCP/IP for Developers en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Subnetting y CIDR en profundidad»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Linux Networking & TCP/IP for Developers?
Sí. Cada lección de Linux Networking & TCP/IP for Developers incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Direccionamiento y conceptos de IPv6
- Protocolos de enrutamiento avanzados (RIP/OSPF)
- Traducción de direcciones de red (NAT)
- Subnetting y CIDR en profundidad