1. Basic configuration commands of Cisco switches
1. Enter privileged mode : enable
switch> enable
switch#
2. Enter the global configuration mode configure terminal
switch> enable
switch#c onfigure terminal
switch(conf)#
3. Name the switch hostname aptech2950 Take aptech2950 as an example
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch-2950
aptech2950(conf)#
4: Configure enable password enable password cisco Take cisco as an example
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# enable password cisco
5: Configure enable password enable secret ciscolab Take cicsolab as an example
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# enable secret ciscolab
6: Create multiple VLANs
1. Create multiple VLANs
Switch>enable (enter privileged mode)
Switch#vlan data (enter vlan configuration mode)
Switch(vlan)#vlan 10 name IT (divide vlan10, named IT)
Switch(vlan)#vlan 20 name HR (divide vlan20, named HR)
Switch(vlan)#vlan 30 name FIN (divide vlan30, the name is FIN)
Switch(vlan)#vlan 40 name LOG (divide vlan40, the name is LOG)
Switch(vlan)#exit
7: set vlan 1
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# interface vlan 1
aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0 Configure switch port ip and subnet mask
aptech2950(conf-if)#no shut is configuration is running
aptech2950(conf-if)#exit
aptech2950(conf)#ip default-gateway 192.168.254 Set the gateway address
8: Enter interface fastehernet 0/17 of a certain port of the switch, taking port 17 as an example
switch> enable
switch#c onfigure terminal
switch(conf)#hostname aptch2950
aptech2950(conf)# interface fastehernet 0/17
aptech2950(conf-if)#
9: View command show
switch> enable
switch# show version View all version information in the system
show interface vlan 1 View the configuration information of the switch about the ip protocol
show running-configure View the current configuration information of the switch
show interface fastethernet 0/1 View the specific configuration and statistics of the switch 1 interface
show mac-address-table View mac address table
show mac-address-table aging-time View the automatic aging time of the mac address table
10: The switch restores the factory default recovery command
switch> enable
switch# erase startup-configure
switch# reload
11: Duplex mode setting
switch> enable
switch#c onfigure terminal
switch2950(conf)#hostname aptch-2950
aptech2950(conf)# interface fasterhernet 0/17 Take port 17 as an example
aptech2950(conf-if)#duplex full/half/auto has three options: full , half and auto
11: cdp related commands
switch> enable
switch# show cdp View the global cdp configuration information of the device
show cdp interface fastethernet 0/17 View the cdp configuration information of port 17
show cdp traffic View statistics about cdp packets
show cdp nerghbors lists cisco devices connected to the device
12: Switch telnet remote login settings:
switch>en
switch#configure terminal
switch(conf)#hostname aptech-2950
aptech2950(conf)#enable password cisco Use cisco as the privileged mode password
aptech2950(conf)#interface fastethernet 0/1 Use port 17 as telnet remote login port
aptech2950(conf-if)#ip address 192.168.1.1 255.255.255.0
aptech2950(conf-if)#no shut
aptech2950(conf-if)#exit
aptech2950(conf)line vty 0 4 Set 0-4 users to log in remotely via telnet
aptech2950(conf-line)#login
aptech2950(conf-line)#password edge Use edge as the user password for remote login
Host settings:
ip 192.168.1.2 The ip of the host must be in the same network as the address of the switch port
part
netmask 255.255.255.0
gate-way 192.168.1.1 The gateway address is the switch port address
run:
telnet 192.168.1.1
Enter the telnet remote login interface
password : edge
aptech2950>en
password: cisco
aptech#
2. Use Layer 3 switches to realize communication between different vlans
Above we learned about the basic configuration commands of Cisco switches, let's look at the configuration cases below.
The case is as follows:
Since pc1 and pc2 are blocked in two different switches and in different vlans, they cannot communicate, so what should I do?
One S3550-24 (layer 3 switch), one S2126 switch, pc1 is in vlan10, pc2 is in vlan20, as shown in the figure below.
Inter-VLAN communication experiment topology diagram
The configuration is as follows:
1. Create VLAN 20 on the switch SwitchA, and divide the F0/15 port into VLAN 20.
SwitchA>enable
SwitchA#configure terminal
SwitchA(config)#vlan20 //Create VLAN 20
SwitchA(config-vlan)#name vlan20 //Name VLAN 20 as vlan20
SwitchA(config)#interface f0/15 //Enter F0/15 interface configuration mode
SwitchA(config-if)#switchport access vlan 20 //Add F0/15 port to VLAN 20
SwitchA #showvlan id 20 //Verify that VLAN 20 has been created and port F0/15 has been assigned to VLAN 20.
2. The port connected to SwitchB on SwitchA (port F0/24 here) is defined as tag vlan mode.
SwitchA>enable
SwitchA#configure terminal
SwitchA (config)#interface f0/24 //Enter interface configuration mode
SwitchA (config-if)#switchport mode trunk //Set F0/24 port to tag vlan mode
SwitchA (config)#show interfaces f0/24 switch //Verify that the F0/24 port has been set to tag vlan mode
3. Create VLAN 10 on SwitchB, and assign port F0/5 to VLAN 10.
SwitchA>enable
SwitchA#configure terminal
SwitchB(config)#vlan 10 //Create VLAN 10
SwitchB (config-vlan)#name vlan10 //Name VLAN 10 as vlan
SwitchB (config)#interface f0/5 //Enter F0/5 interface configuration mode
SwitchB (config-if)#switchport access vlan10! Assign F0/5 port to VLAN 10
SwitchB #show vlan id 10 //Verify that VLAN 10 has been created and port F0/5 has been assigned to VLAN 10
4. The port connected to SwitchA on SwitchB (port F0/24 here) is defined as tag vlan mode.
SwitchA>enable
SwitchA#configure terminal
SwitchB (config)#interface f0/24 //Enter interface configuration mode
SwitchB (config-if)#switchport mode trunk //Set F0/24 port to tag vlan mode
SwitchB (config)#show interfaces f0/24 switch //Verify that the F0/24 port has been set to tag vlan mode.
5. Set up the communication between the VLANs of the three-layer switch, and open the routing function of the three-layer switch
SwitchA>enable
SwitchA#configure terminal
SwitchA(config)#ip routing //Enable the routing function of the three-layer switch
SwitchA(config) #interface vlan 10 //Create a virtual interface vlan10
SwitchA(config-if) #ip address 192.168.10.254 255.255.255.0 //Configure the virtual interface ip address of vlan10
SwitchA(config) #interface vlan 20 //Create a virtual interface vlan20
Configure the virtual interface ip address of vlan20
SwitchA(config-if) #ip address 192.168.20.254 255.255.255.0 //Configure the virtual interface ip address of vlan20
5. Configure the default gateway
Set PC1's default gateway to 192.168.10.254 and PC2's default gateway to 192.168.20.254
In this way, pc1 and pc2 can communicate with each other.