Chapter 1. Configuring VLAN

- Information About Configuring VLAN

- How to Configure VLAN

- Configuration Examples for VLAN

Information About Configuring VLAN

A Virtual Local Area Network (VLAN) is a switched network that is logically segmented by function, project team, or application, without regard to the physical locations of users. VLANs have the same attributes as physical LANs. In VLANs, you can group end stations even if they are not physically located on the same LAN segment. Using a VLAN, you can logically segment a physical LAN into different broadcast domains. The broadcast and unicast traffic within a VLAN is not forwarded to other VLANs.

VLAN Interface Configuration

Compared to traditional Ethernet, VLANs enjoy the following advantages:

- A traditional Ethernet network sends mass broadcast data to all the network devices directly, regardless of necessity, leading to network jitter. With VLAN, you can configure the necessary communication device in each VLAN to reduce broadcast traffic and improve network efficiency.

- Only devices that are a part of the same VLAN can communicate with each other, which helps improve the security of a network.

- A VLAN helps reduce network configuration workload. When the physical position of a host changes within the range of a VLAN, there is no need to change its network configuration.

Management VLAN

A management VLAN manages a device from a remote location, and uses protocols such as Telnet, SSH, SNMP, and syslog. A management VLAN should be configured on a Layer 2 switch. You can log in to a device from a remote location only by using a management VLAN. A management VLAN need not be configured on a Layer 3 switch. On a Layer 3 switch, the interface VLAN is the management VLAN.

How to Configure VLAN

The following topics provide information about the procedures you should perform to configure a VLAN.

- Configuring a VLAN

- Configuring an Interface Default VLAN ID

- Types of VLAN Interfaces

- Configuring Interface VLAN Mode

- Configuring VLAN Attributes on a Hybrid Interface

- Configuring VLAN Attributes on a Trunk Interface

- Configuring Port Priority

- Disabling Ingress Filtering

- Configuring an Acceptable Frame Type for a Port

Configuring a VLAN

To configure a VLAN, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

vlan vlan list

Example:

Device(config)# vlan 11

Creates a VLAN for a single port or a list of ports.

Step 4

switchport ethernet port-number

Example:

Device(config-if-vlan)# switchport ethernet 1/4

Adds a VLAN interface to the designated port.

Step 5

description string

Example:

Device(config-if-vlan)# description vlan1

Adds a description to the VLAN.

Configuring an Interface Default VLAN ID

To configure an interface default VLAN ID, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters interface configuration mode.

Step 4

switchport default vlan vlan-id

Example:

Device(config-if-ethernet-1/4)# swicthport default vlan 3

Configures an interface as a default interface.

Step 5

no swithport default vlan

Example:

Device(config-if-ethernet-1/4)# no switchport default vlan

Restores the default VLAN ID to port 1.

Types of VLAN Interfaces

A VLAN interface can be divided into three different types based on the process an interface performs on a VLA- tagged packet.

- Access: This interface belongs to a single VLAN and is used to connect to a terminal device. When this interface receives an untagged VLAN packet, it adds the Default VLAN tag to it. When the interface receives a tagged VLAN packet, it checks the VLAN ID of the packet. If it is a VLAN that the corresponding port allows to pass through, the interface accepts the packet. Otherwise, the interface drops the packet.

When forwarding a VLAN packet, the interface checks the VLAN ID carried in the packet. If it is a VLAN ID that the corresponding port allows to pass through, then the interface strips the VLAN tag and forwards the packet.

- Hybrid: This interface is able to receive and forward packets to multiple VLANs. When this interface receives an untagged VLAN packet, it adds the tag of the default VLAN to it. When the interface receives a tagged VLAN packet, it checks the VLAN ID of the packet. If it is a VLAN that the corresponding port allows to pass through, the interface accepts the packet. Otherwise, the interface drops the packet.

When forwarding a VLAN packet, the interface checks the VLAN ID carried in the packet. If it is an untagged VLAN ID, the interface strips the VLAN tag and forwards the packet. If the VLAN ID that is carried in the packet is a tagged VLAN ID, the interface retains the VLAN tag and forwards the packet.

- Trunk: This interface can receive and forward packets to multiple VLANs. When the interface forwards a VLAN, the default VLAN packet does not carry a tag whereas, other packets carry the tag. When the interface recieves an untagged VLAN packet, it adds the tag of the default VLAN to it. When the interface receives a tagged VLAN packet, it checks the VLAN ID of the packet. If it is a VLAN that the corresponding port allows to pass through, the interface accepts the packet. Otherwise, the interface drops the packet.

