0Pricing
Linux Networking & TCP/IP for Developers · Aula

Sub-redes e CIDR em profundidade

Domine a máscara de sub-rede de comprimento variável e a notação CIDR para planejar o espaço de endereços, calcular intervalos e agregar rotas com eficiência.

Sub-redes e CIDR em profundidade é uma aula grátis de Linux Networking & TCP/IP for Developers no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Linux Networking & TCP/IP for Developers, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Linux Networking & TCP/IP for Developers inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em 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 bits
  • 10.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 /31 links (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 ipaddress module for verification

This underpins the IPv6, routing, and NAT topics in this course.

Perguntas Frequentes

A aula “Sub-redes e CIDR em profundidade” é grátis?

Sim — o texto completo de “Sub-redes e CIDR em profundidade” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Linux Networking & TCP/IP for Developers, atualize para CoddyKit PRO. O curso de Linux Networking & TCP/IP for Developers inclui 4 aulas no total.

O que vou aprender em “Sub-redes e CIDR em profundidade”?

Domine a máscara de sub-rede de comprimento variável e a notação CIDR para planejar o espaço de endereços, calcular intervalos e agregar rotas com eficiência. Você pratica Linux Networking & TCP/IP for Developers com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Linux Networking & TCP/IP for Developers?

Nenhuma experiência prévia é necessária. Linux Networking & TCP/IP for Developers no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Sub-redes e CIDR em profundidade”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Linux Networking & TCP/IP for Developers?

Sim. Cada aula de Linux Networking & TCP/IP for Developers inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Endereçamento e Conceitos de IPv6
  2. Protocolos Avançados de Roteamento (RIP/OSPF)
  3. Tradução de Endereços de Rede (NAT)
  4. Sub-redes e CIDR em profundidade
← Voltar para Linux Networking & TCP/IP for Developers