銳捷交換機最近挺火,這段時間不斷的有朋友多次提到銳捷交換機的配置,本期我們來了解銳捷交換機的配置。本期內容共分為兩部分,第一部分是vlan的基礎配置命令,第二部分是銳捷交換機的配置例項,我們一起來看下,如何一步步的連線及配置銳捷交換機。
一、連線及遠端登陸
用一臺計算機作為控制檯和網路裝置相連,透過計算機對網路裝置進行配置。
1、硬體連線:
把Console線一端連線在計算機的序列口上,另一端連線在網路裝置的Console口上。
按照上面的線序製作一根雙絞線,一端透過一個轉接頭連線在計算機的序列口上,另一端連線在網路裝置的Console口上。
注意:不要把反轉線連線在網路裝置的其他介面上,這有可能導致裝置損壞。
2、軟體安裝:
在計算機上需要安裝一個終端模擬軟體來登入網路裝置。“超級終端”超級終端的安裝方法,通常使用
secureCRT軟體
較多。
按照提示的步驟進行安裝,其中連線的介面應選擇“COM1”,埠的速率應選擇“9600”,資料流控制應選擇“無”,其它都使用預設值。
登入後,就可以對網路裝置進行配置了。
二、基礎命令配置
連線上交換機後,肯定是需要進行命令配置,我們來看下基礎命令配置。
1、準備命令
>Enable //進入特權模式
#Exit //返回上一級操作模式
#End //返回到特權模式
#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(遠端登陸)等
2、檢視資訊
#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 //檢視某一埠模式(如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的列表的配置資訊
3、埠的基本配置
(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模式,可選模式為access , trunk
(config-if)#port-group 1 //將該埠劃入聚合埠AG1中,用於聚合埠
4、聚合埠的建立
(config)# interface aggregateport 1 //建立聚合介面AG1
(config-if)# switchport mode trunk //配置並保證AG1為 trunk 模式
(config)#int f0/23-24
(config-if-range)#port-group 1 //將埠(埠組)劃入聚合埠AG1中
5、生成樹
配置多生成樹協議:
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地址(另一三層交換機)
6、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 //啟用該埠
7、埠安全
(config)# interface fastethernet 0/1 //進入一個埠
(config-if)# switchport port-security //開啟該埠的安全功能
a、配置最大連線數限制
(config-if)# switchport port-secruity maxmum 1 //配置埠的最大連線數為1,最大連線數為128
(config-if)# switchport port-secruity violation shutdown
//配置安全違例的處理方式為shutdown,可選為protect (當安全地址數滿後,將未知名地址丟棄)、restrict(當違例時,傳送一個Trap通知)、shutdown(當違例時將埠關閉,併發送Trap通知,可在全域性模式下用errdisable recovery來恢復)
b、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地址注意用小寫)
8、三層路由功能(針對三層交換機)
(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
9、三層交換機路由協議
(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所接的埠)
三、銳捷交換機實現同vlan不同交換機的通訊
我們知道,同一個vlan在同一個交換機中,是完全可以通訊的,那麼對於同一個vlan在不同的交換機上,如果不做配置,是無法通訊的,我們來看下例項。
例項一:
如圖所示:
1、分析
兩臺交換機S1、S2利用VLAN分割了幾個虛擬區域網,S1中vlan1、vlan30與s2中的vlan1、vlan30雖然是同一個vlan,但他們卻不能直接通訊。那麼如何使vlan1、vlan30同vlan間可以通訊,不同vlan間不可以通訊呢?
要求:
在s1中建立vlan1、vlan20、vlan30,在s2中建立vlan1、vlan1,使用時屬於同一個VLAN的計算機之間可以通訊,屬於不同VLAN的計算機之間不能通訊。
2、配置
配置
S1
:
S1>enable //進入特權配置模式
S1#configure terminal //全域性配置模
! 建立VLAN20
S1(config)#vlan 20 //建立vlan20
S1(config-vlan)#name VLAN20 //給這個vlan命名vlan為vlan20
! 建立VLAN30
S1(config-vlan)#vlan 30
S1(config-vlan)#name VLAN30
S1(config-vlan)#exit
! 把F0/4~F0/7指派給VLAN20
S1(config)#interface f0/4 //進入埠f0/4
S1(config-if)#switchport access vlan 20 //把這個埠劃分給vlan20
S1(config-if)#interface f0/5 //進入埠f0/5
S1(config-if)#switchport access vlan 20
S1(config-if)#interface f0/6
S1(config-if)#switchport access vlan 20
S1(config-if)#interface f0/7
S1(config-if)#switchport access vlan 20
! 把F0/8~F0/11指派給VLAN30
S1(config-if)#interface f0/8 //進入埠f0/8
S1(config-if)#switchport access vlan 30 //把這個埠劃分給vlan30
S1(config-if)#interface f0/9
S1(config-if)#switchport access vlan 30
S1(config-if)#interface f0/10
S1(config-if)#switchport access vlan 30
S1(config-if)#interface f0/11
S1(config-if)#switchport access vlan 30
! 把F0/12配置為Trunk模式
S1(config-if)#interface f0/12 //進入埠f0/12
S1(config-if)#switchport mode trunk // 將埠f0/12設為trunk,如果交換機只有一個vlan。就使用access介面。如果交換機有多個vlan就必須使用trunk埠,因為trunk埠可封裝vlan標籤。
S1(config-if)#end //返回特權模式
! 檢視配置結果
S1#show vlan
! 儲存配置
S1#copy running-config startup-config
配置
S2
:
S2>enable
S2#configure terminal
! 建立VLAN30
S2(config)#vlan 30
S2(config-vlan)#name VLAN30
S2(config-vlan)#exit
! 把F0/1~F0/5指派給VLAN30
S2(config)#interface range f0/1-5 //將s2中的1到5埠劃分到vlan30,這個使用了埠簡化配置方式,當然也可以在1中使用。
S2(config-if)#switchport access vlan 30
! 把F0/12配置為Trunk模式
S2(config-if)#interface f0/12
S2(config-if)#switchport mode trunk // 將s2埠f0/12也設為trunk,如果交換機只有一個vlan。就使用access介面。如果交換機有多個vlan就必須使用trunk埠,因為trunk埠可封裝vlan標籤。
S2(config-if)#end
! 檢視配置結果
S2#show vlan
! 儲存配置
S2#copy running-config startup-config
細看的朋友可以發現,上面的案例配置看起來有這麼多行程式碼,其實就是4行關鍵的程式碼反覆的在使用,需要我們自己發揮的空間真的不大。
整體的配置路由就是:
進入配置模式——建立vlan——把相應的埠劃分相應的vlan中——但如果
為什麼上面配置的是trunk,而不是access呢?
配置trunk是為了讓同一VlAN跨交換機通訊,如果理解了這句話,那麼上面的配置案例非常簡單。
弱電 | 通訊 | 標準 | 最新
公眾號:武耀網路資訊科技