銳捷交換機配置命令

銳捷交換機配置命令

交換機基本操作
1.進入特權模式
Switch>enable
Switch#
2.返回用戶模式
Switch#exit
Press RETURN to get started!
Switch>
配置模式:
全局配置模式[主機名(config)#]:配置交換機的整體參數
子模式:
1.線路配置模式[主機名(config-line)#]:配置交換機的線路參數
2.接口配置模式[主機名(config-if)#]:配置交換機的接口參數

1.進入全局配置模式下
Switch#configure terminal
Switch(config)#exit
Switch#
2.進入線路配置模式
Switch(config)#line console 0
Switch(config-line)#exit
Switch(config)#
3.進入接口配置模式
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#exit
Switch(config)#

從子模式下直接返回特權模式
Switch(config-if)#end
Switch#

交換機操作幫助特點:
1.支持命令簡寫(按TAB鍵將命令補充完整)
2.在每種操作模式下直接輸入“?”顯示該模式下所有的命令
3.命令空格 “?”顯示命令參數並對其解釋說明
4.字符“?”顯示以該字符開頭的命令
5.命令歷史緩存: (Ctrl+P)顯示上一條命令,(Ctrl+N)顯示下一條命令
6.錯誤提示信息

交換機顯示命令:
顯示交換機硬件及軟件的信息 Switch#show version
顯示當前運行的配置參數 Switch#show running-config
顯示保存的配置參數 Switch#show configure

常用交換機EXEC命令
將當前運行的配置參數複製到flash:Switch#write memory
Building configuration…
[OK]
Switch#
清空flash中的配置參數:Switch#delete flash:config.text
Switch#
交換機重新啓動:Switch#reload
System configuration has been modified. Save? [yes/no]:n
Proceed with reload? [confirm]

配置交換機主機名:Switch(config)#hostname S2126G
S2126G(config)#

配置交換機口令:
1、 配置交換機的登陸密碼
S2126G(config)#enable secret level 1 0 star
“0”表示輸入的是明文形式的口令
2、 配置交換機的特權密碼
S2126G(config)#enable secret level 15 0 Star
“0”表示輸入的是明文形式的口令

常用交換機配置命令:
1、爲交換機分配管理IP地址
S2126G(config)#interface vlan 1
S2126G(config-if)#ip address {IP address} {IP subnetmask}[secondary]
2、將接口啓用
S2126G(config-if)#no shutdown
3、將接口關閉
S2126G(config-if)#shutdown
4、配置接口速率
S2126G(config-if)#speed [10|100|auto]
5、配置接口雙工模式
S2126G(config-if)#duplex [auto|full|half

顯示接口狀態:S2126G#show interfaces
測定目的端的可達性:S2126G>ping {IP address}
從TFTP服務器下載配置參數:S2126G#copy tftp startup-config
管理交換機MAC地址表:
1、查看MAC地址表
S2126G#show mac-address-table
2、配置MAC地址表記錄的生存時間(缺省爲300秒)
S2126G(config)#mac-address-table aging-time <10-1000000>
3、查看MAC地址表記錄的生存時間
S2126G#show mac-address-table aging-time

VLAN的配置:
1.添加一個VLAN
S2126G(config)#vlan <1-4094>
S2126G(config-vlan)#
2.爲VLAN命名(可選)
S2126G(config-vlan)#name
將交換機端口分配到VLAN
1.配置Port VLAN
Switch(config-if)#switchport access vlan <1-4094>
2.配置Tag VLAN
Switch(config-if)#switchport mode trunk
1).配置本地(native)VLAN
Switch(config-if)#switchport trunk native vlan <1-4094>
2).從主幹鏈路中清除VLAN
Switch(config-if)#switchport trunk allowed vlan except
注:VLAN1不可被清除
VLAN的驗證:
1.顯示全部的VLAN:Switch#show vlan
2.顯示單獨的VLAN :Switch#show vlan id <1-4094>

將VLAN信息保存到flash中:Switch#write memory
從flash中清除VLAN信息:Switch#delete flash:vlan.dat
RSTP的配置:
1.啓用生成樹:S2126G(config)#spanning-tree
2.配置交換機優先級:S2126G(config)#spanning-tree priority <0-61440>
“0”或“4096”的倍數(RSTP BPDU該值後12bit全0)
3.配置交換機端口優先級:S2126G(config-if)#spanning-tree port-priority <0-240>
“0”或“16”的倍數(RSTP BPDU該值後4bit全0)
4、生成樹hello時間的配置(由Root決定):S2126G(config)#spanning-tree hello-time <1-10>
5、生成樹的驗證:Switch#show spanning-tree
Switch#show spanning-tree interface <接口名稱> <接口編號>
以上用於銳捷交換機的。

交換機配置命令集

>Enable 進入特權模式
  #ExIT 返回上一級操作模式
  #End 返回到特權模式
  #write memory 或copy running-config startup-config 保存配置文件
  #del flash:config.text 刪除配置文件(交換機及1700系列路由器)
  #erase startup-config 刪除配置文件(2500系列路由器)
  #del flash:vlan.dat 刪除Vlan配置信息(交換機)
  #Configure terminal 進入全局配置模式
  (config)# hostname switchA 配置設備名稱爲switchA
  (config)#banner motd & 配置每日提示信息 &爲終止符
  (config)#enable secret level 1 0 star 配置遠程登陸密碼爲star
  (config)#enable secret level 15 0 star 配置特權密碼爲star
  Level 1爲普通用戶級別,可選爲1~15,15爲最高權限級別;0表示密碼不加密
  (config)#enable services web-server 開啓交換機WEB管理功能
  Services 可選以下:web-server(WEB管理)、telnet-server(遠程登陸)等

查看信息
  #show running-config 查看當前生效的配置信息
  #show interface fastethernet 0/3 查看F0/3端口信息
  #show interface serial 1/2 查看S1/2端口信息
  #show interface 查看所有端口信息
  #show ip interface brief 以簡潔方式彙總查看所有端口信息
  #show ip interface 查看所有端口信息
  #show version 查看版本信息
  #show mac-address-table 查看交換機當前MAC地址表信息
  #show running-config 查看當前生效的配置信息
  #show vlan 查看所有VLAN信息
  #show vlan id 10 查看某一VLAN (如VLAN10)的信息
  #show interface fastethernet 0/1 switchport 查看某一端口模式(如F 0/1)
  #show aggregateport 1 summary 查看聚合端口AG1的信息
  #show spanning-tree 查看生成樹配置信息
  #show spanning-tree interface fastethernet 0/1 查看該端口的生成樹狀態
  #show port-security 查看交換機的端口安全配置信息
  #show port-security address 查看地址安全綁定配置信息
  #show ip access-lists listname 查看名爲listname的列表的配置信息
  #show access-lists

端口的基本配置
  (config)#Interface fastethernet 0/3 進入F0/3的端口配置模式
  (config)#interface range fa 0/1-2,0/5,0/7-9 進入F0/1、F0/2、F0/5、F0/7、F0/8、F0/9的端口配置模式
  (config-if)#speed 10 配置端口速率爲10M,可選10,100,auto
  (config-if)#duplex full 配置端口爲全雙工模式,可選full(全雙工),half(半雙式),auto(自適應)
  (config-if)#no shutdown 開啓該端口
  (config-if)#switchport access vlan 10 將該端口劃入VLAN10中,用於VLAN
  (config-if)#switchport mode trunk 將該端口設爲trunk模式,用於Tag vlan
  可選模式爲access , trunk
  (config-if)#port-group 1 將該端口劃入聚合端口AG1中,用於聚合端口

聚合端口的創建
  (config)# interface aggregateport 1 創建聚合接口AG1
  (config-if)# switchport mode trunk 配置並保證AG1爲 trunk 模式
  (config)#int f0/23-24
  (config-if-range)#port-group 1 將端口(端口組)劃入聚合端口AG1中

生成樹
  (config)#spanning-tree 開啓生成樹協議
  (config)#spanning-tree mode stp 指定生成樹類型爲stp
  可選模式stp , rstp , mstp
  (config)#spanning-tree priority 4096 設置交換機的優先級爲4096 , 優先級值小爲高。優先級可選值爲0,4096,8192,……,爲4096的倍數。交換機默認值爲32768

VLAN的基本配置
  (config)#vlan 10 創建VLAN10
  (config-vlan)#name vlanname 命名VLAN爲vlanname
  (config-if)#switchport access vlan 10 將該端口劃入VLAN10中
  某端口的接口配置模式下進行
  (config)#interface vlan 10 進入VLAN 10的虛擬端口配置模式
  (config-if)# ip address 192.168.1.1 255.255.255.0 爲VLAN10的虛擬端口配置IP及掩碼,二層交換機只能配置一個IP,此IP是作爲管理IP使用,例如,使用Telnet的方式登錄的IP地址
  (config-if)# no shutdown 啓用該端口

端口安全
  (config)# interface fastethernet 0/1 進入一個端口
  (config-if)# switchport port-security 開啓該端口的安全功能
  1.配置最大連接數限制
  (config-if)# switchport port-secruity maxmum 1 配置端口的最大連接數爲1,最大連接數爲128
  (config-if)# switchport port-secruity violation shutdown
  配置安全違例的處理方式爲shutdown,可選爲protect (當安全地址數滿後,將未知名地址丟棄)、restrict(當違例時,發送一個Trap通知)、shutdown(當違例時將端口關閉,併發送Trap通知,可在全局模式下用errdisable recovery來恢復)
  2.IP和MAC地址綁定
  (config-if)#switchport port-security mac-address xxxx.xxxx.xxxx ip-address 172.16.1.1
  接口配置模式下配置MAC地址xxxx.xxxx.xxxx和IP172.16.1.1進行綁定(MAC地址注意用小寫)

三層路由功能(針對三層交換機)
  (config)# ip routing 開啓三層交換機的路由功能
  (config)# interface fastethernet 0/1
  (config-if)# no switchport 開啓端口的三層路由功能(這樣就可以爲某一端口配置IP)
  (config-if)# ip address 192.168.1.1 255.255.255.0
  (config-if)# no shutdown
  三層交換機路由協議
  (config)# ip route 172.16.1.0 255.255.255.0 172.16.2.1 配置靜態路由
  注:172.16.1.0 255.255.255.0 爲目標網絡的網絡號及子網掩碼
  172.16.2.1 爲下一跳的地址,也可用接口表示,如ip route 172.16.1.0 255.255.255.0 serial 1/2(172.16.2.0所接的端口)
  (config)# router rip 開啓RIP協議進程
  (config-router)# network 172.16.1.0 申明本設備的直連網段信息
  (config-router)# version 2 開啓RIP V2,可選爲version 1(RIPV1)、version 2(RIPV2)
  (config-router)# no auto-summary 關閉路由信息的自動彙總功能(只有在RIPV2支持)

(config)# router ospf 開啓OSPF路由協議進程(針對1762,無需使用進程ID)
  (config)# router ospf 1 開啓OSPF路由協議進程(針對2501,需要加OSPF進程ID)
  (config-router)# network 192.168.1.0 0.0.0.255 area 0
  申明直連網段信息,並分配區域號(area0爲骨幹區域)

IP ACL:
  交換機採用命名的訪問控制列表;分標準(stand)和擴展(extended)兩種
  1.標準ACL
  (config)#ip access-list stand listname 定義命名標準列表,命名爲listname,stand爲標準列表
  (config-std-nacl)#deny 192.168.30.0 0.0.0.255 拒絕來自192.168.30.0網段的IP流量通過
  注:deny:拒絕通過;可選:deny(拒絕通過)、permit(允許通過)
  192.168.30.0 0.0.0.255:源地址及源地址通配符;可使用any表示任何IP
  (config-std-nacl)#permit any
  (config-std-nacl)#end 返回
  2.擴展ACL
  (config)#ip access-list extended listname
  定義命名擴展列表,命名爲listname,extended爲擴展
  (config-ext-nacl)#deny tcp 192.168.30.0 0.0.0.255 192.168.10.0 0.0.0.255 eq www 拒絕源地址爲192.168.30.0網段的IP訪問目的地址爲192.168.10.0網段的WWW服務
  注:deny:拒絕通過,可選:deny(拒絕通過)、permit(允許通過)
  tcp: 協議名稱,協議可以是udp, ip,eigrp, gre, icmp, igmp, igrp等等。
  192.168.10.0 0.0.0.255:源地址及源地址通配符
  192.168.30.0 0.0.0.255:目的地址及目的地址通配符
  eq:操作符(lt-小於,eq-等於,gt-大於,neg-不等於,range-包含)
  www:端口號,可使用名稱或具體編號
  可以使用的協議名稱(或編號)和端口名稱(或編號)請打?查詢。
  (config-ext-nacl)#permit ip any any 允許其它通過
  (config-ext-nacl)#end 返回
  (config)#interface vlan 10 進入端口配置模式
  (config-if)# ip access-group listname in 訪問控制列表在端口下in方向應用;可選:in(入棧)、out(出棧)
  (config-if)#end 返回
  注:配置ACL時,若只想對其中部分IP進行限制訪問時,必須配置允許其流量通過,否則設備只會對限制IP進行處理,不會對非限制IP進行允許通過處理。

銳捷網絡交換機的配置命令集

交換機

>Enable 進入特權模式
  #Exit 返回上一級操作模式
  #End 返回到特權模式
  #write memory 或copy running-config startup-config 保存配置文件
  #del flash:config.text 刪除配置文件(交換機及1700系列路由器)
  #erase startup-config 刪除配置文件(2500系列路由器)
  #del flash:vlan.dat 刪除Vlan配置信息(交換機)
  #Configure terminal 進入全局配置模式
  (config)# hostname switchA 配置設備名稱爲switchA
  (config)#banner motd & 配置每日提示信息 &爲終止符
  (config)#enable secret level 1 0 star 配置遠程登陸密碼爲star
  (config)#enable secret level 15 0 star 配置特權密碼爲star
  Level 1爲普通用戶級別,可選爲1~15,15爲最高權限級別;0表示密碼不加密
  (config)#enable services web-server 開啓交換機WEB管理功能
  Services 可選以下:web-server(WEB管理)、telnet-server(遠程登陸)等

查看信息
  #show running-config 查看當前生效的配置信息
  #show interface fastethernet 0/3 查看F0/3端口信息
  #show interface serial 1/2 查看S1/2端口信息
  #show interface 查看所有端口信息
  #show ip interface brief 以簡潔方式彙總查看所有端口信息
  #show ip interface 查看所有端口信息
  #show version 查看版本信息
  #show mac-address-table 查看交換機當前MAC地址表信息
  #show running-config 查看當前生效的配置信息
  #show vlan 查看所有VLAN信息
  #show vlan id 10 查看某一VLAN (如VLAN10)的信息
  #show interface fastethernet 0/1 switchport 查看某一端口模式(如F 0/1)
  #show aggregateport 1 summary 查看聚合端口AG1的信息
  #show spanning-tree 查看生成樹配置信息
  #show spanning-tree interface fastethernet 0/1 查看該端口的生成樹狀態
  #show port-security 查看交換機的端口安全配置信息
  #show port-security address 查看地址安全綁定配置信息
  #show ip access-lists listname 查看名爲listname的列表的配置信息
  #show access-lists

端口的基本配置
  (config)#Interface fastethernet 0/3 進入F0/3的端口配置模式
  (config)#interface range fa 0/1-2,0/5,0/7-9 進入F0/1、F0/2、F0/5、F0/7、F0/8、F0/9的端口配置模式
  (config-if)#speed 10 配置端口速率爲10M,可選10,100,auto
  (config-if)#duplex full 配置端口爲全雙工模式,可選full(全雙工),half(半雙式),auto(自適應)
  (config-if)#no shutdown 開啓該端口
  (config-if)#switchport access vlan 10 將該端口劃入VLAN10中,用於VLAN
  (config-if)#switchport mode trunk 將該端口設爲trunk模式,用於Tag vlan
  可選模式爲access , trunk
  (config-if)#port-group 1 將該端口劃入聚合端口AG1中,用於聚合端口

聚合端口的創建
  (config)# interface aggregateport 1 創建聚合接口AG1
  (config-if)# switchport mode trunk 配置並保證AG1爲 trunk 模式
  (config)#int f0/23-24
  (config-if-range)#port-group 1 將端口(端口組)劃入聚合端口AG1中

生成樹
  (config)#spanning-tree 開啓生成樹協議
  (config)#spanning-tree mode stp 指定生成樹類型爲stp
  可選模式stp , rstp , mstp
  (config)#spanning-tree priority 4096 設置交換機的優先級爲4096 , 優先級值小爲高。優先級可選值爲0,4096,8192,……,爲4096的倍數。交換機默認值爲32768

VLAN的基本配置
  (config)#vlan 10 創建VLAN10
  (config-vlan)#name vlanname 命名VLAN爲vlanname
  (config-if)#switchport access vlan 10 將該端口劃入VLAN10中
  某端口的接口配置模式下進行
  (config)#interface vlan 10 進入VLAN 10的虛擬端口配置模式
  (config-if)# ip address 192.168.1.1 255.255.255.0 爲VLAN10的虛擬端口配置IP及掩碼,二層交換機只能配置一個IP,此IP是作爲管理IP使用,例如,使用Telnet的方式登錄的IP地址
  (config-if)# no shutdown 啓用該端口

端口安全
  (config)# interface fastethernet 0/1 進入一個端口
  (config-if)# switchport port-security 開啓該端口的安全功能
  1.配置最大連接數限制
  (config-if)# switchport port-secruity maxmum 1 配置端口的最大連接數爲1,最大連接數爲128
  (config-if)# switchport port-secruity violation shutdown
  配置安全違例的處理方式爲shutdown,可選爲protect (當安全地址數滿後,將未知名地址丟棄)、restrict(當違例時,發送一個Trap通知)、shutdown(當違例時將端口關閉,併發送Trap通知,可在全局模式下用errdisable recovery來恢復)
  2.IP和MAC地址綁定
  (config-if)#switchport port-security mac-address xxxx.xxxx.xxxx ip-address 172.16.1.1
  接口配置模式下配置MAC地址xxxx.xxxx.xxxx和IP172.16.1.1進行綁定(MAC地址注意用小寫)

三層路由功能(針對三層交換機)
  (config)# ip routing 開啓三層交換機的路由功能
  (config)# interface fastethernet 0/1
  (config-if)# no switchport 開啓端口的三層路由功能(這樣就可以爲某一端口配置IP)
  (config-if)# ip address 192.168.1.1 255.255.255.0
  (config-if)# no shutdown
  三層交換機路由協議
  (config)# ip route 172.16.1.0 255.255.255.0 172.16.2.1 配置靜態路由
  注:172.16.1.0 255.255.255.0 爲目標網絡的網絡號及子網掩碼
  172.16.2.1 爲下一跳的地址,也可用接口表示,如ip route 172.16.1.0 255.255.255.0 serial 1/2(172.16.2.0所接的端口)
  (config)# router rip 開啓RIP協議進程
  (config-router)# network 172.16.1.0 申明本設備的直連網段信息
  (config-router)# version 2 開啓RIP V2,可選爲version 1(RIPV1)、version 2(RIPV2)
  (config-router)# no auto-summary 關閉路由信息的自動彙總功能(只有在RIPV2支持)

(config)# router ospf 開啓OSPF路由協議進程(針對1762,無需使用進程ID)
  (config)# router ospf 1 開啓OSPF路由協議進程(針對2501,需要加OSPF進程ID)
  (config-router)# network 192.168.1.0 0.0.0.255 area 0
  申明直連網段信息,並分配區域號(area0爲骨幹區域)

IP ACL:
  交換機採用命名的訪問控制列表;分標準(stand)和擴展(extended)兩種
  1.標準ACL
  (config)#ip access-list stand listname 定義命名標準列表,命名爲listname,stand爲標準列表
  (config-std-nacl)#deny 192.168.30.0 0.0.0.255 拒絕來自192.168.30.0網段的IP流量通過
  注:deny:拒絕通過;可選:deny(拒絕通過)、permit(允許通過)
  192.168.30.0 0.0.0.255:源地址及源地址通配符;可使用any表示任何IP
  (config-std-nacl)#permit any
  (config-std-nacl)#end 返回
  2.擴展ACL
  (config)#ip access-list extended listname
  定義命名擴展列表,命名爲listname,extended爲擴展
  (config-ext-nacl)#deny tcp 192.168.30.0 0.0.0.255 192.168.10.0 0.0.0.255 eq www 拒絕源地址爲192.168.30.0網段的IP訪問目的地址爲192.168.10.0網段的WWW服務
  注:deny:拒絕通過,可選:deny(拒絕通過)、permit(允許通過)
  tcp: 協議名稱,協議可以是udp, ip,eigrp, gre, icmp, igmp, igrp等等。
  192.168.10.0 0.0.0.255:源地址及源地址通配符
  192.168.30.0 0.0.0.255:目的地址及目的地址通配符
  eq:操作符(lt-小於,eq-等於,gt-大於,neg-不等於,range-包含)
  www:端口號,可使用名稱或具體編號
  可以使用的協議名稱(或編號)和端口名稱(或編號)請打?查詢。
  (config-ext-nacl)#permit ip any any 允許其它通過
  (config-ext-nacl)#end 返回
  (config)#interface vlan 10 進入端口配置模式
  (config-if)# ip access-group listname in 訪問控制列表在端口下in方向應用;可選:in(入棧)、out(出棧)
  (config-if)#end 返回
  注:配置ACL時,若只想對其中部分IP進行限制訪問時,必須配置允許其流量通過,否則設備只會對限制IP進行處理,不會對非限制IP進行允許通過處理。

在銳捷交換機上配置vrrp、arp和mstp

交換機

密碼
1234(config)#enable secret level 1 0 100
1234(config)#enable secret level 15 0 100
遠程登入密碼
1234(config)#line vty 0 4
1234(config-line)#password 100
1234(config-line)#end
交換機管理IP
1234(config)#interface vlan 1
1234(config-if)#ip address 192.168.1.10 255.255.255.0
1234(config-if)#no shutdown
修改交換機老化時間
1234(config)#mac-address-table aging-time 20
1234(config)#end
添刪vlan
1234(config)#vlan 888
1234(config-vlan)#name a888
1234(config)#no vlan 888
添加access口
1234(config)#interface gigabitEthernet 0/10
1234(config-if)#switchport mode access
1234(config-if)#switchport access vlan 10
切換assess trunk
1234(config-if)#switchport mode access
1234(config-if)#switchport mode trunk
指定特定一個native vlan
1234(config-if)#switchport trunk native vlan 10
配置trunk口的許可vlan列表
1234(config-if)#switchport trunk allowed vlan ?
add Add VLANs to the current list
all All VLANs
except All VLANs except the following
remove Remove VLANs from the current list
速成樹協議
1234(config)#spanning-tree
1234(config)#spanning-tree mode rstp/stp
配置網關:
switch(config)#ip default-gateway 192.168.1.254
交換機基本配置-常見查看命令
查看CPU利用率
show cpu
查看交換機時鐘
show clock
查看交換機日誌
show logging
查看交換機動態學習到的MAC地址表
show mac-address-table dynamic
查看當前交換機運行的配置文件
show running-config
查看交換機硬件、軟件信息
show version
查看交換機的arp表
show arp
顯示接口詳細信息的命令
show interfaces gigabitEthernet 4/1 counters
接口配置
Switch(config)#interface gigabitethernet 0/1
把接口工作模式改爲光口。
Switch(config-if)#medium-type fiber
把接口工作模式改爲電口。
Switch(config-if)#medium-type copper
速度/雙工配置
進入接口配置模式。
Switch(config)#interface interface-id
設置接口的速率參數,或者設置爲auto。
Switch(config-if)#speed {10 | 100 | 1000 | auto }
設置接口的雙工模式。
Switch(config-if)#duplex {auto | full | half}
例子
Switch(config)#interface gigabitethernet 0/1
Switch(config-if)#speed 1000
Switch(config-if)#duplex full
光口不能修改速度和雙工配置,只能auto。
在故障處理的時候,如果遇到規律性的時斷時續或掉包,在排除其他原因後,可以考慮是否和對端設備的速率和雙工模式不匹配,尤其是兩端設備爲不同廠商的時候。
VLAN
建立VLAN 100
Switch (config)#vlan 100
該VLAN名稱爲ruijie
Switch (config)#name ruijie
將交換機接口劃入VLAN 中:
range表示選取了系列端口1-48,這個對多個端口進行相同配置時非常有用。
Switch (config)#interface range f 0/1-48
將接口劃到VLAN 100中。
Switch (config-if-range)#switchport access vlan 100
將接口劃回到默認VLAN 1中,即端口初始配置。
Switch (config-if-range)#no switchport access vlan
Switch(config)#interface fastEthernet 0/1
該端口工作在access模式下
Switch(config-if)#switchport mode access
該端口工作在trunk模式下
Switch(config-if)#switchport mode trunk
Switch(config)#interface fastEthernet 0/2
設定VLAN要修剪的VLAN。
Switch(config-if)#switchport trunk allowed vlan remove 2-9,11-19,21-4094
取消端口下的VLAN修剪。
Switch(config-if)#no switchport trunk allowed vlan
生成樹
開啓生成樹協議。
Switch(config)#spanning-tree
禁止生成樹協議。
Switch(config)#no spanning-tree
配置生成樹優先級:
配置設備優先級爲4096。
Switch(config)#spanning-tree priority 4096
數值越低,優先級別越高。
端口鏡像
配置G0/2爲鏡像端口。
Switch (config)# monitor session 1 destination interface G 0/2
配置G0/1爲被鏡像端口,且出入雙向數據均被鏡像。
Switch (config)# monitor session 1 source interface G 0/1 both
去掉鏡像1。
Switch (config)# no monitor session 1
端口聚合
Switch(config)#interface fastEthernet 0/1
把端口f0/1加入到聚合組1中。
Switch (config-if)#port-group 1
把端口f0/1從聚合組1中去掉
Switch (config-if)#no port-group 1
建立ACL:
建立ACL訪問控制列表名爲ruijie,extend表示建立的是擴展訪
Switch(config)# Ip access-list exten ruijie
問控制列表。
添加ACL的規則:
禁止PING IP地址爲192.168.1.1的設備。
Switch (config-ext-nacl)#deny icmp any 192.168.1.1 255.255.255.0
禁止端口號爲135的應用。
Switch (config-ext-nacl)# deny tcp any any eq 135
禁止協議爲www的應用。
Switch (config-ext-nacl)#deny udp any any eq www
允許所有行爲。
Switch(config-ext-nacl)# permit ip any any
將ACL應用到具體的接口上:
Switch (config)#interface range f 0/1
把名爲ruijie的ACL應用到端口f 0/1上。
Switch (config-if)#ip access-group ruijie in
從接口去除ACL。
Switch (config-if)#no ip access-group ruijie in
刪除ACL:
刪除名爲ruijie的ACL。
Switch(config)#no Ip access-list exten ruijie
增加ACE項後,是增加到ACL最後,不可以中間插入,如果要調整ACE的順序,必須整個刪除ACL後再重新配置。
端口安全
Switch (config)#interface range f 0/1
開啓端口安全。
Switch(config-if)# switchport port-security
關閉端口安全。
Switch(config-if)# no switchport port-security
設置端口能包含的最大安全地址數爲8。
Switch(config-if)# switchport port-security maximum 8
在接口fastethernet0/1配置一個安全地址00d0.f800.073c,併爲其綁定一個IP地址192.168.1.1
Switch(config-if)# switchport port-security mac-address 00d0.f800.073c ip-address 192.168.1.1
刪除接口上配置的安全地址。
Switch(config-if)#no switchport port-security mac-address 00d0.f800.073c ip-address 192.168.1.1
防ARP攻擊
IP和MAC地址的綁定
Switch(config)#arp ip-address hardware-address [type] interface-id
Switch(config)#arp 192.168.12.111 00d0.f800.073c arpa g 0/1
綁定網關
進入指定端口進行配置。
Switch(config)#Interface interface-id
配置防止ip-address的ARP欺騙。
Switch(config-if)#Anti-ARP-Spoofing ip ip-address
防STP攻擊
進入端口Fa0/1。
Switch(config)# inter fastEthernet 0/1
打開該端口的的BPDU guard功能。
Switch(config-if)# spanning-tree bpduguard enable
關閉該端口的的BPDU guard功能。
Switch(config-if)# spanning-tree bpduguard diaable
端口關閉後只能shutdown然後再no shutdown
或者重新啓動交換機才能恢復!
防DOS/DDOS攻擊
進入端口Fa0/1。
Switch(config)# inter fastEthernet 0/1
預防僞造源IP的DOS攻擊的入口過濾功能。
Switch(config-if)#ip deny spoofing-source
關閉入口過濾功能只能在三層接口上配置。
Switch(config-if)#no ip deny spoofing-source
和ACL不能同時存在。
端口關閉後只能shutdown然後再no shutdown
或者重新啓動交換機才能恢復!
防IP掃描攻擊配置:
打開系統保護。
Switch(config)#system-guard enable
關閉系統保護功能。
Switch(config)#no system-guard
DHCP配置
打開DHCP Relay Agent:
Switch(config)#service dhcp
配置DHCP Server的IP地址:
Switch(config)#ip helper-address address
VRRP配置
Switch(config)#Interface interface-id
Switch(config-if)#Standby [group-number] ip ip-address
設置虛擬機的優先級。
standby [group-number] priority priority
三層交換機配置
SVI:
把VLAN 10配置成SVI。
switch (config)#interface vlan 10
給該SVI接口配置一個IP地址
switch (config-if)#ip address 192.168.1.1 255.255.255.0
Routed Port:
switch (config)#interface fa 0/1
把f 0/1變成路由口。
switch (config-if)#no switch
路由配置:
添加一條路由。
switch (config)#ip route 目的地址 掩碼 下一跳
switch (config)#ip route 210.10.10.0 255.255.255.0 218.8.8.8

配置多生成樹協議:
switch(config)#spanning-tree //開啓生成樹協議
switch(config)#spanning-tree mst configuration //建立多生成樹協議
switch(config-mst)#name ruijie //命名爲ruijie
switch(config-mst)#revision 1 //設定校訂本爲1
switch(config-mst)#instance 0 vlan 10,20 //建立實例0
switch(config-mst)#instance 1 vlan 30,40 //建立實例1
switch(config)#spanning-tree mst 0 priority 4096 //設置優先級爲4096
switch(config)#spanning-tree mst 1 priority 8192 //設置優先級爲8192
switch(config)#interface vlan 10
switch(config-if)#vrrp 1 ip 192.168.10.1 //此爲vlan 10的IP地址
switch(config)#interface vlan 20
switch(config-if)#vrrp 1 ip 192.168.20.1 //此爲vlan 20的IP地址
switch(config)#interface vlan 30
switch(config-if)#vrrp 2 ip 192.168.30.1 //此爲vlan 30的IP地址(另一三層交換機)
switch(config)#interface vlan 40
switch(config-if)#vrrp 2 ip 192.168.40.1 //此爲vlan 40的IP地址(另一三層交換機)

此配置需在兩個三層交換機和二層交換機上進行配置!在二層交換機上不用配置VRRP!

冗餘鏈路

在骨幹網設備連接中,單一鏈路的連接很容易實現,但一個簡單的故障就會造成網絡的中斷.因此在實際網絡組建的過程中,爲了保持網絡的穩定性,在多臺交換機組成的網絡環境中,通常都使用一些備份連接,以提高網絡的健壯性、穩定性.
  這裏的備份連接也稱爲備份鏈路或者冗餘鏈路.備份鏈路之間的交換機經常互相連接,形成一個環路,通過環路可以在一定程度上實現冗餘.
  鏈路的冗餘備份能爲網絡帶來健壯性、穩定性和可靠性等好處,但是備份鏈路也會使網絡存在環路,環路問題是備份鏈路所面臨的最爲嚴重的問題,交換機之間的環路將導致網絡新問題的發生:
  廣播風暴
  多幀複製
  地址表的不穩定
  解決方法:
  生成樹協議避免環路
  每個LAN都會選擇一臺設備爲指定交換機,通過該設備的端口連接到根,該端口爲指定端口( Designated port )
  將交換網絡中所有設備的根端口(RP)和指定端口(DP)設爲轉發狀態(Forwarding),將其他端口設爲阻塞狀態(Blocking)
  生成樹經過一段時間(默認值是50秒左右)穩定之後,所有端口要麼進入轉發狀態,要麼進入阻塞狀態。
  IEEE 802.1w—快速生成樹協議
  快速生成樹協議概述
  快速生成樹協議RSTP(Rapid Spannning Tree Protocol) IEEE 802.1w
  RSTP協議在STP協議基礎上做了改進,使得收斂速度快得多(最快1秒以內)
  生成樹協議的配置
  開啓生成樹協議
  Switch(config)#Spanning-tree
  關閉生成樹協議
  Switch(config)#no Spanning-tree
  配置生成樹協議的類型
  Switch(config)#Spanning-tree mode stp/rstp
  銳捷全系列交換機默認使用MSTP協議
  配置交換機優先級
  Switch(config)#spanning-tree priority <0-61440>
  (“0”或“4096”的倍數、共16個、缺省32768)
  恢復到缺省值
  Switch(config)# no spanning-tree priority
  配置交換機端口的優先級
  Switch(config)#interface interface-type interface-number
  Switch(config-if)#spanning-tree port-priority number
  顯示生成樹狀態
  Switch#show spanning-tree
  顯示端口生成樹協議的狀態
  Switch#show spanning-tree interface fastethernet <0-2/1-24>
  生成樹協議概述
  生成樹協議(spanning-tree protocol)由IEEE 802.1d標準定義
  生成樹協議的作用是爲了提供冗餘鏈路,解決網絡環路問題
  生成樹協議通過SPA(生成樹算法)生成一個沒有環路的網絡,當主要鏈路出現故障時,能夠自動切換到備份鏈路,保證網絡的正常通信

公衆號:工程師江湖
獲取更多信息。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章