How to Create and Configure VLANs on a Cisco Switch

Creating a VLAN system on a Cisco switch involves setting up VLANs, assigning ports to these VLANs, and ensuring proper communication between VLANs if necessary. Here’s a step-by-step guide on how to achieve this:
Example Scenario:
- Switch Model: Cisco Catalyst 2960 Series
- VLANs to Configure: VLAN 10 (Sales), VLAN 20 (Marketing)
- Inter-VLAN Routing: Optional, requires a Layer 3 device or router on a stick configuration
Configuration Steps:
Step 1: Access the Switch
- Connect to the Switch:
- Use console, SSH, or Telnet to connect to the switch.
- Enter Privileged EXEC Mode:
enable
- Enter Global Configuration Mode:
configure terminal
Step 2: Create VLANs
- Create VLAN 10 for Sales:
vlan 10
name Sales
exit
- Create VLAN 20 for Marketing:
vlan 20
name Marketing
exit
Step 3: Assign Ports to VLANs
- Assign Port FastEthernet 0/1 to VLAN 10:
interface fastethernet0/1
switchport mode access
switchport access vlan 10
exit
- Assign Port FastEthernet 0/2 to VLAN 20:
interface fastethernet0/2
switchport mode access
switchport access vlan 20
exit
Step 4: Configure Trunk Ports (if necessary)
If you have multiple switches or need to route traffic between VLANs, configure a trunk port.
- Configure Trunk Port on FastEthernet 0/24:
interface fastethernet0/24
switchport mode trunk
switchport trunk allowed vlan 10,20
exit
Step 5: Inter-VLAN Routing (Optional)
If inter-VLAN routing is needed, it requires a Layer 3 device. Here, we assume a “router on a stick” configuration using a router.
- On the Router:
interface fastethernet0/0.10
encapsulation dot1q 10
ip address 192.168.10.1 255.255.255.0
exit
interface fastethernet0/0.20
encapsulation dot1q 20
ip address 192.168.20.1 255.255.255.0
exit
Step 6: Verify Configuration
- Verify VLANs on the Switch:
show vlan brief
- Verify Trunk Ports:
show interfaces trunk
- Verify VLAN Assignment to Ports:
show interfaces switchport
- Verify Inter-VLAN Routing (on the Router):
show ip interface brief
Complete Example Script
Here is a complete script that combines all the steps above:
enable
configure terminal
vlan 10
name Sales
exit
vlan 20
name Marketing
exit
interface fastethernet0/1
switchport mode access
switchport access vlan 10
exit
interface fastethernet0/2
switchport mode access
switchport access vlan 20
exit
interface fastethernet0/24
switchport mode trunk
switchport trunk allowed vlan 10,20
exit
end
write memory
Verification Commands
show vlan brief
show interfaces trunk
show interfaces switchport
Summary
This setup ensures that VLANs are properly configured and verified on a Cisco switch. Inter-VLAN routing configuration is optional and only necessary if you need VLANs to communicate with each other. Following these steps will help you effectively manage and segment your network traffic, enhancing both security and performance.