1.3. Interface Operations for Switches¶
1.3.1. Heads Up¶
All the operations are conducted under one of the following modes:
privilege mode (see Enter and Exit Privilege Mode).
config mode (see Enter and Exit Configuration Mode).
config-if mode (see Enter and Exit Interface Config Mode).
Remember to activate the port (see Activate and Deactivate Port).
1.3.2. VLAN¶
Ports in the same VLAN can communicate with each other. Ports from different VLANs are not connected. VLAN 1 is the default VLAN. By default, all ports are assigned to VLAN 1.
1.3.3. VLAN Configurations¶
1.3.3.1. Show VLAN¶
In privilege mode, do
device# show vlan
1.3.3.2. Change Port To Access or Trunk Mode¶
In config-if mode, do
device(config-if)#switchport mode access
device(config-if)#switchport mode trunk
1.3.3.3. Create and Delete VLAN¶
When you In config mode, do
# create a vlan and assign a name
device(config)# vlan 50 # create a new vlan with id 50
device(config-vlan)#name newVLAN # name the new vlan to "newVLAN"
# delete a vlan under config mode or vlan config mode
device(config-vlan)#no vlan 50 # delete vlan with id=50
# or
device(config)#no vlan 50
Need to point out that, if you delete an vlan without re-assign ports to existing vlan, these ports will not have a vlan id after deletion.
1.3.3.4. Assign Ports to VLAN¶
In config or config-vlan mode, do
# choose the target vlan
device(config)# vlan 50
# select port fa1/0
device(config-vlan)#interface fa1/0
# assign the selected port to target vlan
device(config-if)#switchport access vlan 50
device(config)# vlan 100
# assign ports in a range to vlan 100
device(config-vlan)#interface range fa2-10/0
# the access to the vlan 100 is enabled
device(config-vlan-range)#switchport access vlan 100
1.3.3.5. Assign VLANs to Trunk¶
Before assigning VLANs to trunk port, you first need to switch the port to trunk rather than access mode (see Change Port To Access or Trunk Mode). Then, you do
# select GigabitEthernet 0/1
device(config)# int Gi0/1
device(config-if)#switchport trunk allowed vlan 50
device(config-if)#switchport trunk allowed vlan add 100
device(config-if)#switchport trunk allowed vlan add 999
device(config-if)#switchport trunk allowed vlan remove 999
1.3.3.6. Assign IP Address to VLAN¶
In config mode, do
# config the vlan with id 99
device(config)# interface vlan 99
device(config-if)#ip address 192.168.99.253 255.255.255.0
1.3.3.7. Enable Telnet¶
In config mode, do
device(config)#line vty 0 15
device(config-line)#password cisco # telnet password
device(config-line)#login
If you want to enter privilege mode, you must set the privilege mode password (see Set Privilege Mode Password).