스위치의 가상 랜(VLAN)설정은 하나의 스위치를 

여러개의 분리된 스위치 처럼 사용 가능 하도록 지원해 주는 기능입니다. 



1. 기본 정보 조회 


switch>en                                          <- enable 약자

Password:

switch# show interfaces status     <- 인터페이스 상태를 조회 

Port      Name               Status       Vlan       Duplex  Speed Type
Gi0/1                        notconnect   1            auto   auto 10/100/1000BaseTX
Gi0/2                        notconnect   1            auto   auto 10/100/1000BaseTX
Gi0/3                        notconnect   routed       auto   auto 10/100/1000BaseTX
Gi0/4                        notconnect   routed       auto   auto 10/100/1000BaseTX
Gi0/5                        notconnect   routed       auto   auto 10/100/1000BaseTX
... 중략 ... 
Te0/2                        notconnect   routed       full    10G 10GBase-SR
Fa0                          notconnect   routed       auto   auto 10/100BaseTX

'Gi' 는 gigabitEthernet 을 의미 하고, 'Fa'는 fastEthernet을 의미 합니다. 
사용중인 스위치 인터페이스 타입을 알아야 설정이 가능 하겠죠? 
포트들은 기본적으로 Vlan 1번에 포함되어 있습니다. 

switch#show vlan   <- vlan 현황 조회

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                                 active    Gi0/1, Gi0/2, Gi0/17, Gi0/26

Vlan1 번의 이름은 'default'이며, 기본적으로 포트들이 여기에 포함되어 있는걸 확인 할 수 있습ㄴ디ㅏ. 


2. vlan 생성 

switch#conf t                                                          <- configure terminal 약자 
switch(config)#vlan 2                                           <- vlan 2번을 생성  
switch(config-vlan)#name VLAN_NUM2          <- 이름은 'VLAN_NUM2' 라고 함
switch(config-vlan)#exit                                        <- 설정 저장하고 나가기 
switch(config)#exit                                                 <- 설정 저장하고 나가기 
switch#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                                 active    Gi0/1, Gi0/2, Gi0/17, Gi0/26
2    VLAN_NUM2                      active

VLAN 2번에 'VLAN_NUM2' 라는 이름으로 새로운 vlan이 생성된것을 확인 할 수 있습니다. 


3. vlan에 인터페이스 추가 

switch#conf t
switch(config)#interface gigabitEthernet 0/2     <- vlan에 포함 시킬 포트
switch(config-if)#switchport access vlan 2        <- vlan2에 등록 함 
switch(config-if)#exit
switch(config)#exit
switch#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                                 active    Gi0/1, Gi0/17, Gi0/26
2    VLAN_NUM2                      active    Gi0/2

VLAN2에 Gi0/2가 포함되어 있는게 보이시죠? 


4. vlan에 IP 주소 설정 

switch#conf t
switch(config)#interface vlan 2  
switch(config-if)#ip address 10.10.10.2 255.255.255.0         <- vlan2에 ip를 설정 함
switch(config-if)#no shutdown                                                    <- shutdown 앞에 'no'가 붙었으므로, 인터페이스를 살리라는 뜻. 
switch(config-if)#exit
switch(config)#exit
switch#show interfaces vlan 2                                                      <- vlan2의 정보 조회 

Vlan2 is up, line protocol is down
  Hardware is EtherSVI, address is 1c17.d3e5.c14e (bia 1c17.d3e5.c14e)
  Internet address is 10.10.10.2/24
  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
     reliability 255/255, txload 1/255, rxload 1/255
 .. 이하 생략 .. 

IP주소가 정상적으로 설정 된것을 볼 수 있습니다. 


5. vlan에 설정한 IP 주소 삭제
switch#conf t
switch(config)#interface vlan 2  
switch(config-if)#no ip address                              <- vlan2의 ip를 삭제 함
switch(config-if)#exit
switch(config)#exit
switch#show interfaces vlan 2                                <- vlan2의 정보 조회 

Vlan2 is up, line protocol is down
  Hardware is EtherSVI, address is 1c17.d3e5.c14e (bia 1c17.d3e5.c14e)
  MTU 1500 bytes, BW 1000000 Kbit, DLY 10 usec,
     reliability 255/255, txload 1/255, rxload 1/255
 .. 이하 생략 .. 

IP주소가 정상적으로 제거 된것을 볼 수 있습니다. 


6. vlan 삭제 

switch#conf t
switch(config)#no vlan 2                     <- vlan2 를 삭제함 (cisco 스위치는 앞에 'no'를 붙이면 제거/삭제 의 의미를 가짐)
switch(config)#exit
switch#show interfaces status

Port      Name               Status       Vlan       Duplex  Speed Type
Gi0/1                        notconnect      1            auto   auto 10/100/1000BaseTX
Gi0/2                        notconnect      2            auto   auto 10/100/1000BaseTX

이상하게도.. vlan2를 지웠는데 
2번 포트는 여전히 Vlan 2에 포함되어있다고 나옵니다. 
default vlan으로 돌아가게 하고 싶다면 아래 명령을 수행해야 합니다. 


7. vlan에 등록했던 인터페이스 제거 

switch#conf t
switch(config)#interface gigabitEthernet 0/2                     <- vlan에서 제거할 포트 
switch(config-if)#no switchport access vlan 2                  <- vlan2 에서 제거 
switch(config-if)#exit
switch(config)#exit
switch#show inter status

Port      Name               Status       Vlan       Duplex  Speed Type
Gi0/1                        notconnect      1            auto   auto 10/100/1000BaseTX
Gi0/2                        notconnect      1            auto   auto 10/100/1000BaseTX
Posted by KT한
,