Section 27 working mode and basic commands of switch - based on PacketTracer simulation

1. Working mode of switch

1.1 actual working environment

In practical work, when a network device is configured for the first time, it is necessary to use the console cable with the PC terminal to configure the network device with "super terminal" or other software.

1.2 working mode

On the PacketTracer simulation platform, add a 2960 switch as the initialization setting object. Select the switch to enter the command line window.

  1. User mode: the command line prompt is "Switch >. In this mode, you can view the basic and simple information of the switch. You do not have permission to view important configuration information and cannot make any modification.
  2. Privileged mode: use "enable" to enter privileged mode from user mode, and the command line prompt is "Switch #". In this mode, you can view all configuration information and cannot make any modification, but you can do testing, saving, initialization and other operations.
  3. Global configuration mode: use "configure terminal" to enter the global configuration mode from the privileged mode, and the command line prompt is "Switch(config) #". In this mode, the configuration cannot be viewed by default. The configuration can be modified and takes effect globally.
  4. Interface configuration mode: the switch has 26 interfaces, including f0/1-f0/24 and g1/1-g1/2. Use the "interface f0/1" command to enter the interface configuration mode from the global configuration mode. In this mode, the command line cannot see which interface, and you need to remember or view the historical commands. In this mode, the configuration cannot be viewed by default. The configuration can be modified and takes effect for this interface.
  5. Console port configuration mode: use "line console 0" to enter the console port configuration mode from the global configuration mode, also known as line mode or console mode. In this mode, the configuration cannot be viewed by default. The configuration can be modified and takes effect on the console.

2 command

2.1 mode switching command

exit					#Exit from the next level mode to the previous level
end						#Except user mode, other modes directly exit to privileged mode
enable					#It can be abbreviated as en to enter privileged mode from user mode
configure terminal		#It can be abbreviated as conf t to enter global configuration mode from privileged mode
interface Interface number			#It can be abbreviated as int interface number, and enters the interface configuration mode from the global configuration mode
line console 0			#It can be abbreviated as line co 0. Enter the console port configuration mode from the global configuration mode

2.2 shortcut keys

?						#All commands supported in this mode
en?					#See which abbreviations correspond to this command
 up arrow 					#The up arrow automatically populates the last command you entered
Tab key					#As long as the abbreviation is an abbreviation for a specific command, you can use Tab to supplement the command
ctrl+u					#Quickly delete the entire line of commands being edited
ctrl+a					#Position the cursor at the beginning of the line
ctrl+e					#Position the cursor at the end of the line

2.3 configuring host names

conf t						#In global configuration mode,
hostname Device name				#Set a new name for the switch

2.4 setting user password

  • It is recommended to meet the complexity requirements, because Telnet port is often used to meet remote settings in the later stage, and the password is too simple and easy to be brutally cracked.
  • Since the above user password is not targeted at any account, anyone can use it, which is inconvenient for accountability. It is not recommended in practical work. In order to facilitate accountability, you need to configure corresponding account numbers and passwords for different engineers. Learn in the next experiment.
line co 0						#Enter the console port configuration mode
password New password					#Set the user's new password.
login							#Enable this command
end
exit							#Exit switch

2.5 setting privilege password

Since the switch and router are protected, if you want to manage remotely, you must set a privileged password.

conf t								#Enter global configuration mode
enable password New password				#Set the privileged password, which exists in clear text in running config
enable secret New password					#Set the privileged password, which exists as hash value in running config. When setting the ciphertext password, the plaintext password will be invalid.

2.6 viewing the running config configuration

When the switch is started, the switch will first find out whether the startup configuration file (startup config file) is saved in the hard disk. If it does not exist (when it is started for the first time or after initialization), the system will automatically create a new clean running config file in memory; If so, the startup config file is copied into memory and named running config file.

en
show running-config			#Abbreviated as show run, Cisco devices use the show command to view the configuration
show startup-config			#Cisco devices use the show command to view the configuration
display running-config		#Some devices use the display command to view the configuration
 Space							#Use spaces to turn pages during viewing

2.7 saving the configuration

After configuring the switch, you need to manually save the running config file memory to the hard disk and name it stratup config.

en
copy running-config startup-config		#Save the run profile as the startup profile.
write									#Some devices support using this command to write memory files to the hard disk.

2.8 restart

en
reload

2.9 viewing MAC address table

en
show mac-address-table		#The abbreviation show mac can be used-

2.10 view interface list

en
show ip interface brief		#It can be abbreviated to show ip int b
  • There are two interface states, one is the physical state (indicating the physical layer state) and the negotiation state (indicating the data link layer state, and whether the rate mode and duplex mode match successfully). The interfaces working in the second layer are basically similar.
  • The physical state down indicates that it is manually turned on (factory default), but there is no machine connection; up indicates that there is a machine connection; administratively down means to shut down manually.
Physical stateNegotiation statusNegotiation status
downdownThe physical state is off, indicating that no machine is connected to the interface
upupThe physical status has been turned on, the negotiation status has started, and it works normally
updownThe physical state has started, but the negotiation is not successful and cannot work normally
administratively downdownThe physical state has been manually set off

2.11 closing and opening the interface

interface Interface number
shutdown		#After setting, the physical state is administratively down
no shutdown		#Enter the port just set and add no before the original command. Most of them mean to cancel the original setting.

2.12do command

In global configuration mode and interface / line configuration mode, in order to avoid repeated mode switching, you can force some commands used in privileged mode, such as adding a do space before show. This method supports abbreviations, but cannot complete commands.

configure terminal
do show running-config
do show ip interface brief

2.13no command to delete configuration

  • Delete it wherever it is configured.
  • Add no space before the original command.
  • If there are parameters in the original command and the parameters are unique, there is no need to add parameters when deleting.
Location during configuration:
configure terminal
hostname New name			#Configure new name
 Location of injury:
configure terminal
no hostname				#When deleting a configuration, the new name is unique. You do not need to add it when deleting a configuration, but you need to add it if there are multiple new names

2.14 initialize switch

en
erase stratup-config		#Empty startup profile
reload

2.15 turn off the automatic analysis function

When the command is input incorrectly, the switch will conduct a global broadcast to query who recognizes the command, which will consume a lot of time. It is recommended to turn off the automatic parsing function.

conf t				#Enter global configuration mode
no ip domain-lookup	#Turn off automatic parsing

3 Summary

  1. Focus on mastering the five working modes of the switch.
  2. Focus on mastering the basic commands of the switch.
  3. The working mode and command of routers and other devices are similar to that of switches, which can be popularized and mastered by analogy.

Keywords: switch

Added by maxx99 on Tue, 04 Jan 2022 07:09:50 +0200