《通用版CISCO交换机配置命令及释义》——【全面、通用,含部分功能的注释】

                      CISCO交换机配置命令及释义

1.设置交换机名称

switch(config)#hostname DSHD

DSHD(config)#


2.设置交换机管理IP地址

switch(config)#interface vlan1

switch(config)#ip address 10.1.1.1 255.255.255.0

switch(config-if)#no shutdown

switch(config-if)#exit

switch#show run


3.设置交换机特权模式登录口令:

 switch> enable

 Password:

switch# configure terminal

扫描二维码关注公众号,回复: 11177266 查看本文章

Enter configuration commands, one per line. End with Ctrl+Z.

switch (config)# line vty 0 4

switch (config-line)# password xxxx(xxxx是Telnet用户登录口令)

switch (config-line)# exit

switch (config)# enable password xxxx(xxxx特权用户模式的口令)


4.设置 交换机内部时钟

switch#show clock

* 18:37:04.104 UTC Mon Jul 30 2008

switch# clock set 9:00:00 Jan 1 2001

switch#show clock

09:00:04.123 UTC Mon Jan 1 2008


5.设置secret登录命令:

switch(config)# enable secret  ASB

switch(config)#exit

switch#show running-config

     ……….

Enable secret 5 $1228899030dieiiop

    ……….

#同样配置telnet和console的口令,并加密(service password-encryption).

switch(config)# service password-encryption

switch(config)#line console 0

switch(config-line)#password xxxxxx

switch(config-line)#line vty 0 4

switch(config-line)#password yyyyyy

switch(config-line)#login

switch(cnfig-line)#end


6.设置交换机日志信息

(1)输出 : 分为Console、Telnet、Buffer、Host四个方向。

(2)日志等级分为8级,0级最高.使用logging buffer level 修改记录等级。

           emergency  0   紧急:系统不可用

           alert   1   告警:需要立即行动

           critical   2   关键:关键状态

           error   3   错误:错误状态

           warning 4   警告:警告状态

           notification   5   通知:正常但重要状态

           informational  6   信息:仅是信息消息

           debug   7   调试:调试消息

 

switch(config)#logging buffered  //把日志记录到buffer中的配置命令.

switch(config)#logging buffered informational  //等级为6,informational

switchr(config)#show logging  //显示buffer中的logging信息.

switch(config)# service timestamps log datetime  //给日志信息打时间标记


7.设置交换机SNMP信息

switch(config)# access-list 10 permit 172.18.129.100  log

  //配置snmp访问控制列表

switch(config)# snmp-server community ********** RW 10

 //配置读写字符串

switch(config)# snmp-server trap-source Vlan1000

  //配置trap的源地址

switch(config)# snmp-server host 172.18.129.100 **********

  //配置接收trap的主机地址及特定字符串


8.打开和关闭端口

//缺省状态下,端口是关闭的

Switch(config)#interface fastethernet 0/1

Switch(config-if)#shutdown           //关闭端口

Switch(config)#interface fastethernet 0/1

Switch(config-if))#no shutdown    //打开端口


9.设置端口描述

# 描述命令说明了以太网端口的作用.

Switch(config)#interface fastethernet 0/1

Switch(config-if)#description : connected to CC1


10.设置端口双工状态

Switch(config)#interface fastethernet 0/1

Switch(config-if)# duplex { half | full | auto }

//其中half为半双工,full为全双工,auto为自动协商。


11.设置端口速率(流量设置)

Switch(config)#interface fastethernet 0/1

Switch(config-if)# speed { 10 | 100 | 1000 | auto}

//其中10为10M,100为100M,1000为1000M,auto为自动协商。

Switch(config-if)#no speed

//恢复端口缺省速率配置。


12.设置以太网端口的工作模式(access和trunk)

 // 指明端口工作在access模式下

Switch(config-if)#switchport mode access

//指明端口工作在trunk模式下

Switch(config-if)#switchport mode trunk

   

说明 :

   0、以太网端口有二种工作模式:Access和Trunk。

1、端口工作在Access模式下只能属于1个VLAN,一般用于接用户计算机的端口;

 2、端口工作在Trunk模式下可以属于多个VLAN,可以接收和发送多个VLAN的报文,一般用于交换机之间连接的端口;

3、可以使用switchport access vlan  vlan_number指明端口属于什么vlan。


12. 设置链路聚合(EtherChannel)

switch(config)#interface fastethernet 0/1

switch(config-if)# channel- group channel-group-number mode {auto [non-silent] | desirable [non-silent] | on}

 

注意 :

1、快速以太网信道链路上的所有端口必须是同一个VLAN的成员,或者必须是Trunk端口。

2、如果快速以太网信道链路内的端口是trunk端口,则这些端口必须有相同的vlan范围。

3、快速以太网信道链路内的所有端口的速度和双工模式设置必须相同。


13.trunk配置及封装

switch(config)#interface GigabitEthernet1/0/2

switch(config-if)# switchport trunk encapsulation dot1q

switch(config-if)# switchport mode trunk

1、接入(access)链路:接入链路只是一个VLAN的成员。这个VLAN被称为端口的本地VLAN。连接到这个端口上的设备完全不知道存着一个VLAN。设备只是根据被配置在该设备上的第3层信息认为它是网络或子网的一部分。为了保证使它不需要知道VLAN的存在,交换机负责在帧被发送到未端设备之前将VLAN信息从帧中拿掉。接入链路是属于一个、并且只属于一个VLAN的端口,这个端口不能从另一个VLAN接收信息,除非该信息已经选择过路由了。这个端口也不能发送信息到另一个VLAN,除非这个端口可以访问路由器。

