Presentation is loading. Please wait.

Presentation is loading. Please wait.

實驗 3:Layer 2 交換器裝置之安全性設定與操作

Similar presentations


Presentation on theme: "實驗 3:Layer 2 交換器裝置之安全性設定與操作"— Presentation transcript:

1 實驗 3:Layer 2 交換器裝置之安全性設定與操作

2 實驗 3:Layer 2 交換器裝置之安全性設定與操作
實驗目的 本實驗講解如何設定Port Security、DHCP Snooping、BPDU Guard等方法來抵御下列幾種攻擊: CAM table overflow MAC address spoofing DHCP starvation STP manipulation 而在講解如何在交換器上設定對應的防禦機制前,將會簡述以上四種攻擊法,能夠讓各位更能了解這些防禦機制的工作原理。

3 CAM table overflow 攻擊簡述
實驗 3:Layer 2 交換器裝置之安全性設定與操作 CAM table overflow 攻擊簡述 CAM table overflow的目的是透過發送大量偽造MAC address的封包,使得交換器的CAM table紀錄的對應資料中不含有正常的主機MAC address,在這種狀況下交換器的工作方式就如同集線器一樣,將收到的封包將所有的連接埠送(除了來源的連接埠),攻擊者便可藉此竊聽所有流經交換器的訊息。 場景如左圖1,一開始交換器上的CAM table存有主機A位於連接埠1、主機B位於連接埠2的對應資訊,當主機A要傳送資料給主機B時,由於CAM table中存在主機B存在連接埠2這項對應資訊,所以A傳送給B的訊息會直接送往連接埠2。 如圖2,之後主機C發送偽造MAC address的封包,當交換器收到後會更新CAM table中的資料,此時因為數量超過了CAM table所能紀錄的大小,所以會將先前存在的對應資料覆蓋掉,可以看到CAM table中紀錄到了X、Y這兩個不存在的MAC address位在連接埠3的資訊。 如圖3,最後假設主機A要傳訊息給主機B,交換器收到封包後發現CAM table中沒有紀錄主機B是位在哪個連接埠,因此將該訊息送往連接埠2、3。此時主機C就可收到主機A傳給主機B的訊息,。 圖1 圖2 圖3

4 MAC address spoofing 攻擊簡述
實驗 3:Layer 2 交換器裝置之安全性設定與操作 MAC address spoofing 攻擊簡述 圖1 MAC address spoofing的目的是藉由送出一個來源MAC address為攔截目標的MAC address的封包給交換器,讓交換器上的CAM table紀錄錯誤的訊息,讓其後要送給目標主機的訊息都傳送攻擊者所在的連接埠。注意MAC address spoofing與CAM table overflow的差別在於MAC address spoofing只會收到攻擊目標的封包,而CAM table overflow則是會竊聽到所有流經交換器的封包。 我們用左方的圖來簡述MAC address spoofing的攻擊流程,場景如左圖1,一開始CAM table中紀錄主機A在連接埠2、主機B在連接埠1、主機C在連接埠3。 之後主機B送出一個來源MAC address欄位填上A的MAC address的封包,當交換器收到後,會更新CAM table,使得交換器認為主機A在連接埠1,如圖2。 接著所有要送給主機A的訊息,全部都會往連接埠1傳送,使得主機B可以收到原本要傳給主機A的訊息,如圖3。直到A主機再度送出訊框更新CAM table中的資訊,A主機才能夠收到原本該收到的封包。 圖2 圖3

5 實驗 3:Layer 2 交換器裝置之安全性設定與操作
DHCP starvation 攻擊簡述 DHCP starvation的目的是發送偽造MAC address的封包將合法的DHCP伺服器所有可用的IP位址佔用,使得合法使用者無法從DHCP伺服器取得可用IP位址。然後攻擊者架設一個DHCP伺服器,偽裝成合法的DHCP伺服器,當使用者發出DHCP request時,當合法的DHCP伺服器收到後因為本身已無可用的IP位置而不做任何的回應,而此時就由攻擊者所偽裝的DHCP伺服器來回應給使用者。而通常DHCP除了分派IP位址之外,同時會指定DNS伺服器與預設的閘道器,而攻擊者就是利用將這些位址指向自已所擁有的主機位址藉此達成man-in-the-middle attack。 我們用下方的圖來簡述DHCP starvation的攻擊流程,如圖1,首先攻擊者發送大量偽造來源MAC address的DHCP request給合法的DHCP伺服器,嘗試找出DHCP伺服器所有可分配的IP位址範圍並佔用所有可用的IP位址。 如圖2,當攻擊者將合法的DHCP伺服器的所有可用IP佔用後,自已設置一個偽裝的DHCP伺服器,當合法使用者發出DHCP request時由攻擊者偽裝的DHCP伺服器回應給使用者。 圖1 圖2

