2010年3月21日 星期日

How to Control STP Block Port

SwA(config)# spanning-tree vlan 1 root primary
SwB(config)# spanning-tree vlan 1 root secondary
如果依照 圖上的 root priority 設定的話,預設block port 是在下方線路的其中一個port


這時,需在控制線路頻寬,已達到圖上所要的block port。
需設定 C ---> B ---> A 路徑成本 大於  C ---> D ---> A的成本。
此時走 c - b -a 的成本過高所以  C-B 線路會被block掉,那B的 priority 又高於 C
所以,Block port 就會被控制在如圖上所示的地方。


此分為兩種設定方式: 


1.如果 SwB -> SwC 的 Interface 是 L3 則設定 bandwidth 即可.

SwB(config)# int fa 0/1 
SwB(config-if)# bandwidth  xxxx


2.如果 SwB -> SwC 的 Interface 是 L2 則需調整 spanning 的 cost

SwB(config)# int fa 0/1 
SwB(config-if)# spanning vlan 1 cost  XXX(Range is 1-200000000)   (default  是該線路的速度 )
cost 越高, 表示越優先..

註: L2還有另一個指令 panning vlan 1 port-priority xxxx  (Rnage 0-240 , 以16為倍數 ex :0,16,32.....)
可以調整 同一switch上 不同Interface的優先權. (需兩個介面外在優先權相同的條件下.才成立,否則需要更改Cost)


L3 Switch for HSRP

HSRP (Hot Standby Router Potocol)




L3 switch 比較特別的是,可以區分VLAN active 在不同的switch 上。
這樣可以減輕 Loading,達到Load balance。


由於要區分不同的vlan,所以指令不能設定在實體界面上。


SwA(config)# interface vlan 1 
SwA(config-if)# ip address 10.10.10.252  255.255.255.0 
SwA(config-if)# standby ip  10.10.10.254 
SwA(config-if)# standby  preempt 
SwA(config-if)# standby priority 105
SwA(config-if)# standby track fa0/1


SwB(config)# interface vlan 1 
SwB(config-if)# ip address 10.10.10.253  255.255.255.0 
SwB(config-if)# standby ip  10.10.10.254 
SwB(config-if)# standby  preempt 
SwB(config-if)# standby priority 100
SwB(config-if)# standby track fa0/1

standby preempt   
此設定在於,當 SwA 失效時,SwB的 Vlan1會從standby 變成 active,等到SwA恢復正常後,Vlan 1 的所有權,會再回到SwA

standby priority 100 
Default  priority is 100 。
數值越大,表示優先權越高。這與 Switch priority 定義 相反,需注意。

standby track fa0/1
一般使用HSRP時,其中一個設備shutdown,Standby設備才會Active。Track的好處可以同時偵測多個介面,(Etherchannel 也行),當device shutdown,會自動減少其priority值,切換成Standby設備接手。

2010年3月15日 星期一

使用Static route 配置 L3 Switch



1-1、配置 IP address、switchport、access or Trunk 
     Router 需配置 Default route 指向 fa0/0

L3-- 1.啟用 ip routing
            Switch(config)# ip routing
Tip: Check the show running-configuration. Verify whether ip routing is enabled.
2.建立Vlan  20  30
            Switch(config)# vlan 20
            Switch(config-if)# name  IT
            ......
Tip: You can use VLAN Trunking Protocol (VTP) to propagate these VLANs to other switches.
3.設定各vlan default Gateway
            Switch(config)# interface Vlan 20
            Switch(config-if)# ip address 192.168.2.254 255.255.255.0
            Switch(config-if)# no shutdown
             .....
4.跟router連接的端口,需更改為 no switchport  並設定IP address
           Switch(config)# interface FastEthernet 0/1
           Switch(config-if)# no switchport 
           Switch(config-if)# ip address 192.168.1.1 255.255.255.0
           Switch(config-if)# no shutdown
5.這裡我們使用 static route 來加強封包傳送的概念 因為目前L3switch 所知道的IP 只有192.168.1.0/24 192.168.2.0/24   192.168.3.0/24    192.168.100.0/24 這些網段。所以我們須將 vlan 40 網段 設定到 routing table。
           Switch(config)# ip route 192.168.4.0 255.255.255.0  192.168.100.2  
   诶? 那這樣還會有一個問題。假如今天要去的 IP address 不是這些呢?
   如果routing table 比對不到,就會將這個封包丟棄。所以,我們還需要在設定一個
   Default route 將這些封包 指向 邊界路由器。
           Switch(config)# ip address 0.0.0.0  0.0.0.0  192.168.1.2
             OK! 大功告成!
     

等等... 別忘了! 我們還有 另一台 L3 Switch呢!  那他的設定 基本上也是一樣的! 只要記得把Default route 指向 192.168.100.1 。

註!我相信各位設定完畢後,在試著ping 200.1.1.1 這台電腦時,一定會發現ping 不通。
      封包確實有過去,只是回不來。
      因為 router 的 routing table 並沒有 底下 Vlan的網段,所以會將封包丟向 fa0/0。
      所以,在這個實驗裡,如果想要ping到 200.1.1.1這台電腦,就需要更改Default route
      聰明的你知道怎更改了吧!!  

     Router(config)# ip address 0.0.0.0  0.0.0.0  192.168.1.1