Assigning Switch Ports to VLANs

Assigning Switch Ports to VLANs
You configure a port to belong to a VLAN by assigning a membership mode that specifies the
kind of traffic the port carries, plus the number of VLANs to which it can belong. You can
configure each port on a switch to be in a specific VLAN (access port) by using the interface
switchport
command. You can also configure multiple ports at the same time with the
interface range
command.
Here in Table 6.3 are the basic switch VLAN commands used on a switch port:
TABLE 6 . 2
Verifying a VLAN
Command Meaning
show vlan
Displays the contents or list of VLANs stored in the VLAN database
file. (The VLAN database file is called
vlan.dat
and can be
seen with the
show flash
command.)
TABLE 6 . 3
Assigning Switch Port Memberships
Command Meaning
interface
Enters the interface configuration mode and allows the configuration
of a specific interface.
interface range
Allows the selection of multiple ports for the purpose of configuring
the same functions on all of those ports.
switchport mode
The
switchport
command is used to modify most layer-2 properties
of a switch port. The mode option allows the modification
of how a switch port will handle traffic for a specific VLAN or set
of VLANs.
switchport access
Configures the port into a specific VLAN for the purpose of allowing
only traffic from that VLAN to pass to and from that port.
Here’s an example of setting a switch port assignment to VLAN 3
S1#c
onfig t
S1(config)#
int fa0/3
S1(config-if)#
switchport ?
access Set access mode characteristics of the interface
backup Set backup for the interface
block Disable forwarding of unknown uni/multi cast addresses
host Set port host
mode Set trunking mode of the interface
44 nonegotiate Device will not engage in negotiation protocol on this
interface
port-security Security related command
priority Set appliance 802.1p priority
protected Configure an interface to be a protected port
trunk Set trunking characteristics of the interface
voice Voice appliance attributes
S1(config-if)#
switchport mode ?
access Set trunking mode to ACCESS unconditionally
dynamic Set trunking mode to dynamically negotiate access or
trunk mode
trunk Set trunking mode to TRUNK unconditionally
S1(config-if)#
switchport mode access
S1(config-if)#
switchport access vlan 3