網頁

2012年3月7日 星期三

CCNA學習筆記(三)

STP (802.1D)
為了完成打斷迴圈的工作,在一群Switch中首先要選出Root Bridge,並且只能有一台Switch成為Root Bridge。
會比較兩個值,首先比較[Bridge ID](Priority ID+第一個VLAN ID),[值]越低則優先權越高。
Bridge ID相同時,在比較[MAC Address],一樣[值]越低的優先權越高。

STP埠之狀態
blocking凍結:中斷迴圈用。
listening聆聽:偵測沒有迴圈後準備傳送資料。
learning學習:產生MAC table。
forwarding轉送:傳送資料。
disable關閉:不參與任何運作。

收斂
當Switchs上所有的port狀態都變成Blockingforwarding狀態時,就叫達成收斂(Convergence)。

STP根據Cost(BW)來決定port為Blocking或Forwarding。
Giga port cost=4
100M port cost=19

PostFast
加速收斂時間,但使用這個指令就喪失STP的功能(無法打斷迴圈),一般可以用在末端的Switch,如果用在Core Switch或是還有串接其他Switch、Hub的設備,就要先確認線路有沒有迴圈。

RSTP(Rapid STP)快速STP (802.1W)
縮短收斂時間,只需要1-2秒
Switch#conf t
Switch(config)#spanning-tree mode rapid-pvst


Post Security交換埠的安全性(防非法MAC存取)
switch #configure terminal
switch (config)#interface fastEthernet 0/24  (多個Port可用range)
switch (config-if)#switchport mode access  (將Port運作模式改成Access Mode)
switch (config-if)#switchport port-security  (啟用Port Security機制)
switch (config-if)#switchport port-security maximum 1  (設定最大的MAC數量,上限為一筆)
switch (config-if)#switchport port-security mac-address sticky (自動記錄學到的Mac Address,不需手動輸入)
switch (config-if)#switchport port-security violation shutdown(預設,處理err-disabled,偵測到違反政策時,關閉該port)

switch(config-if)#switchport port-security violation restrict  (合法MAC接回就會通)

1.switchport port-security maximum 允許讓多少筆 Mac-Address通過
2.switchport port-security mac-address 允許哪些 Mac-Address過過這裡有兩個選項可選:一個是直接輸入讓它通過的Mac-Address,另一個是動態紀錄
3.switchport port-security violation 當不在允許列表的 Mac-Address出現時所 採取的動作
  a.protect 保護原有的 Mac-Address, 不允許其它 Mac-Address通過
  b.restrict 不允許通過, 且紀錄
  c.shutdown 讓該 Port Shutdown

當違規被Shutdown時
Switch#clear port-security all(清除Port-Security資料)
Switch#conf t
Switch(config)#int fa0/1(違規的介面)
Switch(config-if)#sh(關閉)
Switch(config-if)#no sh(啟用)


Access Port與Trunk Port
Switch Port有兩種運作模式,Access Mode、Trunk Mode。
設定為Access Mode時該Port只能指定給一個VLAN,也只能與許該VLAN的封包通過。
如是Trunk Port,則能允許任何的VLAN封包通過(除非你有設定管制)。

VLAN(IEEE 802.1Q)
Switch(config)#vlan 30(新增VLAN ID 30)
Switch(config-vlan)#vlan 40(新增VLAN ID 40)

Switch(config)#interface range fastEthernet 0/10-20
Switch(config-if-range)#switchport access vlan 50(新增VLAN ID 50,並把ports fa0/10-20加入)
% Access VLAN does not exist. Creating vlan 50


VTP-Trans1#vlan database 
% Warning: It is recommended to configure VLAN from config mode,
  as VLAN database mode is being deprecated. Please consult user
  documentation for configuring VTP/VLAN in config mode.


VTP-Trans1(vlan)#?
VLAN database editing buffer manipulation commands:
  exit  Apply changes, bump revision number, and exit mode
  no    Negate a command or set its defaults
  vlan  Add, delete, or modify values associated with a single VLAN
  vtp   Perform VTP administrative functions.
VTP-Trans1(vlan)#vlan 10
VLAN 10 added:
    Name: VLAN0010
VTP-Trans1(vlan)#no vlan 10
Deleting VLAN 10...
VTP-Trans1(vlan)#vtp ?
  client       Set the device to client mode.
  domain       Set the name of the VTP administrative domain.
  password     Set the password for the VTP administrative domain.
  server       Set the device to server mode.
  transparent  Set the device to transparent mode.
  v2-mode      Set the administrative domain to V2 mode.

Trunk
Switch(config)#interface fastEthernet 0/24
Switch(config-if)#switchport mode trunk 

Switch(config-if)#switchport mode dynamic ?

  auto       Set trunking mode dynamic negotiation parameter to AUTO

  desirable  Set trunking mode dynamic negotiation parameter to DESIRABLE
