Network security

VLAN Configuration: How to Create a VLAN and Segment Your Network

A VLAN splits one switch into separate broadcast domains. Create it with vlan 10, name it, assign access ports, and link switches with a trunk.

Cysoro Security TeamPublished · 7 min read
NETWORK SECURITYVLANConfigurationSplit one switch into separate,secure networks — step by stepVLAN 10SalesVLAN 20EngineeringVLAN 30GuestsVLAN 40Printersswitchport mode trunk802.1Q taggedCYSORO • cysoro.com
Quick answer

A VLAN is a separate broadcast domain on a switch, created with the vlan command, given a name, and filled by assigning switch ports to it as access ports. Switches share VLANs over trunk ports using 802.1Q tagging, and devices in different VLANs can only talk to each other through a router or Layer 3 switch. Move user traffic off VLAN 1 and save your configuration when you finish.

Key takeaways

  • A VLAN turns one physical switch into several logical switches, each its own broadcast domain.
  • Create a VLAN with vlan 10, name it, assign ports with switchport access vlan 10, and connect switches with a trunk.
  • Devices in different VLANs need a router or Layer 3 switch to communicate — that boundary is where you enforce security policy.

By default, every device on a switch shares one big broadcast domain: sales, engineering, printers and the guest in the lobby all hear each other's broadcasts. A VLAN carves that switch into separate networks without buying more hardware.

What is a VLAN?

A VLAN (virtual local area network) is a separate broadcast domain on a switch. Put one port in VLAN 10 and another in VLAN 20, and a broadcast from VLAN 10 is flooded only to other VLAN 10 ports — VLAN 20 never sees it.

You have turned one physical switch into two logical switches that happen to share a chassis. The switch keeps a separate MAC address table per VLAN, so learning and flooding happen independently inside each one.

The benefits are practical: smaller broadcast domains, a clean boundary between departments, and a natural place to apply security policy. A guest VLAN, for example, can be blocked from reaching your servers at the router, even though the guest and the server plug into the same switch.

One switch, two separate networksPhysical switchVLAN 10 — SalesPorts 1–12 • 192.168.10.0/24Broadcasts stay inside VLAN 10VLAN 20 — EngineeringPorts 13–24 • 192.168.20.0/24Broadcasts stay inside VLAN 20Same hardware, separate broadcast domains — no traffic crosses without a router.
One switch split into two VLANs, each with its own broadcast domain and subnet. Illustration by Cysoro.

How do I create a VLAN?

Create a VLAN by entering configuration mode, running vlan 10, giving it a name, and exiting. The switch adds the VLAN to its database immediately — you do not need to reboot.

On a Cisco IOS switch, the steps are:

Switch> enable
Switch# configure terminal
Switch(config)# vlan 10
Switch(config-vlan)# name Sales
Switch(config-vlan)# end
Switch# show vlan brief
Switch# copy running-config startup-config

Check the output of show vlan brief to confirm VLAN 10 exists with the name Sales and no ports yet. The copy running-config startup-config step saves the port configuration; note that normal-range VLANs themselves live in the vlan.dat file in flash, not in the running configuration. ComputingForGeeks' Cisco VLAN configuration guide shows the same commands captured on real switches.

To create several VLANs at once, repeat the vlan command for each ID, or use a range on switches that support it. Keep a simple numbering plan — for example, 10 for Sales, 20 for Engineering, 30 for Guests, 40 for Printers — and write it down before you start.

Which VLAN IDs can I use?

Normal-range VLAN IDs run from 1 to 1005, and extended-range IDs run from 1006 to 4094. Most small and medium networks only ever need the normal range, and you should avoid the reserved IDs inside it.

RangeIDsNotes
VLAN 1 (default)1Every port starts here; cannot be deleted; move user traffic off it
Normal range2–1001Use these for your departments, guests and devices
Reserved1002–1005Legacy Token Ring and FDDI VLANs; do not use them
Extended range1006–4094For large environments; stored in running config, not vlan.dat

VLAN 1 deserves a warning. Because every port belongs to it by default, building your network on VLAN 1 means every new device lands in your main network automatically. Create your own VLANs and move ports into them, and leave VLAN 1 mostly empty.

