24.4.2 Configuring the port VLAN
The following explains how to set a port VLAN. It provides example settings for Switch 1 shown in the figure below.
Port 1/0/1 is set for port VLAN 10. Ports 1/0/2 and 1/0/3 are set for port VLAN 20. Port 1/0/4 is the trunk port, and all VLANs are set for it.
|
- <Structure of this section>
(1) Creating a ported VLAN
- Points to note
-
The example below shows how to create a port VLAN. When a VLAN is created, if a VLAN ID is specified but a VLAN type is not, the VLAN becomes a port VLAN.
Command examples
-
(config)# vlan 10,20
Creates VLAN ID 10 and VLAN ID 20 as port VLANs. This command switches to VLAN configuration mode.
(2) Configuring Access Ports
When a single VLAN is set to a single port and untagged frames are handled, it is set as an access port.
- Points to note
-
The example below shows how to set a port for the access port, and set the VLANs handled by the access port.
Command examples
-
(config)# interface gigabitethernet 1/0/1
Switches to the Ethernet interface configuration mode for port 1/0/1.
-
(config-if)# switchport mode access
(config-if)# switchport access vlan 10
(config-if)# exit
Sets port 1/0/1 as an access port. Then, sets VLAN 10.
-
(config)# interface range gigabitethernet 1/0/2-3
Switches to the Ethernet interface configuration mode for ports 1/0/2 and 1/0/3. Because the configuration is the same for ports 1/0/2 and 1/0/3, setting is done as a batch operation.
-
(config-if-range)# switchport mode access
(config-if-range)# switchport access vlan 20
Sets ports 1/0/2 and 1/0/3 as access ports. Also, set VLAN 20.
(3) Configuring Trunk Ports
- Points to note
-
The example below shows how to set the port that handles tagged frames as the trunk port, and set the VLANs for the trunk port.
Command examples
-
(config)# interface gigabitethernet 1/0/4
Switches to Ethernet interface configuration mode for ports 1, 0, and 4.
-
(config-if)# switchport mode trunk
(config-if)# switchport trunk allowed vlan 10,20
Sets port 1/0/4 as a trunk port. Then, sets VLAN 10 and VLAN 20.