CCNA Vlan


VLAN singifica Virutal Local Area Network, trata-se de uma segmentação lógica da camada 2 (LAN).

VLAN

VLAN segmenta uma LAN em LANs virtuais aumentando assim número do domínio de broadcast, porém um dispositivo camada 3 deve existir para permitir que uma VLAN fale com a outra.

Diferentemente do arquivo de configuração - que armazena as configurações do dispositivo na NVRAM - as informações e configurações das VLANs, excluindo o relacionamento de portas pois o mesmo é realizado na interface, fica num arquivo chamado vlan.dat, portanto se quiser apagar as informações de VLANs é necessário apagar esse arquivo

Switch>enable
Switch#show flash
Directory of flash:/

    1  -rw-     3058048          <no date>  c2950-i6q4l2-mz.121-22.EA4.bin
    2  -rw-         676          <no date>  vlan.dat

64016384 bytes total (60957660 bytes free)
Switch#

Como funciona

Quando um switch aprende um endereço MAC ele faz a seguinte associação em uma tabela chamada de CAM (content addressable memory) ou tabela MAC:

Associação de VLAN

Repare o campo chamado VLAN com o valor 1, você nunca soube mas essa relação sempre aconteceu, o switch, quando aprende um endereço mac, associa uma VLAN a um endereço MAC, e foi feito para apenas comutar quadros para endereços associados a mesma VLAN. Portanto um switch layer 2 (camada 2) pode criar várias VLANs para impedir que parte do tráfego da rede possa ser comutado (enviado) para certar postas.

A configuração de VLAN é feita através de uma associação de portas a uma VLAN, lembrando que quando falamos VLAN estamos nos referindo a simplesmente um número que pode variar de 1 a 1001 dependendo apenas da sua vontade ou necessidade, sendo as VLAN’s 1002, 1003, 1004 e 1005 reservadas.

A VLAN padrão é a 1 e não é possível removê-la, todas as portas são associadas a VLAN 1, se todas as portas estão associadas a mesma VLAN é possível usar todas as portas sem nenhum problema (o que sempre foi feito).

Não é possível descobrir em qual VLAN uma interface está apenas analisando o tráfego, pois não há informações de VLAN em portas do tipo acesso; portas onde computadores se conectam no switch.

Modos de comutação de porta de um switch

Para encaminhar o tráfego o switch camada 2 possui 2 estados de portas para comutação:

  • modo de acesso (mode access)
  • modo trunk (mode trunk)

Para mais informações consulte Cisco Switch DTP

Modo de acesso

Uma porta no modo de acesso pode ser associada a uma única VLAN de dados e a uma única VLAN de voz, é o tipo de porta que permite que um computador envie e receba tráfegos normalmente

Configurando uma porta como acesso

Switch>enable
Switch#configure terminal
Switch(config)#interface FastEthernet 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1

Para mais informações consulte Cisco Switch DTP

Modo trunk

Uma porta trunk trabalha, normalmente, com um encapsulamento um pouco diferente do Ethernet (802.3), trabalha com o encapsulamento de VLAN chamado dot1q - (802.1q). O padrão IEEE 802.1q modifica um pouco o quadro Ethernet inserindo um espaço para os campos que incluam informações de VLAN. Portanto apenas nos links trunk as informações de VLAN’s podem ser visualizados pois o switch insere a tag da VLAN nela.

Configurando uma porta como trunk

Switch>enable
Switch#configure terminal
Switch(config)#interface FastEthernet 0/1
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk allowed vlan all

Para que exista tráfego entre as VLAN’s um link tronco deve ser configurado com o dispositivo camada 3 que irá rotear o tráfego entre as mesmas. Para mais informações consulte Cisco Switch DTP

Configurando VLANS

Não há muito para se fazer quanto a configuração de VLANs, há simplesmente as seguintes tarefas:

* Criar uma VLAN
* Associar portas a VLAN
* Selecionar quais VLAN's podem passar pelo Link trunk

Criando VLANs

Existem 3 modos de se criar uma VLAN

Modo fácil - Entrando no VLAN database (não recomendado, mas funcional)

Switch>enable
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
  as VLAN database mode is being deprecated. Please consult user
  documentation for configuring VTP/VLAN in config mode.

Switch(vlan)#vlan 2 name Dados
VLAN 2 added:
    Name: Dados
Switch(vlan)#vlan 3
VLAN 3 added:
    Name: VLAN0003
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#

Modo muito fácil - Entrando no modo de configuração global

Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 4
Switch(config-vlan)#name RH
Switch(config-vlan)#exit
Switch(config)#vlan 5
Switch(config-vlan)#exit
Switch(config)#

Modo facílimo - Associar uma porta a uma VLAN que não existe