How do I assign a port to a VLAN?

Assign a port by entering interface configuration mode, setting it to access mode, and naming the VLAN. An access port belongs to exactly one VLAN and carries untagged traffic for the device plugged into it.

Switch# configure terminal
Switch(config)# interface gigabitethernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# no shutdown
Switch(config-if)# end

The no shutdown command enables the port. Verify the result with show vlan brief or show interfaces gigabitethernet0/1 switchport — the output should show the port in access mode in VLAN 10.

Assign a whole range of ports the same way with an interface range command, for example interface range gigabitethernet0/1-12, then the same two switchport commands. That is how you fill a department VLAN in one step instead of twelve.

A common extra is a voice VLAN for IP phones. A phone plugs into the port, a PC plugs into the phone, and the switch puts voice traffic in one VLAN and data in another:

Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# switchport voice vlan 40

How do trunk ports work between switches?

A trunk port carries traffic for several VLANs between two switches, tagging each frame with its VLAN ID using 802.1Q. Without a trunk, each VLAN would need its own cable between the switches.

Configure a trunk like this:

Switch# configure terminal
Switch(config)# interface gigabitethernet0/24
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 10,20,30
Switch(config-if)# end

The allowed vlan list is a security control, not just a convenience: only the VLANs you list can cross that link. If a VLAN is not allowed on the trunk, its traffic stops at the switch, even if the VLAN exists on both sides.

One VLAN on a trunk is untagged — the native VLAN. By default that is VLAN 1. Change it to an unused VLAN ID and never use it for user traffic, so an attacker cannot hop VLANs by sending untagged frames. Set it explicitly on both ends of the trunk so the two switches agree.

Access ports vs trunk portsSwitch AAccess: VLAN 10Access: VLAN 20One VLAN, untaggedSwitch BAccess: VLAN 10Access: VLAN 20One VLAN, untaggedTRUNK — 802.1QVLAN 10, 20, 30 taggedAccess ports serve one device; the trunk serves every VLAN on both switches.
Access ports carry one untagged VLAN; a trunk carries many VLANs, tagged with 802.1Q. Illustration by Cysoro.

How do devices in different VLANs communicate?

They cannot talk directly. Each VLAN is a separate subnet, so traffic between VLANs must go through a router or a Layer 3 switch — a process called inter-VLAN routing. That boundary is exactly where you enforce policy.

The usual setup is a router-on-a-stick: one router interface, divided into subinterfaces, one per VLAN, each with its own IP address as the gateway for that VLAN. The switch trunk carries all the VLANs to the router, and the router forwards traffic between them.

Router(config)# interface gigabitethernet0/0.10
Router(config-subif)# encapsulation dot1Q 10
Router(config-subif)# ip address 192.168.10.1 255.255.255.0
Router(config-subif)# exit
Router(config)# interface gigabitethernet0/0.20
Router(config-subif)# encapsulation dot1Q 20
Router(config-subif)# ip address 192.168.20.1 255.255.255.0

On a Layer 3 switch, the same idea uses switched virtual interfaces (SVIs): create an interface VLAN 10 with an IP address, enable IP routing, and the switch routes between VLANs itself.

Routing alone does not mean open access. Add access control lists at the router or SVI to decide what may cross: Sales may reach the printer VLAN, but the guest VLAN should reach nothing internal except the internet. Without those rules, VLANs separate broadcasts but not people.

How do I verify and troubleshoot a VLAN?

Start with show vlan brief. It lists every VLAN, its name, its status and which ports belong to it. If a VLAN is missing or a port is in the wrong VLAN, that one command usually shows it.

  • show vlan brief — lists VLANs and their ports.
  • show vlan id 10 — detail for one VLAN.
  • show interfaces trunk — shows trunk ports, the native VLAN and which VLANs are allowed and active.
  • show interfaces switchport — shows a port's mode, access VLAN and trunk settings.
  • show running-config interface gigabitethernet0/1 — shows exactly what is configured on one port.

Common faults follow a pattern. If two devices in the same VLAN cannot talk, check that both ports are in the same VLAN and that the ports are enabled.

