Configure Virtual LANs to segment network traffic and create separate broadcast domains on a single switch.
Step 1: Create VLANs and assign names
1
2
3
4
5
6
7
8
9
10
11
|
SW1>enable
SW1#configure terminal
SW1(config)#vlan 10
SW1(config-vlan)#name Sales
SW1(config-vlan)#exit
SW1(config)#vlan 20
SW1(config-vlan)#name Marketing
SW1(config-vlan)#exit
SW1(config)#vlan 30
SW1(config-vlan)#name IT
SW1(config-vlan)#exit
|
Step 2: Assign access ports to VLANs
Configure specific switch ports to belong to individual VLANs for end devices like computers and printers.
1
2
3
4
5
6
7
8
9
10
11
12
13
|
SW1(config)#interface fastEthernet 0/1
SW1(config-if)#description Sales PC
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW1(config-if)#no shutdown
SW1(config-if)#exit
SW1(config)#interface range fastEthernet 0/2-5
SW1(config-if-range)#description Marketing Department
SW1(config-if-range)#switchport mode access
SW1(config-if-range)#switchport access vlan 20
SW1(config-if-range)#no shutdown
SW1(config-if-range)#exit
|
Step 3: Configure trunk ports
Set up trunk ports to carry multiple VLANs between switches or to routers.
1
2
3
4
5
6
|
SW1(config)#interface gigabitEthernet 0/1
SW1(config-if)#description Trunk to Router
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk allowed vlan 10,20,30
SW1(config-if)#no shutdown
SW1(config-if)#exit
|
Step 4: Configure management VLAN (optional)
Assign the switch management interface to a specific VLAN for remote access.
1
2
3
4
5
6
7
|
SW1(config)#interface vlan 30
SW1(config-if)#description Management Interface
SW1(config-if)#ip address 192.168.30.10 255.255.255.0
SW1(config-if)#no shutdown
SW1(config-if)#exit
SW1(config)#ip default-gateway 192.168.30.1
SW1(config)#end
|
Step 5: Verify the configuration
1
2
3
|
SW1#show vlan brief
SW1#show interfaces switchport
SW1#show interfaces trunk
|
Key Points:
- VLAN 1 is the default VLAN and cannot be deleted
- Access ports belong to one VLAN, trunk ports carry multiple VLANs
- Use
switchport trunk native vlan X to change the native VLAN from default VLAN 1
- Always verify VLAN assignments before connecting devices