M2 · Switching e LAN

Configuração prática de VLANs

VLANs segmentam uma rede lógica em broadcast domains distintos. Um switch não roteia tráfego entre VLANs diretamente — esse papel pertence ao roteador.

Topologia de referência

Três VLANs, três subredes /26, um roteador (R1) com uma interface física por VLAN:

VLAN Departamento Subrede Gateway
10 Engineering 10.0.0.0/26 10.0.0.62
20 HR 10.0.0.64/26 10.0.0.126
30 Sales 10.0.0.128/26 10.0.0.190

O gateway de cada subrede é o último endereço utilizável, configurado na interface do roteador correspondente.

Configuração do roteador (inter-VLAN routing)

Cada interface física do R1 pertence a uma VLAN. Configure o IP e ative a interface:

R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip address 10.0.0.62 255.255.255.192
R1(config-if)# no shutdown

R1(config)# interface GigabitEthernet0/1
R1(config-if)# ip address 10.0.0.126 255.255.255.192
R1(config-if)# no shutdown

R1(config)# interface GigabitEthernet0/2
R1(config-if)# ip address 10.0.0.190 255.255.255.192
R1(config-if)# no shutdown

Verifique com:

R1# show ip interface brief

Configuração do switch (access ports)

Atribuindo interfaces às VLANs

Use interface range para configurar múltiplas interfaces simultaneamente. Sempre declare switchport mode access explicitamente antes de atribuir a VLAN:

SW1(config)# interface range GigabitEthernet0/1, FastEthernet3/1, FastEthernet4/1
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 10

SW1(config)# interface range GigabitEthernet1/1, FastEthernet5/1, FastEthernet6/1
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 20

SW1(config)# interface range GigabitEthernet2/1, FastEthernet7/1, FastEthernet8/1
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 30

> Nota CCNA: ao atribuir uma VLAN inexistente a uma interface, o IOS cria a VLAN automaticamente.

Nomeando as VLANs

SW1(config)# vlan 10
SW1(config-vlan)# name engineering

SW1(config)# vlan 20
SW1(config-vlan)# name HR

SW1(config)# vlan 30
SW1(config-vlan)# name sales

Verificação

SW1# show vlan brief

A saída lista cada VLAN, seu nome e as interfaces membros — indispensável para confirmar a configuração no exame.

Fluxo de pacotes entre VLANs

Um ping de PC1 (VLAN 10) para PC3 (VLAN 20) percorre o seguinte caminho:

PC1 → SW1 → R1 (G0/0) → R1 (G0/1) → SW1 → PC3

O switch encaminha o frame ao roteador porque os dispositivos estão em VLANs diferentes. O roteador decide o próximo salto com base na tabela de roteamento e devolve o pacote ao switch na interface da VLAN de destino.

Broadcasts são confinados à VLAN: um broadcast enviado na VLAN 10 jamais alcança dispositivos nas VLANs 20 ou 30.

Pontos críticos para o exame

  • switchport mode access — define a porta como access (um único VLAN)
  • switchport access vlan — associa a porta à VLAN
  • show vlan brief — verifica membros e nomes de VLANs
  • Trunk ports (múltiplas VLANs por interface) são configurados com switchport mode trunk — tema da aula seguinte
  • Sem roteamento inter-VLAN, hosts em VLANs distintas não se comunicam, independentemente do endereçamento IP