6 實驗 3:Layer 2 交換器裝置之安全性設定與操作
STP manipulation 攻擊簡述 STP manipulation的目的是為了要竊聽網路上流經的封包,做法是攻擊者將自已偽裝成Root Bridge,使得原本不該流經過攻擊者的封包送往攻擊者端。除了竊聽之外,也可做到DoS的效果,利用發送STP configuration/topology change BPDUs,迫使STP 重新計算路徑,在重新計算路徑的這段時間可能會造成網路30~45秒的中斷,達到DoS的效果。 我們用左方的圖來簡述STP manipulation的攻擊流程,場景如圖1,一開始交換器A被選為Root Bridge,交換器A、B要傳送訊框時,是直接互傳給對方。 如圖2,之後攻擊者假冒成交換器,廣播STP topology change BPDUs 宣稱他的優先權較高。 接著當其它交換器收到時,認為攻擊者系統的優先權較高,應為Root Bridge,因此重新計算連接到攻擊者的最短路徑。重新計算出來的路徑如圖3,重新計算出的路徑使得所有原本應直接經由交換器A、B轉送的訊框,不是直接傳送給對方,而是要經由攻擊者系統才能到達,因此攻擊者可利用偽裝成Root Bridge竊聽到原本不能收到的訊息。 圖1 圖2 圖3

7 實驗 3:Layer 2 交換器裝置之安全性設定與操作
Port Security Port Security Port Security能夠用來指定在交換器上任何一個實體連接埠允許哪些MAC address可以使用以及最大可容納的MAC address數量。利用Port Security可以用來防禦CAM table Overflow attacks、MAC Spoofing attacks。 Port Security分為三種方式: Static secure MAC address:在交換器的實體連接埠上手動設定只有哪些MAC address 可以使用。 Dynamic secure MAC addresses:在交換器的實體連接埠上指定最大可容納的MAC address數量。 Sticky secure MAC addresses:Static secure MAC addresses與Dynamic secure MAC addresses的結合,全由手動設定會增加管理者的負擔,因此我們只需要針對某些提供重要服務的設備指定MAC address,其餘的部分就交由Dynamic secuire MAC addresses的方式管理。 Static secure Fa0/7 Hub Switch 主機A 主機B 只允許主機A通過 Dynamic secure Fa0/7 Hub Switch 主機A 主機B 只允許2位同時在線 主機C 7

8 實驗 3:Layer 2 交換器裝置之安全性設定與操作
Port Security Port Security (Cont.) 當交換器連接埠上MAC address數量達到限制的數量時 (port security violation),有以下三種處理方式: Protect:當交換器連接埠上MAC address數量達到限制的數量時,如果接下來的封包上的來源MAC address不在已學習到的清單內,則將封包丟棄,直到某些MAC address因閒置過久而從清單中被移除或是當最大限制的數量增加時,才可讓新加入的MAC address使用。使用此種方式的話當發生security violation時並不會做任何的通知。 Restrict:當交換器連接埠上MAC address數量達到限制的數量時,如果接下來的封包上的來源MAC address不在已學習到的清單內,則將封包丟棄,直到某些MAC address因閒置過久而從清單中被移除或是當最大限制的數量增加時,才可讓新加入的MAC address使用。當發生security violoation時會送通知到SNMP伺服器以及產生syslog message。 Shutdown:當交換器連接埠上MAC address數量達到限制的數量時,該連接埠會被停用,並顯示為err-disabled,同時會發送SNMP trap以及產生syslog message。 Protect & Restrict Fa0/7 Hub Switch 主機A 主機B MAX=1 假設主機A目前在線上,主機B需等待主機A從清單中移除後才可使用 Shutdown Fa0/7 Hub Switch 主機A 主機B MAX=1