Switch>enable
Switch#configure terminal
Switch(config)#interface fastethernet 0/2
Switch(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
Switch(config-if)#end
Switch#
%SYS-5

Associar Portas a VLAN

Como já foi visto, não é necessário criar uma VLAN para associar uma VLAN a uma interface, quando se digita o comando de associação o switch irá verificar se a VLAN existe, se ela não existir ele ira criá-la, mas no exemplo abaixo seguiremos as boas práticas:

Switch>enable
Switch#configure terminal
Switch(config)#vlan 10
Switch(config-vlan)#name Lab01
Switch(config-vlan)#exit
Switch(config)#interface FastEthernet 0/15
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 10

Verificando a configuração de VLANs

Basta digitar o comando show vlan no modo EXEC privilegiado

Switch#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/1, Fa0/3, Fa0/4, Fa0/5
                                                Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24
2    Dados                            active    
3    VLAN0003                         active    
4    RH                               active    
5    VLAN0005                         active    
10   Lab01                            active    Fa0/2, Fa0/15
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

Para selecionar as vlans permitidas pelo link trunk serão necessários duas coisas:

  • Configurar mais de uma VLAN
  • Configurar pelo menos uma porta como TRUNK

Configurando algumas vlans:

Switch>enable
Switch#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#vlan 4
Switch(config-vlan)#exit
Switch(config)#vlan 5
Switch(config-vlan)#exit
Switch(config)#

Configurando uma interface como trunk:

Switch(config)#interface FastEthernet 0/24
Switch(config-if)#switchport mode trunk

Selecionando as VLAN’s que irão poder passar nesse por essa interface

Switch(config-if)#switchport trunk allowed vlan 1
Switch(config-if)#switchport trunk allowed vlan add 2
Switch(config-if)#switchport trunk allowed vlan add 3

Permitindo todas

switchport trunk allowed vlan all

Verificando as interfaces trunk

Basta digitar o seguitne comando

Switch#show interfaces trunk 
Port        Mode         Encapsulation  Status        Native vlan
Fa0/23      on           802.1q         trunking      1
Fa0/24      on           802.1q         trunking      1

Port        Vlans allowed on trunk
Fa0/23      1-1005
Fa0/24      1-3

Port        Vlans allowed and active in management domain
Fa0/23      1,2,3,4,5,10,106,1001
Fa0/24      1,2,3

Port        Vlans in spanning tree forwarding state and not pruned
Fa0/23      1,2,3,4,5,10,106,1001
Fa0/24      1,2,3

Apagando VLANs

Para apagar uma VLAN basta digitar o comando NO antes do comando de criação

Switch>enable
Switch#configure terminal
Switch(config)#no vlan 2
Switch(config)#no vlan 3

É necessário muita atenção para apagar uma VLAN, ao apagar uma VLAN que está associada a N portas fará com que as portas parem de realizar a comutação (encaminhamento) de quadros, mesmo com seu status permanecendo up/up:

Criando VLANs e associando-as a portas

Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#interface range FastEthernet 0/1-9
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 2
Switch(config-if-range)#exit
Switch(config)#interface range FastEthernet 0/10-20
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 3
Switch(config-if-range)#end

Verificando a associação das VLANs criadas

Switch#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/21, Fa0/22, Fa0/23, Fa0/24
2    VLAN0002                         active    Fa0/1, Fa0/2, Fa0/3, Fa0/4
                                                Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                Fa0/9
3    VLAN0003                         active    Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
2    enet  100002     1500  -      -      -        -    -        0      0
3    enet  100003     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------

Apagando as VLANS

Switch#configure terminal
Switch(config)#no vlan 2
Switch(config)#no vlan 3
Switch(config)#end

Verificando a associação das VLANs apagadas

Switch#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/21, Fa0/22, Fa0/23, Fa0/24
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0
1002 fddi  101002     1500  -      -      -        -    -        0      0   
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------


Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------

Como podemos ver, as portas associadas as VLANs apagadas não ficam atribuídas a VLAN alguma, portanto não poderão encaminhar tráfego embora seu status seja up/up:

witch#sh int f0/1
FastEthernet0/1 is up, line protocol is up (connected)
  Hardware is Lance, address is 0000.0c96.9e01 (bia 0000.0c96.9e01)

VLAN Nativa

A VLAN nativa é uma VLAN especial que não será tageada no pelo link trunk, o switch já sabe que VLANs que não tiverem tags pertencem a VLAN nativa. Se a VLAN nativa for diferente em algum switch da rede ou em um dispositivo camada 3 que participa o processo de roteamento interVLAN parte do tráfego não será encaminhado

Por padrão a VLAN 1 é a VLAN nativa Apenas portas trunk podem ter uma VLAN nativa

Verificando qual é a VLAN nativa

Switch#show interfaces f0/24 switchport 
Name: Fa0/24
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: down
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: native
Negotiation of Trunking: On
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Voice VLAN: none

Configurando uma VLAN nativa

Switch>ena
Switch#configure terminal
Switch(config)#vlan 50
Switch(config-vlan)#exit
Switch(config)#interface FastEthernet 0/24
Switch(config-if)#switchport mode trunk
Switch(config-if)#switchport trunk native vlan 50
Switch(config-if)#

Veja também

Category:Cisco Category:CCNA Category:Switch Category:CiscoCCNA