Hello and welcome back to your training.
In the last lesson, you performed the essential initial setup of a switch, giving it a hostname, securing it with passwords, and configuring a management IP address on a dedicated management VLAN. This allowed you to access the switch remotely.
Today, we'll build directly on that foundation. A switch's primary job is to connect devices, but in any professional environment, we need to control how they're connected. We'll dive into one of the most fundamental concepts in networking: Virtual Local Area Networks (VLANs). You will learn how to create VLANs to logically segment a network, and how to configure the physical switch ports to enforce that segmentation using access ports and trunk ports.
Mastering VLANs is non-negotiable for any network or data center role. It's the core technique used to enhance security, improve performance, and organize devices in every modern network.
1. What Are VLANs and Why Do We Use Them?
In the previous lesson, you created VLAN 99 for management. But what exactly is a VLAN? In simple terms, a VLAN allows you to take a single physical switch and split it into multiple, logically separate virtual switches. Devices in one VLAN cannot communicate with devices in another VLAN without a router, even if they are plugged into the same physical piece of hardware.
Before we jump into the command line, it's crucial to understand the "why." The following video provides an excellent conceptual overview of LANs, VLANs, and their benefits.
VLANs Made Easy: Learn This Today!
This video from Crosstalk Solutions clearly explains what VLANs are and the key reasons for using them, such as for security and organization.
Watch from 04:30 to 08:39. Focus on the definition of a VLAN, the concept of a VLAN tag (or ID), and the three main benefits discussed: security, organization, and performance.
To summarize the key benefits for a job interview context:
- Security: This is the primary driver. By placing sensitive departments like Finance (VLAN 20) on a separate VLAN from general users (VLAN 30) or guests (VLAN 999), you prevent users from snooping on traffic that they shouldn't have access to. A security breach in one VLAN is contained and doesn't immediately compromise the entire network.
- Organization & Management: Grouping devices by function (e.g., VoIP phones, security cameras, servers) simplifies network management and policy application.
- Performance: VLANs reduce unnecessary broadcast traffic. A broadcast message sent by a device will only be forwarded to other devices within the same VLAN, not to every single port on the switch. This reduces network congestion and improves overall efficiency.
2. Access Ports vs. Trunk Ports: The Rules of the Road
Now that you know why we use VLANs, we need to understand how a switch enforces them. This is done by configuring each port to behave in one of two ways: as an access port or a trunk port. Getting this right is critical.
The next segment of the video we just watched introduces this terminology perfectly.
VLANs Made Easy: Learn This Today!
Let's continue with the 'VLANs Made Easy' video to understand the roles of untagged/access ports and tagged/trunk ports. The office building analogy is particularly helpful.
Watch from 10:10 to 15:10. Pay close attention to the definitions of 'untagged' (access), 'tagged', and 'trunk' ports.
Here’s a breakdown of the key terms:
-
Access Port:
- Purpose: Connects to an end device (e.g., a user's computer, a printer, a server).
- Rule: An access port belongs to only one VLAN.
- Traffic: It sends and receives regular, untagged Ethernet frames. When an untagged frame arrives at an access port, the switch knows it belongs to the VLAN assigned to that port.
-
Trunk Port:
- Purpose: Connects a switch to another switch, a router, or a server that needs to handle traffic from multiple VLANs.
- Rule: A trunk port can carry traffic for multiple VLANs simultaneously.
- Traffic: It uses a special protocol, most commonly 802.1Q, to insert a tag into each Ethernet frame. This tag contains the VLAN ID, telling the receiving device which VLAN the frame belongs to.


3. Practical Configuration: Building the VLANs
Let's apply these concepts. Imagine our task is to set up a new switch for two departments: Engineering (VLAN 10) and Sales (VLAN 20).
The following video demonstrates the exact Cisco IOS commands needed to accomplish this. We'll watch it in segments as we build our configuration.
Step 1: Create the VLANs
First, we need to tell the switch that VLAN 10 and VLAN 20 exist.
Cisco Switch basic Configuration | VLAN, Access Port & Trunk Port Configuration step by step
This short clip from Cisco Config shows how to create VLANs and assign descriptive names in the Cisco command-line interface.
Watch from 01:01 to 02:29. Observe how the prompt changes as you enter VLAN configuration mode.
From global configuration mode (Switch(config)#):
# Create VLAN 10 for Engineering
vlan 10
name Engineering
# Create VLAN 20 for Sales
vlan 20
name Sales
exit
Giving VLANs a descriptive name is a crucial best practice. show vlan brief will now show "Engineering" instead of the generic "VLAN0010".
Step 2: Configure Access Ports
Next, we'll assign switch ports to these new VLANs. Let's say ports 1-8 are for Engineering, and ports 9-16 are for Sales.
Cisco Switch basic Configuration | VLAN, Access Port & Trunk Port Configuration step by step
Now, let's see how to configure ports as access ports and assign them to the VLANs we just created. This clip also shows the very useful 'interface range' command.
Watch from 02:29 to 05:36. Note the two key commands: switchport mode access and switchport access vlan <ID>.
The commands are:
# Configure ports for the Engineering department
interface range gigabitethernet1/0/1 - 8
switchport mode access
switchport access vlan 10
exit
# Configure ports for the Sales department
interface range gigabitethernet1/0/9 - 16
switchport mode access
switchport access vlan 20
exit
The interface range command is a huge time-saver, allowing you to apply the same configuration to many ports at once.
Step 3: Configure a Trunk Port
Finally, let's configure port 24 to be the trunk link that will connect to our main network router. This will allow traffic from both VLANs (and our management VLAN 99) to travel to the router.
Cisco Switch basic Configuration | VLAN, Access Port & Trunk Port Configuration step by step
This final clip demonstrates how to change a port's mode to 'trunk' and specify which VLANs are allowed to cross it.
Watch from 05:36 to 07:54. Pay attention to the 'switchport mode trunk' and 'switchport trunk allowed vlan' commands.
The commands are:
interface gigabitethernet1/0/24
switchport mode trunk
switchport trunk allowed vlan 10,20,99
The switchport trunk allowed vlan command is an important security and performance best practice. It ensures that only traffic from the specified VLANs can pass through this trunk. If you omit this command, the trunk will, by default, carry traffic for every VLAN known to the switch, which might not be desirable.
4. Verifying Your Configuration
Configuration without verification is just a hopeful guess. You must always check that the switch is operating as you intended.
The following article from PracticalNetworking.net is an excellent, in-depth reference for both configuration and verification. For now, focus on the verification commands it presents.
Configuring VLANs on Cisco Switches
This article is a comprehensive guide to VLAN configuration on Cisco switches. We'll focus on the 'Show Commands' section to learn how to verify our work.
Read the section titled 'Show Commands'. Pay special attention to the purpose and output of show vlan brief, show interfaces trunk, and show interfaces <interface> switchport.
Here are the essential verification commands to commit to memory:
show vlan brief: This is your primary tool. It gives you a quick table showing all created VLANs, their names, and which access ports are assigned to each.show interfaces trunk: This command lists all active trunk ports. It tells you their encapsulation type (802.1q), their status, and, crucially, which VLANs are allowed on the trunk.show interfaces <interface_id> switchport: This command provides a highly detailed report for a single port, including its administrative mode (e.g.,static accessortrunk), its operational mode, the VLAN it belongs to (if access), or the native VLAN (if trunk).
5. Practice Application
Time to use your "katana." Let's say you need to prepare a switch for a new office floor. The requirements are:
- VLAN 110 for
Marketingon portsGigabitEthernet1/0/1through1/0/10. - VLAN 120 for
Logisticson portsGigabitEthernet1/0/11through1/0/20. - Port
GigabitEthernet1/0/24should be a trunk port connecting to another switch. It should only carry traffic for theMarketingandLogisticsVLANs.
Write down the full sequence of commands, starting from global configuration mode (Switch(config)#), to implement this setup. Then, list the verification commands you would use to confirm your configuration is correct.
Conclusion
You have just configured the fundamental building block of a modern switched network. By segmenting traffic with VLANs, you dramatically improve security and organization.
Key Takeaways:
- VLANs create logically separate broadcast domains on a single physical switch.
- Access ports belong to a single VLAN and connect to end devices like PCs. They handle untagged traffic.
- Trunk ports carry traffic for multiple VLANs between switches or to a router. They use 802.1Q tagging to identify the VLAN for each frame.
- The configuration process is:
- Create and name the VLANs (
vlan <id>,name ...). - Assign access ports (
switchport mode access,switchport access vlan <id>). - Configure trunk ports (
switchport mode trunk,switchport trunk allowed vlan ...).
- Create and name the VLANs (
- Always verify your work with
show vlan briefandshow interfaces trunk.
In our next lesson, we will move to the device that our new trunk port connects to: the router. You will learn to configure interface settings on a router, including assigning IP addresses. This will be the first step in enabling communication between the VLANs you just created, a process known as inter-VLAN routing.