zoukankan      html  css  js  c++  java
  • 思科Cisco 2960系列交换机配置命令

    配置密码:

    2960>en ;第一次密码为空 
    2960h#conf t ;进入全局配置模式 
    2960(config)#hostname swa ;设置交换机名 
    2960(config)#enable secret aaa ;设置特权加密口令为 aaa 
    2960(config)#enable password aax ;设置特权非密口令为 aax 
    2960(config)#line console 0 ;进入控制台口(Rs232) 
    2960(config-line)#password aa ;设置登录口令aa 
    2960(config-line)#login ;登录要求口令验证 
    2960(config-line)#line vty 0 4 ;进入虚拟终端virtual tty 
    2960(config-line)#password a ;设置登录口令a 
    2960(config-line)#login ;登录要求口令验证 
    2960(config-line)#exit ;返回上一层 
    2960(config)#exit ;返回上一层 
    2960#sh run ;看配置信息 
    2960#exit ;返回命令

    配置Vlan

    新建一个Vlan的命令

    Switch>enable     进入特权模式

    Switch#configure terminal      进入全局配置模式

    Switch (config)# vlan vlan-id     创建一个Vlan或者进入Vlan配置模式

    Switch (config-vlan)# name vlan-name 给Vlan命名(取消设置:no name)

    Switch (config-vlan)# mtu mtu-size 设置最大通讯量(取消设置:no mtu)

    Switch (config-vlan)#remote-span    开启远程流量监控(关闭:no remote-span)

    Switch (config-vlan)# end 回到特权模式

    Switch#show vlan {name vlan-name | id vlan-id}        查看当前配置

    Switch#copy running-config startup config 保存配置

    删除Vlan的命令

    Switch>enable     进入特权模式

    Switch#configure terminal      进入全局配置模式

    Switch (config)# no vlan vlan-id       删除Vlan

    Switch (config)# end 回到特权模式

    Switch#show vlan brief    查看删除情况

    Switch#copy running-config startup config 保存配置

    端口加入特定Vlan的命令

    Switch>enable     进入特权模式

    Switch#configure terminal      进入全局配置模式

    Switch (config)# interface interface-id    进入端口配置

    Switch (config-if)# switchport mode access     将接口的模式设为访问模式

    Switch (config-if)# switchport access vlan vlan-id 将端口加入指定的Vlan(恢复端口默认配置:default interface interface-id)

    Switch (config-if)# end       回到特权模式

    Switch#show running-config interface interface-id     查看端口模式

    Switch#show interfaces interface-id switchport 查看端口详细配置

    Switch#copy running-config startup-config 保存配置

    批量端口加入特定Vlan的命令

    int range fa0/1 - 10

    switchport   access   VLan   V2

    将特定端口设为trunk

    2960-01(config)#default interface fastEthernet 0/1    端口恢复默认值    

    2960-01(config)#interface fastethernet0/1            进入端口模式

    2960-01(config-if)#switchport mode trunk           设置端口为trunk模式

    2960-01(config-if)#switchport nonegotiate          将接口设置为不协商模式

    2960-01(config-if)end

    2960-01#wr

    启用snmp

     

    Switch>enable     进入特权模式

    Switch#configure terminal      进入全局配置模式

    Switch (config)# snmp-server community string [view view-name] [ro | rw] [access-list-number]

    (关闭snmp: no snmp-server)

    (删除团体字符: no snmp-server community string)    配置snmp团体字符并开启snmp代理服务

    String: 团体口令字符(所有SNMP命令中只有设置团体口令的snmp-server community是必须的,其它的都是可选的.)

    View: view 可以用于限定哪些MIB分支不能用本community-string存取预先用snmp-server view定义

    ro | rw: ro获得MIB对象信息;rw获得并可以修改MIB对象信息

    access-list-number:访问列表号

    Switch (config)#access-list access-list-number {deny |

    permit} source [source-wildcard]     配置拒绝或者允许访问snmp代理服务的IP地址,访问列表号为上一步指定的列表号

    Switch (config)#end    回到特权模式

    Switch#show running-config 查看配置

    Switch#copy running-config startup-config 保存配置

    cisco2960口令恢复

     

    交换机口令恢复的步骤

    ⒈串口线连接到到交换机的console口。

    ⒉先按住交换机面板上的mode键,然后打开电源。

    ⒊初始化flash

    >flash_init

    ⒋更名含有password的配置文件。

    >rename flash:config.text flash:config.old

    ⒌启动交换机。

    >boot

    ⒍进入特权模式。

    >enable

    ⒎此时开机是已忽略password

    #rename flash:config.old flash:config.text

    ⒏copy配置文件到当前系统中。

    #copy flash:config.text system:running-config

    ⒐修改口令。

    #configure terminal

    #enable secret

    ⒑保存配置。

    #write

    ===================================================================================================
    (一)使能口令(enable password),口令以明文显示 
    使能密码 (enbale secret), 口令以密文显示 
    Switch.> /*用户直行模式提示符 
    Switch.>enable /*进入特权模式 
    Switch.# /*特权模式(进入前要输入密文) 
    Switch.#config terminal /*进入全局配置模式 
    Switch.(config)# /*配置模式提示符 
    Switch.(config)# hostname Pconline /*设置主机名Pconline 
    Pconline(config)# enable password cisco3560 /*设置使能口令为pconline 
    Pconline(config)# enable secret cisco3560 /*设置使能密码为network 
    Pconline(config)# line vty 0 15 /*设置虚拟终端线 
    Pconline(config-line)# login /*设置登陆验证 
    Pconline(config-line)# password cisco3560 /*设置虚拟终端登陆密码 
    二、 交换机VLAN设置 
    Switch.> /*用户直行模式提示符 
    Switch.>enable /*进入特权模式 
    switch#vlan database ; 进入VLAN设置 
    switch(vlan)# vlan 2 ; 建VLAN 2 
    switch(vlan)#no vlan 2 ; 删vlan 2 
    switch(config)#int f0/1 ; 进入网络端口1 
    switch(config)#int giga0/1 ; 进入汇聚千兆口1 
    switch(config-if)# duplex {auto | full | half} 设置端口为---自动/全双工/半双工 
    switch(config-if)#switchport mode trunk ; 当前端口设置为汇聚口 
    switch(config-if)#switchport mode access ; 当前端口设置为接入模式 
    switch(config-if)#switchport trunk allowed vlan 1,2 ;设置1,2号口允许的vlan组 
    switch(config-if)#switchport trunk vlan 2 ; 设置1号口允许的vlan 
    switch(config-if)#switchport access vlan 2 ; 当前端口加入vlan 2 
    switch(config-if)#switchport trunk encap dot1q ; 设置vlan 中继 
    cisco网络中,交换机在局域网中最终稳定状态的接口类型主要有四种: 
    access/ trunk/ multi/ dot1q-tunnel。 
    1、access: 主要用来接入终端设备,如PC机、服务器、打印服务器等。 
    2、trunk: 主要用在连接其它交换机,以便在线路上承载多个vlan。 
    3、multi: 在一个线路中承载多个vlan,但不像trunk,它不对承载的数据打标签。主要用于接入支持多vlan的服务器或者一些网络分析设备。现在基本不使用此类接口,在cisco的网络设备中,也基本不支持此类接口了。 
    4、dot1q-tunnel: 用在Q-in-Q隧道配置中。 
    switch(config)#vtp domain ; 设置发vtp域名 
    switch(config)#vtp password ; 设置发vtp密码 
    switch(config)#vtp mode server ;设置发vtp模式 
    switch(config)#vtp mode client ;设置发vtp模式 
    三. 交换机设置IP地址 
    switch(config)#interface vlan 1 进入vlan 1 
    switch(config-if)#ip address 132.37.48.3 255.255.255.0; 设置交换机管理IP 
    switch(config)#ip default-gateway 132.37.48.1 ;设置交换机默认网关 
    switch(config)#end; 退出当前模式 
    Switch#conf t 进入特权模式 
    Switch(config)# interface fa0/5 
    Switch(config-if)# shutdown 关闭端口 
    Switch(config-if)# no shutdown 打开端口 
    四. 交换机显示命令 
    特权模式下: 
    switch#write ; 保存配置信息 
    switch#show vtp ; 查看vtp配置信息 
    switch#show run ; 查看当前配置信息 
    switch#show vtp ; 查看交换机vtp信息 
    switch#show vlan ; 查看vlan配置信息 
    switch#show interface ; 查看端口信息 
    Switch#show interfaces fastethernet 0/1 switchport ;显示二层端口的状态,可以用来决定此口是否为二层或三层口。 switch#show int f0/0 ; 查看指定端口信息 
    sw1924_b#show ip; 查看上述设置环境 
    sw1924_b#show versi;查看交换机的版本等信息 
    sw1924_b#show running-config;查看交换机的当前运行配置等全部信息 
    sw1924_b#show int e0/1;查看交换机的第1个端口信息 
    基于端口的MAC地址绑定 
    Switch#config terminal #进入配置模式 
    Switch(config)# Interface fastethernet 0/1 #进入具体端口配置模式 
    Switch(config-if)#Switchport port-secruity #配置端口安全模式 
    Switch(config-if )switchport port-security mac-address MAC(主机的MAC地址) 
    #配置该端口要绑定的主机的MAC地址 
    Switch(config-if )no switchport port-security mac-address MAC(主机的MAC地址) 
    #删除绑定主机的MAC地址 
     
    ====================================================================================================

    配置步骤 注释 
    配置密码 
    Switch>en 特权模式 
    Switch#conf t 配置模式 
    Switch(config)#host SAT2960 改变设备名称 
    Switch(config)#ena se cisco 特权口令 
    Switch(config)#line vty 0 15 修改远程登陆口令 
    Switch(config-line)#login             
    Switch(config-line)#password cisco 
    Switch(config-line)#line con 0 修改串口登陆口令 
    Switch(config-line)#login             
    Switch(config-line)#password noco 
    Switch(config-line)#exit 
    Switch(config)#exit 
    Switch# 
    创建VLAN (特权模式下用vlan database命令) 
    SAT2960#vlan database 
    SAT2960(vlan)#vlan 2 name Marketing 创建并命名 
    VLAN 2 modified: 
    Name: Marketing 
    SAT2960(vlan)#apply 应用 
    APPLY complete 
    SAT2960(vlan)#(Ctrl+C) 退出 
    SAT2960#sh vlan brief 验证 
    设置IP信息 
    默认情况下,VLAN1是管理VLAN,所有接口均是VLAN1的成员 
    SAT2960(config)#int vlan1 进入管理VLAN 
    SAT2960(config-if)#ip address 172.16.10.16 255.255.255.0 
    SAT2960(config-if)#no shut 打开接口 
    SAT2960(config-if)#exit 
    SAT2960(config)#ip default-gateway 172.16.10.1 
    SAT2960(config)# 
    SAT2960交换机配置文件的擦除: 
    SAT2960交换机配置文件是存储在NVRAM中的,使用copy run start 来保存当前运行的配置到NVRAM中,擦除SAT2960 里面的start-config文件,使用命令:
    SAT2960#erase start-config
    SAT2960#reload

    配置端口描述:(使用 description 命令)
    SAT2960(config)#int fa 0/1
    SAT2960(config-if)#description haha
    SAT2960(config-if)#exit
    可以使用show interface 和 show running-config 命令来查看这些描述信息;

    给VLAN分配端口: 
    SAT2960(config-if)#int f0/2 
    SAT2960(config-if)#switchport access vlan 2 
    SAT2960(config-if)#int f0/3 
    SAT2960(config-if)#switchport access vlan 3 
    SAT2960(config-if)#int f0/4 
    SAT2960(config-if)#switchport access vlan 4 
    SAT2960(config-if)#exit 
    SAT2960(config)#exit 
    验证配置信息,如下: 
    SAT2960#sh vlan brief 
    配置中继端口——打trunk 
    SAT2960(config)#int f0/12 
    SAT2960(config-if)#switchport mode trunk 
    SAT2960(config-if)#(ctrl+c) 
    SAT2960# 
    验证配置信息: 
    SAT2960#sh run 
    保存设置 
    SAT2960#wr mem 
    或者 
    SAT2960#copy running-config startup-config 

    常用调试命令           
    a、显示所有配置命令:Switch#show run           
    b、显示所有接口状态:Switch#show ip int brief           
    c、显示所有VLAN的信息:Switch#show vlan brief

     

    =======================================================

    端口镜像

    monitor session 1 source interface F0/1 - F0/23       !指定被镜像端口
    monitor session 1 destination interface F0/24 !指定接收镜像的端口

    取消某个命令是在前面加no

  • 相关阅读:
    关于unity的一个不错的插件平台
    erlang otp中的socket参数设置
    android开发国内镜像
    composer中文镜像
    bootstrap的一些资源
    根据现有表操作基于active record的model
    Erlang Web 监控工具
    erlang程序发布的时候需要注意的地方
    pcl学习笔记(二):点云类型
    c++中inline函数的意义
  • 原文地址:https://www.cnblogs.com/sysk/p/5310385.html
Copyright © 2011-2022 走看看