一、交换机命令集
      Cisco交换机支持两种命令集。
      1、基于Cisco IOS的命令集。
         Catalyst 1900/2800、2900XL系列
      2、基于设置的命令集,使用“set”和“clear”命令。
         Catalyst 2926、2926G、1948G、4000、5000、6000
二、基础设置
      1、设置访问口令
         a、基于IOS命令的设置
            enable password level n password
            注:n=1,给用户普通的可执行模式用户特权;
                n=15,通过使能口令允许的访问级别;
                password为4到8位,不区分大小写。
         b、基于set命令的设置
            set password
            set enablepass
            注:口令区分大小写
      2、定义主机名
         a、基于IOS命令的设置
            hostname xxxxxxxx
            no hostname xxxxxxxx
         b、基于set命令的设置
            set prompt xxxxxxxx
      3、定义交换机IP地址
         a、基于IOS命令的设置   
            在全局配置模式下:ip addr [ip address] [netmask]
         b、基于set命令的设置
            set int sc0 [ip address] [netmask]
            set int sc0 [vlan]
            将sc0与某个vlan关联起来,缺省为VLAN1
      4、定义端口速率
         在基于IOS命令的交换机上,端口速率不能被改变。
         a、基于set命令的设置
            set port speed [mod-num/port-num] [10|100|auto]
      5、设置线路模式(双工方式)
         a、基于IOS命令的设置
            duplex [auto|full|full-flow-control|half]
            full-flow-control强迫100BaseTX端口进入带流控的全双工模式,
            此参数只在100BaseTX端口有效。
         b、基于set命令的设置
            set port duplex [mod-num/port-num] [full|half]
三、VLAN的设置
      1、建立VLAN
        a、基于IOS命令的设置
            vlan database
            vlan [vlan-id] name [vlan-name]
            exit
            show vlan name [vlan-name]
            no vlan [vlan-id]                       *删除VLAN
            将端口划分到VLAN中:
            conf t
            int [interface]
            switchport mode access                  *定义VLAN成员模式
            switchport access vlan [vlan-id]        *将此端口划分到指定VLAN
            exit
            show int [interface] switchport
         b、基于set命令的设置
            set vlan [vlan-num] [mod-num/port-list]
            注:缺省配置是所有以太网端口都在VLAN1上。
                端口组格式:2/1,3/3,3/4或2/1,3/3-4
      2、VLAN标识
         目前使用两种标识技术:
         a、Cisco交换机间链路(ISL)
         b、IEEE 802.1Q标准
         注:各型交换机支持的标识技术不同,如Catalyst 4000系列只支持802.1Q标准,
             可使用show port capabilities命令查看。
      3、设置VLAN成员
         a、基于IOS命令的设置
            inter e 0/1
            进入接口配置模式,此例为第1以太网口
            vlan-membership static [vlan-number]
            将接口指派到相应的本地VLAN
         b、基于set命令的设置      
      4、配置干道链路
         a、基于IOS命令的设置
            conf t
            int [interface]
            switchport mode trunk
            switchport trunk encapsulation [isl | dot1q]
            no switchport mode     *取消TRUNK模式
            switchport trunk allowed vlan remove [vlan-list]     *定义不传输信息的VLAN

         b、基于set命令的设置
            set trunk [mod-num/port-num] [on|off|desirable|auto|nonegotiate]
            [vlan-range] [isl|dot1q|dot10|lane|negotiate]
            注:desirable(企望)参数,让端口主动的试图将链路转变为干道链路,若
                相邻端口被设置为开启、企望或自动模式的话,该端口就可变成干道端口。
            从干道链路中清除VLAN:clear trunk [mod-num/port-num] [vlan-range]
            核验干道配置:show trunk [mod-num/port-num]
      5、配置VLAN干道协议(VTP)
         a、基于IOS命令的设置
            vlan database
            vtp domain [domain-name]
            vtp server
            exit
            show vtp status
            设置为客户端模式:
            vlan database
            vtp domain [domain-name]
            vtp client
            exit
            show vtp status
            客户端模式不能更改VLAN设置,只能从VTP Server上获得更新信息。
        
            关闭VTP功能
            vlan database
            vtp transparent
            起用VTP Version 2
            vlan database
            vtp v2-mode
            禁用VTP Version 2
            no vtp v2-mode
            注:当enable Version 2后,在同一VTP域内的其他具有Version 2
                能力的交换机都可起用此模式。Version 1和Version 2不能同时
                使用,同一VTP域内必须使用同一VTP版本。除非同一VTP域内的
                交换机都支持Version 2,否则不要起用Version 2。

         b、基于set命令的设置
            ·建立VTP域并确定模式
              set vtp domain [domain-name] password [password] mode
              [server|client|transparent] [v2 enable]
            ·核验VTP配置
              show vtp domain, show vtp statistics
      6、配置VTP修剪(pruning)
         a、基于IOS命令的设置
            conf t
            int [interface]
         
            switchport trunk pruning vlan remove [vlan-id]  
            *去除不需VTP修剪的VLAN
      
         b、基于set命令的设置   
            启用VTP修剪:
            set vtp pruneeligible [vlan-range]
            关闭VTP修剪:
            clear vtp pruneeligible [vlan-range]   
      7、设置端口属于多个VLAN(设置multi-VLAN port)
            conf t
            int [interface]
            switchport mode multi
            switchport multi vlan [vlan-list]
         注:为避免未知的STP信息和性能的降低,不要将multi-VLAN port连接到HUB或
             交换机,可将其连接到Router或Server。