Switch(config-if)#switchport trunk allowed ?
  vlan  Set allowed VLANs when interface is in trunking mode

1.switchport mode access: 強制接口成為access接口,並且可以與對方主動進行協商,誘使對方成為access模式。
2.switchport mode dynamic desirable: 主動與對協商成為Trunk接口的可能性,如果鄰居接口模式為Trunk/desirable/auto之一,則接口將變成trunk接口工作。如果不能 形成trunk模式,則工作在access模式。
3.switchport mode dynamic auto: 只有鄰居交換機主動與自己協商時才會變成Trunk接口,所以它是一種被動模式,當鄰居接口為Trunkdesirable之一時,才會成為 Trunk。如果不能形成trunk模式,則工作在access模式。
4.switchport mode trunk: 強制接口成為Trunk接口,並且主動誘使對方成為Trunk模式,所以當鄰居交換機接口為trunk/desirable/auto時會成為Trunk接口。
5.switchport nonegotiate: 嚴格的說,這不算是種接口模式,它的作用只是阻止交換機接口發出Dynamic Trunking Protocol (DTP)封包

SW01  Fa0/1
SW02  Fa0/1
Trunk是否形成?
Trunk
Trunk
O

Dynamic desirable
O

Dynamic auto
O

Access
X
Dynamic desirable
Trunk
O

Dynamic desirable
O

Dynamic auto
O

Access
X
Dynamic auto
Trunk
O

Dynamic desirable
O

Dynamic auto
X

Access
X
Access
Trunk
X

Dynamic desirable
X

Dynamic auto
X

Access
X
Switch0#conf t
Switch0(config)#int g1/1
Switch0(config-if)#switchport mode trunk 

Router#conf t
Router(config)#int fa0/0
Router(config-if)#no sh
Router(config-if)#int fa0/0.10
Router(config-subif)#encapsulation dot1Q 10
Router(config-subif)#ip address 192.168.1.254 255.255.255.0
Router(config-subif)#int fa0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.2.254 255.255.255.0

vlan10的PC設定Gateway為192.168.1.254
vlan10的PC設定Gateway為192.168.2.254
如此VLAN10及VLAN20就可以互通

VTP(Vlan Trunking Protocol)(CISCO專屬)
VTP是一種讓Switch之間可以自動相互同步VLAN設定的通訊協定。
使用VTP需先宣告一VTP Domain,網域中最少要有一台Switch作為VTP Server,其餘的Switch則成為VTP Client。當需要異動Vlan時,只能在VTP Server上異動,結果會同步更新到所有VTP Client。

VTP運作模式
1.Server Mode:可以新增、移除、修改Vlan,並同步更新到所有網域內的VTP Client。
2.Client Mode:只能被動接受VTP Server的Vlan資料庫,同步更新到本身的資料庫,無法在Client Mode下新增、移除、修改Vlan。
3.Transparent Mode:不參與VTP Domain內Vlan資料庫同步更新,可以在Transparent Mode下新增、移除、修改Vlan,但其結果只會紀錄再本身的資料庫中
  在Transparent Mode下的Switch接收到VTP Server的更新資訊時,會直接轉送給其他的Switch。

VTP-Server#conf t
VTP-Server(config)#vtp ?
  domain    Set the name of the VTP administrative domain.
  mode      Configure VTP device mode
  password  Set the password for the VTP administrative domain
  version   Set the adminstrative domain to VTP version
VTP-Server(config)#vtp mode ?
  client       Set the device to client mode.
  server       Set the device to server mode.
  transparent  Set the device to transparent mode.
VTP-Server(config)#vtp mode server 

VTP-Server#show vtp ?
  counters  VTP statistics
  password  VTP password
  status    VTP domain status
VTP-Server#show vtp status 
VTP Version                     : 2
Configuration Revision          : 0
Maximum VLANs supported locally : 255
Number of existing VLANs        : 5
VTP Operating Mode              : Server
VTP Domain Name                 : ABC
VTP Pruning Mode                : Disabled
VTP V2 Mode                     : Disabled
VTP Traps Generation            : Disabled
MD5 digest                      : 0xB7 0x9A 0x90 0xBA 0xA0 0xA6 0xB4 0xD4 
Configuration last modified by 0.0.0.0 at 0-0-00 00:00:00
Local updater ID is 0.0.0.0 (no valid interface found)

將新的交換機增加到域中,一定要保證該交換機的修訂號已經為0(Configuration Revision : 0),不然如剛好為Server Mode就可能會發生災難。
VTP修訂號存儲在NVRAM中,交換機的電源開關不會改變這個設定值.可以使用下列方法:
1.將交換機的VTP模式變到Transparent Mode,然後再變回Server Mode。
2.將交換機的VTP Domain名稱修改為一個不存在的名稱,然後再回到原來的VTP Domain名稱。
3.使用erase startup-config 或 erase nvram命令,清除交換機的配置和VTP資訊.再次啟動。

沒有留言:

張貼留言