2、干道(trunk)链路:干道链路可以承载多个VLAN。干道链路的得名是来自电话系统中的干道(trunk),它们能够传输多个电话对话。干道链路通常被用来将交换机连接到其他交换机,或者将交换机连接到路由器。Cisco在快速以太网和千兆以太网端口上支持干道链路。

     目前Cisco所使用的有两种标识技术如下:

 a、Cisco交换机间链路(ISL): 用于互连多台交换机的cisco专有封装协议。该该协议在  Catalyst 交换机和路由器上被支持

 b、IEEE802.1Q标准:它通过 在帧头插入一个VLAN标识符来标识VLAN。


14.配置二层、三层VLAN

//创建vlan

switch#vlan database

switch(config-vlan)# vlan valn_id name vlan_name

switch(config-vlan)# no vlan vlan_id

//创建三层vlan

switch(config)# interface vlan_id

switch(config-vlan)# ip address 172.168.1.1 255.255.255.0

switch(config-vlan)# no shutdown

//端口加入vlan

switch(config)# interface g1/0/10

Switch(config-if)#switchport mode access

Switch(config-if)#switchport access vlan vlan_id

Switch(config-if)#no shutdown


15.HSRP配置

//主交换机上standby的配置

interface Vlan10

description "uplink"

ip address 172.18.128.53 255.255.255.248

standby 10 ip 172.18.128.50            //standby_id=10,standby_ip= 172.18.128.50

standby 10 priority 105                      //配置优先级,数值越大,优先级越高

standby 10 preempt                         //配置抢占模式

//从交换机上standby的配置

interface Vlan10

description "uplink"

ip address 172.18.128.54 255.255.255.248

standby 10 ip 172.18.128.50

查看命令:show standby


16.VTP配置

switch#vlan database

switch(config-vlan)# vtp domain domain-name

switch(config-vlan)# vtp mode { server | client | transparent }

 

说明 :

    1、VTP(VLAN Trunk Protocol,VLAN干道协议)的功能与GVRP(IEEE 802.1Q的标准协议)相同。

2、VTP Server维护该VTP域中所有VLAN信息列表,可以增加、删除或修改VLAN。

3、VTP Client也维护该VTP域中所有VLAN信息列表,但不能增加、删除或修改VLAN,任何变化的信息必须从VTP Server发布的通告报文中接收。

4、VTP Transparent不参与VTP工作,它虽然忽略所有接收到的VTP信息,但能够将接收到的VTP报文转发出去。它只拥有本设备上的VLAN信息。

5、其中,VTP Server和VTP Client必须处于同一个VTP域,且一个交换机只能位于一个VTP域中。

6、同一个VTP域内的所有交换机的域名必须相同;

7、同一个VTP域内的交换机必须邻接;

8、同一个VTP域内的邻接交换机之间的Trunk链路必须激活。

    9、VTP的版本号是用来同步整个交换VLAN的信息的,只有VTP的Server上的高配置版本号才能同步低的,相同配置版本号的两个VLAN数据库不会更新对方,可以使用以下几种办法可以清除VTP的版本号:

        a.将VTP的域名改掉,再改回来;

        b.将VTP的版本号改掉,再改回来;

        c.将VTP的模式改为透明模式,再改回来。


17.配置生成树协议

//配置根网桥:

switch(config)# spanning-tree vlan vlan-id root primary [diameter net-diameter [hello-time seconds]]

//配置备用根网桥:

switch(config)# spanning-tree vlan vlan-id root secondary [diameter net-diameter [hello-time seconds]]

//修改端口优先级:

switch(config)#interface interface-id

switch(config-if)# spanning-tree port-priority priority

//修改端口路径开销:

switch(config)#interface interface-id

switch(config-if)# spanning-tree cost cost

 

STP的基本原理是,通过在交换机之间传递一种特殊的协议报文(IEEE 802.1D协议将这种协议报文称为“配置消息”)来确定网络的拓扑结构。配置消息中包含了足够的信息来保证交换机完成生成树计算。

配置消息中主要包括以下内容:

树根的ID:由树根的优先级和MAC地址组合而成;

到树根的最短路径开销;

指定交换机的ID:由指定交换机的优先级和MAC地址组合而成;

指定端口的ID:由指定端口的优先级和端口编号组成

配置消息的生存期:MessageAge;

配置消息的最大生存期:MaxAge;

配置消息发送的周期:HelloTime;

端口状态迁移的延时:ForwardDelay。


18.静态路由设置

配置静态路由示例:

ip route 0.0.0.0 0.0.0.0 172.18.128.49

删除静态路由示例

no ip route 0.0.0.0 0.0.0.0 172.18.128.49


19.动态路由设置

OSPF路由设置

router ospf添加ospf路由配置

no router ospf删除ospf路由配置

RIP路由设置

router rip添加rip路由配置

no router rip删除rip路由配置

EIGRP路由配置

Router eigrp添加eigrp路由配置

no router eigrp删除eigrp路由配置

原创文章 46 获赞 36 访问量 8万+

猜你喜欢

转载自blog.csdn.net/istrangeboy/article/details/92340724