9 實驗 3:Layer 2 交換器裝置之安全性設定與操作
Port Security Command Description switchport mode {access | trunk} Sets the interface mode as access or trunk. An interface in the default mode of dynamic auto cannot be configured as a secure port. switchport port-security Enables port security on the interface. switchport port-security [maximum value [vlan {vlan-list | {access | voice}}]] Sets the maximum number of secure MAC addresses for the interface. The active Switch Database Management (SDM) template determines the maximum number of available addresses. The default is 1. switchport port-security violation {protect | restrict | shutdown} Sets the action to be taken when a security violation is detected. The default mode for security violations is to shut down the interface. switchport port-security [mac-address macaddress [vlan {vlan-id | {access | voice}}] Sets a secure MAC address for the interface. This command may be used to enter the maximum number of secure MAC addresses. If fewer secure MAC addresses are configured than the maximum, the remaining MAC addresses are dynamically learned. switchport port-security mac-address sticky Enables sticky learning on the interface. [mac-address | vlan {vlan-id | {access | voice}}] Sets a sticky secure MAC address. This command can be repeated as many times as necessary. If fewer secure MAC addresses are configured than the maximum, the remaining MAC addresses are dynamically learned, converted to sticky secure MAC addresses, and added to the running configuration. Port Security (Cont.) 以下是設定port security的指令: switch(config-if)# switchport mode {access | trunk} 指定交換器連接埠的模式,預設為非secure port。 switchport port-secuirty 在該連接埠下啟動port security。 switchport port-security [maximum value] 限制Port可容納多少的MAC addresses。 switchport port-security violation {protect | restrict | shutdown} 當超過可容納的MAC addresses數量時採取何種對應方式。

10 實驗 3:Layer 2 交換器裝置之安全性設定與操作
Port Security Port Security (Cont.) 左圖為實驗場景與設定: 將fa0/7這個Port限制最大可使用的MAC為1個。並且設定若超過所指定的數量,Switch的動作為Shutdown。 依據左圖的建構目前實驗的環境。 觀察Port Security 主機A取得IP之後,使用Show port-security,觀看CurrentAddr欄位,會顯示1,代表目前此Port有1主機存在(如左所示)。 將主機B接至HUB。此時,fa0/7將會shutdown。主機A、B將無法連線。 Port Security Switch(config)#int fa0/7 Switch(config-if)#switchport port-security Switch(config-if)#switchport port-security max 1 Switch(config-if)#switchport port-security violation shutdown Fa0/7 Hub Switch 主機A 主機B Port Security 實驗場景 Show Port Security

11 實驗 3:Layer 2 交換器裝置之安全性設定與操作
DHCP Snooping DHCP Snooping DHCP Snooping是用來過濾來路不明的DHCP messages並保護使用者不會從網路上不合法的DHCP伺服器取得錯誤的網路設定資訊。 DHCP Snooping透過建立DHCP Snooping Binding 資料庫來過濾掉非合法的使用者。DHCP Snooping啟動之後會監聽流經的DHCP封包,利用使用者要與DHCP Server取得位址時所發送的DHCP Reques與DHCP Ack記錄此使用者的資訊將之儲存於DHCP Snooping binding table,此表中會紀錄,使用者對應的MAC位址、IP位址、租用時間、vlan編號等等的資訊。 DHCP Snooping會設定交換器中哪些Port或是哪些vlan為trust的介面,只有trust的介面才可以收送DHCP Offer封包。區別trust與untrust介面的依據是根據連接埠是否直接連接到end-user,如果是連接到end-user則為untrust的介面,若是接到DHCP Server或是另一臺交換器的話,則為trust的介面。 Rogue DHCP Attacker Client Untrusted Trusted Legitimate DHCP Server 11

12 實驗 3:Layer 2 交換器裝置之安全性設定與操作 DHCP Snooping
Command Purpose Switch(config)# ip dhcp snooping Enables DHCP snooping globally. You can use the no keyword to disable DHCP snooping. Switch(config)# ip dhcp snooping vlan number [number] Enables DHCP snooping on your VLANs. Switch(config)# ip dhcp snooping information option Enables DHCP Option 82 data insertion. Switch(config-if)# ip dhcp snooping trust Configures the interface as trusted or untrusted. You can use the no keyword of to configure an interface to receive only messages from within the network. Switch(config-if)# ip dhcp snooping limit rate rate Normally, the rate limit applies to untrusted interfaces. If you want to set up rate limiting for trusted interfaces, keep in mind that trusted interfaces aggregate all DHCP traffic in the switch, and you will need to adjust the rate limit to a higher value. DHCP Snooping (Cont.) 設定DHCP Snooping的指令如下: switch(config)# ip dhcp snooping ip dhcp snooping vlan [number or range] 在交換器上啟動DHCP Snooping的功能 Switch(config)# ip dhcp snooping trust 設定介面是trust還是untrust。 Switch(config-if)# ip dhcp snooping limit rate rate 每秒最多能收多少DHCP封包 資料來源 switch#configure Terminal Enter configuration commands, one per line. End with CNTL/Z. switch(config)#ip dhcp snooping switch(config)#ip dhcp snooping vlan 32 switch(config)#int fa0/36 switch(config-if)#ip dhcp snooping trust switch(config-if)#ip dhcp snooping limit rate 100 switch(config-if)#exit switch(config)#^Z switch#show ip dhcp snooping Switch DHCP snooping is enabled DHCP snooping is configured on following VLANs: 32 DHCP snooping is configured on the following Interfaces: Insertion of option 82 is enabled circuit-id format: vlan-mod-port remote-id format: MAC Option 82 on untrusted port is not allowed Verification of hwaddr field is enabled Interface Trusted Rate limit (pps) FastEthernet0/ yes switch#

13 Dynamic ARP Inspection
實驗 3:Layer 2 交換器裝置之安全性設定與操作 Dynamic ARP Inspection Rogue DHCP Attacker Client Untrusted Trusted Legitimate DHCP Server Dynamic ARP Inspection Dynamic ARP Inspection (DAI)是用來核對IP-to-MAC address bindings以丟棄不正確的ARP封包。DAI使用DHCP Snooping database來核對bindings,當封包來自於trust的介面時,封包不需要經過DAI檢查,而當封包是從untrust的介面送來時,DAI會對這些封包檢查。當啟用DAI時,能夠對流進的ARP封包限流來預防DoS攻擊,預設的在untrust的介面上的限流是每秒14個封包,trust的介面上則沒有限制。 以下是設定DAI的指令: switch(config)# ip arp inspection vlan vlan 啟用DAI ip arp inspection trust 設定介面是trust還是untrust。 ip arp inspection limit rate rate burst interval interval 設定rate-limit Switch#configure terminal Switch(config)#ip arp inspection vlan 34 Switch(config)#interface fa0/0 Switch(config-if)#ip arp inspection trust Switch(config-if)#ip arp inspection limit rate 20 burst interval 2

14 實驗 3:Layer 2 交換器裝置之安全性設定與操作
BPDU Guard 在STP中,只要連接埠有參與STP的運作,那麼該設備就有機會可以成為root bridge影響STP topology。要成為root bridge,自已本身的優先權要比目前的root bridge的priority低,才能夠取代原先的root bridge。當取代原本的root bridge時,STP topology會重新計算,大約需要30~50秒的時間,在這段時間內可能造成某些服務time out。如果有人利用這種方式一直迫使STP不停的重新計算Topology,會造成阻斷式服務攻擊(DoS)。 運作STP的交換器在告知其它的交換器自已的priority時,是利用BPDU封包,因此我們可以利用BPDU Guard來防止STP manipulation attack。 BPDU Guard的原理是假設我們知道目前整個網路的topology,知道交換器的哪些連接埠是有連接參與STP的交換器,只允許這些連接埠發送BPDU封包,禁止沒有參與STP的連接埠發送BPDU封包,如果在這些連接埠上接收到BPDU的封包則視為異常狀況,會將該連接埠disable。 Client B Client A Configure BPDU guard here. Web Server

15 實驗 3:Layer 2 交換器裝置之安全性設定與操作
BPDU Guard BPDU Guard BPDU Guard用來抵禦STP manipulation attack,主要是禁止交換器連接埠接收來路不明的BPDU封包。 設定BPDU Guard的指令如下: Switch(config)# spanning-tree portfast bpduguard 啟用BPDU Guard Switch# show spanning-tree summary totals 檢視BPDU Guard的設定 switch#configure terminal Enter configuration commands, one per line. End with CNTL/Z. switch(config)#spanning-tree portfast bpduguard switch(config)#show spanning-tree summary totals Switch is in pvst mode Root bridge for: none Extended system ID is enabled Portfast Default is disabled PortFast BPDU Guard Default is enabled Portfast BPDU Filter Default is disabled Loopguard Default is disabled EtherChannel misconfig guard is enabled UplinkFast is disabled BackboneFast is disabled Configured Pathcost method used is short Name Blocking Listening Learning Forwarding STP Active 1 vlan switch#

16 Mitigating VLAN Hopping Attacks
實驗 3:Layer 2 交換器裝置之安全性設定與操作 Mitigating VLAN Hopping Attacks Switch(config-if)#switchport mode access Configures the ports as access ports and turns off DTP Switch(config-if)#switchport access vlan vlan-id Statically assigns the ports to specific unused VLAN Mitigating VLAN Hopping Attacks 要減緩vlan hopping attacks可根據以下幾點設定: 所有的trunk port使用專用的VLAN ID。 關閉所有未使用的連接埠,以及將這些連接埠分入一個未使用的VLAN。 使用switchport mode access指令將與使用者連接的連接埠設為非trunk port。 在網路骨幹上的交換器之間的連接,要確實的設為trunking。 不要使用VLAN 1做為管理的專用VLAN。


Download ppt "實驗 3:Layer 2 交換器裝置之安全性設定與操作"

Similar presentations


Ads by Google