[Day 9] 5. Virtual Local Area Network (VLAN)
Introduction
A VLAN creates logical partitions within a physical switch, allowing for better traffic management, security, and network organization. By segmenting networks, VLANs reduce broadcast domains and help optimize network performance.
-
Concurrent Sessions: A VLAN supports up to 16 Telnet sessions simultaneously, enabling multiple remote connections to the switch.
-
VLAN Numbering: VLANs are typically numbered from 1 to 1005, but VLANs 1002 to 1005 are reserved for system use. VLANs 1 to 1001 are available for regular configuration, and extended VLANs can go up to 4096.
-
Default VLAN: The default VLAN on a switch is VLAN 1, often referred to as the Management, Parent, or Untagged VLAN, and it is used for general switch management tasks.
Configuration of VLAN 1
-
Power on the switch:
switch> on -
Enter global configuration mode:
switch# conf t -
Enter the interface configuration mode for VLAN 1:
switch(config)# int vlan1 -
Enable the interface (bring it up):
switch(config-if)# no shut -
Assign an IP address and subnet mask to VLAN 1:
switch(config-if)# ip address 172.16.100.10 255.255.255.0 -
Exit interface configuration mode:
switch(config-if)# exit -
Set the default gateway for the switch:
switch(config)# ip default-gateway 172.16.10.1 -
Enter interface configuration mode for a physical port (e.g., fa1/0):
switch(config)# int fa1/0
(This is the switch port configuration) -
Configure port security by setting a MAC address:
switch(config-if)# switchport port-security mac-address <MAC address>- Note: Instead of using a static MAC address, the keyword can be used to automatically learn and assign the MAC address to the port, making it permanent.
sticky
switch(config-if)# switchport port-security mac-address sticky
- Note: Instead of using a static MAC address, the
-
Set the violation action to shutdown if an unauthorized device tries to access the port:
switch(config-if)# switchport port-security violation shutdown- Explanation: If a device with an unknown MAC address attempts to connect, the port will shut down automatically and will only be re-enabled by an administrator.
Configuration for Multiple Ports at Once
-
To configure a range of ports (e.g., fa1/0 to fa1/8):
switch(config)# int range fa1/0 - 8 -
Apply port security with the
MAC address option to all selected ports:sticky
switch(config-if)# switchport port-security mac-address sticky -
Set the violation action to shutdown for all selected ports:
switch(config-if)# switchport port-security violation shutdown
Steps to Configure VLANs
-
Create a new VLAN:
switch(config)# vlan2 -
Assign a name to the VLAN:
switch(config-vlan)# name sales -
Exit VLAN configuration mode:
switch(config-vlan)# exit -
Create another VLAN:
switch(config)# vlan3 -
Assign a name to the second VLAN:
switch(config-vlan)# name purchase -
Exit VLAN configuration mode:
switch(config-vlan)# exit -
To allocate ports to a VLAN, select an interface:
switch(config)# int fa1/1 -
Assign the port to VLAN 2:
switch(config-if)# switchport access vlan 2
Alternatively, you can use the range command to configure multiple ports at once:
-
Select a range of ports:
switch(config)# int range fa1/1-8 -
Assign the selected ports to VLAN 2:
switch(config-if-range)# switchport access vlan 2
Read Next
[Day 9] 6. VTP (VLAN Trunking Protocol)
**VLAN Trunking Protocol (VTP)** is a Cisco proprietary protocol developed by Cisco Systems. **Definition & Purpose:** VTP (VLAN Trunking Protocol)...
[Day 9] 7. Inter-VLAN Connection
### **Inter-VLAN Routing (Router-on-a-Stick Configuration)** **Explanation:** Inter-VLAN routing is necessary when devices in different VLANs ne...