四、VLAN间路由的设置
      1、内部路由处理器
         第3层路由器和第3层交换机之间的最大区别是,第3层路由器通过软件
         进行路由选择,第3层交换机通过硬件进行路由选择。
         没装Netflow特性卡(NFFC)的Catalyst 5000上的路由交换模块(RSM)被
         视为一台第3层路由器,即路由选择是通过RSM以软件形式进行的,配上
         NFFC后就可通过硬件进行路由,成为第3层交换机。
         RSM是一个运行普通Cisco IOS路由器软件的路由器模块,其直接插到5000
         系列交换机背板上。
         RSFC是一台全功能的Cisco IOS路由器,它作为5000系列监控引擎II G和
         监控引擎III G卡的集成子卡选项安装。
         MSM通过4个全双工G比特以太网接口连接到交换总线。Catalyst交换机将
         MSM视为通过4个接口连接到交换机的一台外部路由器。
五、配置HSRP
      1、将Router配置为一个备份组成员(在接口配置模式下设置)
         standby [group-number] ip [virtual-ip-address]
         [group-number]         ———— 该接口所属的HSRP组,缺省为0
         [virtual-ip-address] ———— 虚拟HSRP Router的IP地址
      2、分配HSRP备份优先级
         standby [group-number] priority [priority-value]
         [priority-value] ———— 优先级值,从0至255,缺省100
         在HSRP组中有最高优先级的Router变为转发/活跃Router
      3、配置HSRP备份占先权
         standby [group-number] preempt
      4、显示HSRP的状态
         show standby [type-number] [group] brief
         [type-number] ———— 说明要显示的目标接口类型和序号
         [group]         ———— 要显示的接口上的某个具体HSRP组
      