When forwarding a VLAN packet, the interface checks the VLAN ID carried in the packet. If it is an untagged VLAN ID, the interface strips the VLAN tag and forwards the packet. If the VLAN ID that is carried in the packet is a tagged VLAN ID, the interface retains the VLAN tag and forwards the packet.

Configuring Interface VLAN Mode

To configure VLAN mode, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters the interface configuration mode.

Step 4

switchport mode { access | hybrid | trunk}

Example:

Device(config-if)# switchport mode hybrid

Configures the VLAN mode for the interface.

Configuring VLAN Attributes on a Hybrid Interface

To configure VLAN attributes on a hybrid interface, perform this procedure:

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters the interface configuration mode.

Step 4

switchport mode hybrid

Example:

Device(config-if-ethernet-1/4)# switchport mode hybrid

Configures the hybrid mode for the interface VLAN.

Step 5

switchport hybrid { untagged | tagged} vlan { vlan-list | all}

Example:

Device(config-if-ethernet-1/4)# switchport hybrid tagged 2-4

Allows the packets from the specified VLANs to pass through the hybrid port. (To prevent the packets from the specified VLANs passing through the hybrid port, use the no form of the command.

Configuring VLAN Attributes on a Trunk Interface

To configure VLAN attributes on a trunk interface, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device#configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters interface configuration mode.

Step 4

switchport mode trunk

Example:

Device(config-if-ethernet-1/4)# switchport mode trunk

Configures the trunk mode for the interface VLAN.

Step 5

switchport trunk allowed vlan { vlan-list | all}

Example:

Device(config-if-ethernet-1/4)# switchport trunk allowed vlan 2-4

Allows the packets from the specified VLANs to pass through the trunk port. (To prevent the packets from the specified VLANs passing through the trunk port, use the no form of this command.)

Configuring Port Priority

To add a priority value to a port, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters interface configuration mode.

Step 4

priority port-priority

Example:

Device(config-if-ethernet-1/4)# priority 2

Configures a priority value for the port. The priority range is from 0 to 7. (To restore the default priority value for the port, use the no form of the command.)

Step 5

show interface ethernet port-number

Example:

Device# show interface ethernet 2

Displays the detailed configurations for a port.

Step 6

end

Example:

Device(config-if-ethernet-1/4)# end

Exits to privileged EXEC mode.

Step 7

show interface brief ethernet port-number

Example:

Device# show interface brief ethernet 2

Displays the configurations on the port, in brief.

Disabling Ingress Filtering

Ingress filtering is enabled by default. The interface checks the received packets. If the packets belong to the VLAN, the interface forwards them. If the packets do not belong to the VLAN, it drops the packets. To disable ingress filtering, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)# interface ethernet1/4

Enters interface configuration mode.

Step 4

ingress filtering

Example:

Device(config-if-ethernet-1/4)# ingress filtering

Enables ingress filtering. (To disable ingress filtering use the no form of this command.)

Step 5

end

Example:

Device(config-if-ethernet-1/4)# end

Exits to privileged EXEC mode.

Step 6

show ingress interface { ethernet port-number| gpon port-number}

Example:

Device# show ingress interface ethernet 1/4

Displays the status of filtering on the ingress port.

Configuring an Acceptable Frame Type for a Port

To configure an acceptable frame type that is acceptable on a port, perform this procedure.

Procedure

Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode. Enter your password, if prompted.

Step 2

configure terminal

Example:

Device#configure terminal

Enters global configuration mode.

Step 3

interface ethernet port-number

Example:

Device(config)#interface ethernet1/4

Enters interface configuration mode.

Step 4

ingress acceptable-frame { all| tagged}

Example:

Device(config-if-ethernet-1/4)# ingress acceptable-frame tagged

Configures the type of frames acceptable on the port.

- all: the port can receive tagged and untagged VLAN packets.

- tagged: the port can receive only tagged VLAN packets.

Step 5

end

Example:

Device(config-if-ethernet-1/4)# end

Exits to privileged EXEC mode.

Step 6

show ingress interface { ethernet port-number| gpon port-number}

Example:

Device# show ingress interface ethernet 1/4

Displays the status of filtering on the ingress port.

Configuration Examples for VLAN

The following sections provide examples of VLAN configurations.

- Example: Creating a VLAN and Assigning a Default VLAN

- Example: Configuring the VLAN Mode for an interface

