S21系列交換機常用配置的命令
1、交換機命名
示例1:
switch#config
switch(config)#hostnameS2126G
2、配置管理密碼
示例2:
S2126G(config)#enablesecretlevel10rg
//配置telnet管理密碼為rg
S2126G(config)#enablesecretlevel150rg
//配置特權模式下的管理密碼rg
3、給交換機(堆疊組)配置管理IP
示例3:
S2126G(config)#interfacevlan*//假設管理VLAN為VLAN*S2126G(config-if)#ipaddress192.168.1.1255.255.255.*//給管理VLAN配置管理IP地址
S2126G(config-if)#noshutdown
//激活管理IP
S2126G(config-if)#shutdown
//關閉管理IP
4、給交換機(堆疊組)配置網關
示例4:
S2126G(config)#ipdefault-gateway192.168.1.25*//假設網關地址為192.168.1.25*5、給交換機劃分VLAN
示例5:
S2126G(config)#vlan10*//建立VLAN10*S2126G(config)#nameStudent_A_*//該VLAN是學生宿舍A棟4樓的用戶VLAN
6、將交換機接口劃入VLAN100中
示例6:
S2126G(config)#interfacerangef1/0/1-48,2/0/1-4*S2126G(config-if-range)#switchportaccessvlan10*S2126G(config-if-range)#noswitchportaccessvlan
//將接口劃到默認VLAN1中
7、建立安全訪問控制列表(ACL)
示例7:S2126G(config)#ipaccess-listextendedmyAcl
//給ACL命名為myAcl
S2126G(config-ext-nacl)#denytcpanyanyeq44*S2126G(config-ext-nacl)#denyudpanyanyeq44*S2126G(config-ext-nacl)#permitipanyany
S2126G(config)#noipaccess-listextendedmyAcl
//去除myAcl的定義
8、將ACL應用到具體的接口上
示例8:
S2126G(config)#interfacerangef1/0/1-48,2/0/1-4*S2126G(config-if-range)#ipaccess-groupmyAclin
S2126G(config-if-range)#noipaccess-groupmyAclin
//從接口去除ACL
9、將接口工作模式定義為Trunk
示例9:
S2126G(config)#interfacegigabitEthernet1/0/*//假設堆疊組的上聯光纖口為1/0/*S2126G(config-if)#switchportmodetrunk
//將該接口工作模式定義為Trunk
S2126G(config-if)#noswitchportmode
//將該接口工作模式定義為Access
10、在S21上啟動STP/RSTP/MSTP協議
示例10:
S2126G(config)#spanning-tree
S2126G(config)#spanning-treemodeRSTP
//以RSTP為例
11、S21系列交換機直連PC或者HUB時,將該接口設置為portfast
示例11:
S2126G(config)#interfacerangef1/0/1-4*S2126G(config-if-range)#spanning-treeportfast
12、將上聯光纖口啟動過濾Bpdu報文功能,提高網絡的穩定性
示例12:
S2126G(config)#interfacegigabitEthernet1/0/*S2126G(config-if)#spanning-treebpdufilterenabled
S2126G(config-if)#spanning-treebpdufilterdisabled
//禁用Bpdu過濾功能
13、給交換機啟動SNMP協議,便于StarView網管工具發現
示例13:
S2126G(config)#snmp-servercommunitypublicro
14、開啟SSH服務
示例14:
S2126G(config)#enableservicesssh-server//開啟ssh
S2126G(config)#ipsshversion2//定義ssh的版本*S2126G(config)#usernameruijiepassword0ruijie//定義一個ssh登入用的用戶名&密碼
S2126G(config)#linevty
S2126G(config-line)#nologinlocal//如果showrun有該命令,就刪除,沒有就不用配置了
S2126G(config-line)#exi
15、端口鏡像(SPAN)
示例15:
S2126G(config)#monitorsession1sourceinterfacefastethernet4/1*S2126G(config)#monitorsession1filtervlan5*S2126G(config)#monitorsession1destinationinterfacefastethernet4/1*//監控端口FastEtheraet4/10上的雙向數據流(在該端口上承載著VLANl~VLANl005的數據流),只監控其中VLAN57中的數據流,端口
FastEthernet4/15為目的端口