六、Catalyst 4000设置举例
      1、说明
         在4232-L3上,用Show run命令,可看到有4个Giga口,其中1、2为模块前端的
         Giga口,3、4为模块内部与背板连接的接口。
      2、参数
         a、C4006,2 Slot插WS-4232,3 Slot插WS-4232-L3,连接3个设备,组成
            3个VLAN,现设置互相访问。
         b、连接设备参数
            Bang:      满足“a”要求的C4006
            Liki:      连接到路由模块上gigabit 1端口的Router
            Donald:    连接到port 3/3(路由模块上的一个二层端口),并处于VLAN2
                     的Router
            Daniella: 连接到port 2/3 of bang,并处于VLAN3的Router
         c、IP Address
            Bang gigabit 1:3.3.3.2 255.255.255.0 
            Bang port 2/3 :1.1.1.2 255.255.255.0 
            Bang port 3/3 :2.2.2.2 255.255.255.0 
      3、设置
         a、在Supervisor上
         
            set port channel 3/1-2 156 
            set vlan 2 3/3
            set vlan 3 2/3
            set trunk 3/1    nonegotiate dot1q 1-1005
            set trunk 3/2    nonegotiate dot1q 1-1005 
            set port channel 3/1-2 mode on                              
         b、在WS-4232-L3上
            interface Port-channel1                   
            !---this interface is configured for dot1q routing with native
                vlan 1 to match supervisor configuration
            interface Port-channel1.2                    *“.2”表示VLAN 2
             encapsulation dot1Q 2                       *“2”表示VLAN 2
             ip address 2.2.2.2 255.255.255.0            *为VLAN 2设置一个网关
            ! 
            interface Port-channel1.3 
             encapsulation dot1Q 3 
             ip address 1.1.1.2 255.255.255.0 
            interface FastEthernet1                 
            !---this is the out of band interface that you can use for management
            interface GigabitEthernet1 
             ip address 3.3.3.2 255.255.255.0
            interface GigabitEthernet3 
             channel-group 1                       
            !---both port gig 3 and gig 4 are part of the channel-group 1 
            interface GigabitEthernet4 
             channel-group 1                         
            !---both port gig 3 and gig 4 are part of the channel group    1 
            router eigrp 1 
             passive-interface FastEthernet1 
             network 1.0.0.0 
             network 2.0.0.0 
             network 3.0.0.0 
七、设置举例二
      设置VLAN,并实现VLAN间三层交换。
      1、catalyst 2924/3524 设置
         en
         conf t
         hostname zj5                                  *设置主机名
          user 1 pass 0 1                              *建立一个用户,用户名口令均为1
          snmp-s commu public                          *设置网管参数
         line vty 0 4                                  *设置telnet登录参数
          pass 0 112233                                *设置登录口令为112233
          login
         int vlan 1                                    *设置交换机IP
          ip addr 172.16.22.5 255.255.255.0
         int fa 0/23                                  *将23端口设置为Trunk方式
                                                   (此口为级连线口)
          switch mode trunk
          switch trunk encap dot
          switch trunk all vlan all
         int giga 0/1                                 *设置光纤口
          switch mode trunk
          switch trunk encap dot
          switch trunk all vlan all
         int fa 0/1                                  *设置1端口属于VLAN 3
          switch mode acce
          switch acce vlan 3
         exit
         ip defa 172.16.22.23                        *设置默认网关(4232-L3 IP地址)
         exit
         wr                                          *存储设置
———————————————————————————————————————
      2、catalyst 4006 设置(4306-GB,4232-L3)
         set vlan 1 state active                    *激活VLAN 1
         set vlan 2 state active
       set vlan 3 state active
       set vlan 4 state active
       set vlan 5 state active
       set vlan 6 state active
       set vlan 7 state active
       set vlan 8 state active
       set vlan 9 state active
       set vlan 10 state active
       set vlan 11 state active
       set vlan 12 state active
       set vlan 13 state active
       set vlan 14 state active
       set vlan 16 state active
       set interface sc0 172.16.22.22 255.255.255.0 up    *设置Catalyst4006 IP地址
       set ip route 0.0.0.0 0.0.0.0 172.16.22.23          *设置路由(指向4232-L3)
       set trunk 3/1    on dot1q 1-1005                    *将4006端口设置为Trunk方式
       set trunk 3/2    on dot1q 1-1005
       set trunk 3/3    on dot1q 1-1005
       set trunk 3/4    on dot1q 1-1005
       set trunk 3/5    on dot1q 1-1005
       set trunk 3/6    on dot1q 1-1005
       set trunk 5/1    on dot1q 1-1005
       set trunk 5/2    on dot1q 1-1005
       set port channel 5/1-2 mode on                   *将4232-L3的1、2口捆绑为Trunk
       set vlan 15 5/31                                *设置4232-L3的端口31属于VLAN 15
       set snmp commu public                          *设置网管参数
       wr ter                                         *存储设置
4232-L3配置同“举例六”。