CCNA Networking Mastery
VLAN Segmentation
From Flat to Segmented Networks
Imagine an office building where every department—Sales, HR, Engineering—shares one single, open-plan floor. Everyone can hear everyone else's conversations. Confidential HR documents are left on desks next to sales reports. This is a flat network. All devices are in the same broadcast domain, meaning a message sent by one device is heard by all others. This creates noise, slows down performance, and is a security nightmare.
Virtual Local Area Networks, or VLANs, are the solution. They act like virtual walls, logically dividing a single physical switch into multiple, isolated broadcast domains. It’s like giving each department its own secure floor in the office building, even though they all still use the same physical infrastructure. Devices in VLAN 10 (Sales) can't directly communicate with devices in VLAN 20 (HR) without a router to direct the traffic between them.
VLANs are used to logically segment a physical network into multiple isolated broadcast domains, while subnets are divisions of an IP network that group together devices based on their IP addresses, facilitating efficient routing and network management.
This segmentation drastically reduces unnecessary broadcast traffic and contains security threats. An issue on the Engineering VLAN won't bring down the Sales network. This isolation is the foundation of modern network design.
Configuring and Verifying VLANs
On a Cisco switch, creating VLANs is straightforward. You enter global configuration mode and use the vlan command. Let's create two VLANs: one for Sales and one for Human Resources.
Switch> enable
Switch# configure terminal
Switch(config)# vlan 10
Switch(config-vlan)# name Sales
Switch(config-vlan)# exit
Switch(config)# vlan 20
Switch(config-vlan)# name HR
Switch(config-vlan)# end
Now that the VLANs exist on the switch, we need to assign switch ports to them. These are called 'access ports', as they provide network access to end-user devices like laptops and printers. An access port belongs to only one data VLAN.
Switch# configure terminal
Switch(config)# interface FastEthernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# exit
Switch(config)# interface FastEthernet0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 20
Switch(config-if)# end
In this example, any device plugged into port FastEthernet0/1 is now in the Sales VLAN, and any device in FastEthernet0/2 is in the HR VLAN. To confirm our work, we use the show vlan brief command. This gives a quick overview of all VLANs and which ports are assigned to them.
| VLAN | Name | Status | Ports |
|---|---|---|---|
| 1 | default | active | Fa0/3, Fa0/4, Fa0/5, Fa0/6... |
| 10 | Sales | active | Fa0/1 |
| 20 | HR | active | Fa0/2 |
| 1002 | fddi-default | act/unsup | |
| 1003 | token-ring-default | act/unsup | |
| 1004 | fddinet-default | act/unsup | |
| 1005 | trnet-default | act/unsup |
Connecting Switches with Trunks
What happens when you have more devices than ports on a single switch? You add another switch. But how do you extend your VLANs across this new switch? You can't just connect them with a standard cable; that would only carry traffic for one VLAN. You need a trunk link.
A trunk link is a special connection that can carry traffic for multiple VLANs simultaneously. It does this using a protocol called 802.1Q tagging. When an Ethernet frame from a VLAN travels across a trunk, a small 'tag' is inserted into the frame's header. This tag identifies which VLAN the frame belongs to, so the receiving switch knows where to send it.
Configuring a trunk is similar to an access port, but we set the mode to trunk.
Switch(config)# interface GigabitEthernet0/1
Switch(config-if)# switchport mode trunk
Switch(config-if)# end
One crucial part of a trunk is the Native VLAN. This is the one VLAN on the trunk that does not get tagged. By default, it's VLAN 1. If an untagged frame arrives on a trunk port, the switch assumes it belongs to the native VLAN. For security, it's a best practice to change the native VLAN to an unused ID and not use VLAN 1 for anything.
Some switches can automatically negotiate whether a link should become a trunk using . While this sounds convenient, it can be a security risk. If an attacker connects a device that can speak DTP, they could trick your switch into forming a trunk and gain access to all VLANs. The safest approach is to manually configure trunk ports and disable DTP (switchport nonegotiate).
Special Cases and Management
Not all traffic is created equal. Voice traffic from VoIP phones is highly sensitive to delay. To prioritize it, we use a separate Voice VLAN. A single switch port can be configured to carry data traffic on one VLAN and voice traffic on another.
A PC plugs into the back of a VoIP phone, which then plugs into the switch. The switch tells the phone which VLAN to use for voice, and the PC's traffic passes through untagged to the data VLAN.
Switch(config)# interface FastEthernet0/10
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 100 ! Data VLAN for the PC
Switch(config-if)# switchport voice vlan 110 ! Voice VLAN for the phone
Switch(config-if)# end
Just as you'd separate user data, you should also isolate your network management traffic. By creating a dedicated management VLAN, you ensure that only authorized administrators can access and configure your network devices. Using the default VLAN 1 for management is a common but risky practice.
Finally, as your network grows, you don't want unnecessary broadcast traffic from every single VLAN flooding all of your trunk links. VLAN pruning is a feature that stops traffic from a particular VLAN from being sent across a trunk if no devices on the other side need it. This can be configured manually or handled automatically by protocols like Cisco's VLAN Trunking Protocol (VTP), optimizing bandwidth on your inter-switch links.
Ready to test your knowledge?
What is the primary function of a Virtual Local Area Network (VLAN)?
Which set of commands correctly configures a switch port FastEthernet0/5 as an access port for VLAN 10?
By moving from a flat network to a segmented one with VLANs, you gain significant improvements in performance, manageability, and security. It's a fundamental skill for any network administrator.