交换机命令

发布时间 2023-08-07 13:52:18作者: 楚颖i

交换机命令

该命令是cisco交换机的,其他交换机可能不一样。

下面的命令都可以缩写,如enable缩写成en,但不能有歧义(即这个缩写的英语单词只有那个)

路由器命令与交换机类似

1)用户模式:
    switch>
    	可以查看交换机的基本简单信息,但不能做任何修改配置!
    	
2)特权模式
    switch> enable
    switch#>
        可以查看所有配置,不能修改配置,但可以做测试、保存、初始化等操作
        
3)全局配置模式
    switch# configure terminal
    switch(config)#
        默认不能查看配置!
        可以修改配置,且全局生效!
        
4)接口配置模式:
    switch(config)#interface f0/1
    switch(config-if)#
        默认不能查看配置!
        可以修改配置,且对该接口生效!
        
5)console口/线/控制台配置模式:
    switch(config)#line console 0
        默认不能查看配置!
        可以修改配置,且对console口生效!

命令:
6、 exit 退出一级
    end 直接退到特权模式
7、支持命令缩写
8、?的用法:不用写/,直接写?
9、历史命令
10、tab补全键

11、配置主机名:
    configure terminal    #进入全局配置模式
    hostname 设置设备名

12、设置用户密码:
    line co 0    #进入console口/线/控制台配置模式
    password 密码
    login
    exit

13、快捷键:
    ctrl+u : 快速删除光标前所有字符
    ctrl+a : 快速定位光标到行首
    ctrl+e : 快速定位光标到行尾

14、
    在内存中存在一个文件:
    running-config
    第一次开机,系统会在内存中自动创建一个新的干净的running-config
15、配置
    enable    #进入特权模式
    copy running-config startup-config
    或
    write    #将当前的做好的配置写入【启动】中
    
16、交换机开机动作:
    先去硬盘中查找startup-config是否存在:
    如果不存在,内存中创建新的running-config
    如果存在,则复制到内存中并改名为running-config
    
17、查看running-config配置
    enable    #特权模式
    show running-config
18、查看startup-config配置
    enable    #特权模式
    show startup-config
    
19、重启设备:
    enable
    reload
    
20、配置特权密码:
    configure terminal    #全局配置模式
    enable password 密码(明文)   #查看时会显示密码
    enable secret 密码 (密文)   #查看时会显示md5加密后信息,同时设置两个,使用secret密码才能登录
    
21、查看MAC地址表
    enable
    show mac-address-table
22、查看接口状态列表:
    show ip interface brief
    ==show ip int b
    
23、手工关闭接口
	configure terminal
    interface f0/x    #x表示任意(交换机有的才行)
    shutdown
    exit
23、手工开启接口
    int f0/x
    no shutdown
    exit
    
24、do的用法
    其他模式加do空格可以强制使用特权模式的命令	
    如:
        do show running-config    #用do不能补全,难受
        do sh ip int b    #缩写
        do wr
        
25、删除配置
    1)在哪配置的,就在哪删!
    2)命令前加no 空格
    3)原命令中有参数,并且参数具有唯一性,则删除时不需要加参数
    如:
        conf t    #全局配置模式
        hostname sw1
 
        conf t
        no hostname
 
26、清空/擦除/初始化配置
    en    #特权模式
    erase start-config
    
27、为3层端口 配置IP:(路由器最初一般是人工down状态)
    int f0/0
    ip add 10.1.1.254 255.255.255.0
    no shutdown

28、开启远程控制:
    conf t    #全局配置模式
    line vty 0 4    #可同时4人同时控制(默认是telnet)
    transport input telnet/ssh/none/all
    password 密码	
    login
    exit
 
 	conf t    #ssh(比telnet安全)
    hostname r1
    ip domain-name r1.qf.com
    crypto key generate rsa   //生成密钥对
    line vty 0 4
    transport input telnet/ssh/none/all
    login local
    exit
    username xx password 123.com
    
29、为交换机配置管理IP:
    conf t
    interface vlan 1
    ip address 10.1.1.253 255.255.255.0
    no shut
    
30、为交换机配置默认网关
    目的:可跨网段管理
    conf t
    ip defaut-gateway 10.1.1.254
    
31、关闭自动解析功能:
    conf t
    no ip domain-lookup