If devices on different switches in the same VLAN cannot talk, check the trunk: is it in trunk mode, does the allowed list include the VLAN, and do both ends agree on the native VLAN? If devices in different VLANs cannot talk, check the router or SVI for a missing gateway or a blocking access list.

Remember the vlan.dat quirk from the start: erasing the startup configuration and reloading does not wipe normal-range VLANs. To genuinely reset the VLAN database, delete the file with delete flash:vlan.dat and reload — and only do that when you mean to start over.

How do I keep VLANs secure?

VLANs are a segmentation tool, not a security guarantee. A misconfigured switch can undo them, so treat the switch itself as a security device.

  • Move traffic off VLAN 1. Do not use the default VLAN for users, servers or management.
  • Use a dedicated management VLAN. Put switch management on its own VLAN, reachable only from admin workstations.
  • Limit trunk ports. Set switchport mode trunk only where a trunk is needed, and prune the allowed VLAN list to what that link actually carries.
  • Set an unused native VLAN. Never use VLAN 1 or a user VLAN as the native VLAN on a trunk.
  • Disable unused ports. Shut down ports with nothing plugged in, so nobody can walk up and join your network.
  • Enable port security. Limit how many MAC addresses a port learns, so one port cannot be used to impersonate many devices.
  • Filter between VLANs. Use access lists at the router or SVI so the guest VLAN cannot reach internal systems.

For the wider network, see our guide to securing your Wi-Fi — wireless clients should land in their own VLAN too, not straight into your main network.

If you manage the network from home, confirm your public address with the free what-is-my-IP tool before opening remote access.

Cisco's VLAN configuration guide documents the commands used in this article, including creating VLANs and assigning access ports.

The bottom line

Creating a VLAN takes four commands: vlan 10, a name, an access-port assignment, and a trunk to carry it to the next switch. The harder part is the plan — which groups to separate, which subnets to give them, and what may cross between them.

Start small: one guest VLAN and one department VLAN, with a router or Layer 3 switch in between and an access list that blocks guests from internal systems. Check your setup with show vlan brief, save it, and build from there with the small business cybersecurity checklist.

Frequently asked questions

What is a VLAN in simple terms?

A VLAN is a group of devices on a switch that behave as if they were on their own separate switch. They share broadcasts with each other but not with devices in other VLANs, even though they use the same physical hardware.

How do I create a VLAN on a Cisco switch?

Enter privileged mode with enable, then configure terminal, then vlan 10, then name Sales, then end. Verify with show vlan brief and save with copy running-config startup-config.

What is the difference between an access port and a trunk port?

An access port belongs to one VLAN and carries untagged traffic for a single device. A trunk port carries traffic for several VLANs between switches, tagging each frame with its VLAN ID using 802.1Q.

Can devices in different VLANs talk to each other?

Not directly. They are in separate broadcast domains and separate subnets, so traffic must go through a router or a Layer 3 switch, which can apply access rules as it forwards it.

What is VLAN 1?

VLAN 1 is the default VLAN on Cisco switches. Every port belongs to it until you assign it elsewhere, and it cannot be deleted. Good practice is to move user traffic off VLAN 1 rather than build your network on it.

What VLAN ID range can I use?

Normal-range VLANs are 1 to 1005, with 1002 to 1005 reserved for legacy Token Ring and FDDI. Extended-range VLANs are 1006 to 4094. Most small networks only need IDs in the normal range.

Why is my VLAN not working after a reboot?

Normal-range VLANs are stored in the vlan.dat file in flash, not in the running configuration, so they usually survive a reboot. Check show vlan brief, confirm the port assignment, and check that the trunk allows the VLAN.

Do I need a VLAN for a small office?

Not always, but VLANs help as soon as you want to separate guests, printers, phones or departments. Even a small office benefits from a guest VLAN that cannot reach internal systems.

Sources

  1. Cisco — VLANs Configuration Guide (Catalyst 2960)
  2. ComputingForGeeks — Configure VLANs on a Cisco Switch
  3. Cisco Community — VLAN Configuration via CLI on 300 and 500 Series Managed Switches
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Cisco's Catalyst VLAN configuration guide and ComputingForGeeks' Cisco VLAN lab guide.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free