Example: Creating a VLAN and Assigning a Default VLAN

The following example shows how to create a VLAN:

Device> enable
Device# configure terminal
Device(config)#vlan 100
Device(config-if-vlan)#switchport ethernet 1/1 ethernet 1/2

The following example shows how to configure a default VLAN and change the VLAN mode of an interface:

Device> enable
Device# configure terminal
Device(config)#interface ethernet 1/1
Device(config-if-ethernet-1/1)#switchport mode access
Device(config-if-ethernet-1/1)#switchport default vlan 100
Device(config-if-ethernet-1/1)#interface ethernet 1/2
Device(config-if-ethernet-1/2)#switchport mode trunk
Device(config-if-ethernet-1/2)#switchport default vlan 100
Device(config-if-ethernet-1/2)#exit

The following example shows how to display the VLAN configuration on Port1 and Port2:

Device> enable
Device# configure terminal
Device(config)#show interface brief ethernet 1/1 ethernet 1/2
Port    Desc   Link shutdn Speed        Pri PVID Mode TagVlan    UtVlan
e1/1         up   false  auto-f100     0   100  acc             100
e1/2         up   false  auto-f100     0   100  trk              100
Total entries: 2 .

Example: Configuring the VLAN Mode for an interface

The following example shows how to configure an access port:

Device> enable
Device# configure terminal
Device(config)#vlan 100
Device(config)#interface ethernet 1/1
Device(config-if-ethernet-1/1)#switchport mode access

The following example shows how to configure a trunk port:

Device> enable
Device# configure terminal
Device(config)#vlan 100
Device(config)#interface ethernet 1/2
Device(config-if-ethernet-1/1)#switchport mode trunk

The following example shows how to display the VLAN configuration on Port1 and Port2:

Device(config)# show interface brief ethernet 1/1 ethernet 1/2
Port  Desc  Linkshutdn  Speed  Pri  PVID  ModeTagVlan  UtVlan
e1/1  up  false        auto-f100  0  1    acc            1
e1/2  up  false        auto-f100  0  1    trk             1
Total entries: 2 .

Full Cisco Trademarks with Software License

THE SPECIFICATIONS AND INFORMATION REGARDING THE PRODUCTS IN THIS MANUAL ARE SUBJECT TO CHANGE WITHOUT NOTICE. ALL STATEMENTS, INFORMATION, AND RECOMMENDATIONS IN THIS MANUAL ARE BELIEVED TO BE ACCURATE BUT ARE PRESENTED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. USERS MUST TAKE FULL RESPONSIBILITY FOR THEIR APPLICATION OF ANY PRODUCTS.

THE SOFTWARE LICENSE AND LIMITED WARRANTY FOR THE ACCOMPANYING PRODUCT ARE SET FORTH IN THE INFORMATION PACKET THAT SHIPPED WITH THE PRODUCT AND ARE INCORPORATED HEREIN BY THIS REFERENCE. IF YOU ARE UNABLE TO LOCATE THE SOFTWARE LICENSE OR LIMITED WARRANTY, CONTACT YOUR CISCO REPRESENTATIVE FOR A COPY.

The Cisco implementation of TCP header compression is an adaptation of a program developed by the University of California, Berkeley (UCB) as part of UCB's public domain version of the UNIX operating system. All rights reserved. Copyright © 1981, Regents of the University of California.

NOTWITHSTANDING ANY OTHER WARRANTY HEREIN, ALL DOCUMENT FILES AND SOFTWARE OF THESE SUPPLIERS ARE PROVIDED “AS IS" WITH ALL FAULTS. CISCO AND THE ABOVE-NAMED SUPPLIERS DISCLAIM ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, THOSE OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE.

IN NO EVENT SHALL CISCO OR ITS SUPPLIERS BE LIABLE FOR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, OR INCIDENTAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST PROFITS OR LOSS OR DAMAGE TO DATA ARISING OUT OF THE USE OR INABILITY TO USE THIS MANUAL, EVEN IF CISCO OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.

All printed copies and duplicate soft copies of this document are considered uncontrolled. See the current online version for the latest version.

Cisco has more than 200 offices worldwide. Addresses and phone numbers are listed on the Cisco website at www.cisco.com/go/offices.

Cisco and the Cisco logo are trademarks or registered trademarks of Cisco and/or its affiliates in the U.S. and other countries. To view a list of Cisco trademarks, go to this URL: https://www.cisco.com/c/en/us/about/legal/trademarks.html. Third-party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1721R)