實驗02 網路設備之安全性設定與操作

Download Report

Transcript 實驗02 網路設備之安全性設定與操作

實驗二 網路設備之安全性設定與操作
國立雲林科技大學
計算機網路實驗室
實驗二 網路設備之安全性設定與操作

本實驗針對一般較常接觸到的設備 layer 2/3 交換器講解如何設定,抵禦下列幾項在區域網
路下常見的攻擊:




實驗目的
DHCP spoofing
MAC address spoofing
ARP spoofing
透過在交換器上啟用下列三種功能,能夠消除上述三種攻擊:



DHCP Snooping
IP Source Guard
Dynamic ARP Inspection
國立雲林科技大學 自由軟體研發中心
2
實驗二 網路設備之安全性設定與操作
實驗場景
Internet
ASUS AP WL-520GU
IP: 192.168.2.1
DHCP pool
192.168.2.10 ~ 192.168.2.250
Cisco layer 3 switch 3560
FastEthernet0/24
FastEthernet0/1
Client 1
FastEthernet0/2
Client 2
國立雲林科技大學 自由軟體研發中心
3
實驗二 網路設備之安全性設定與操作

何謂 DHCP spoofing ?
何謂 DHCP spoofing ?

在 DHCP 中,如果使用者是第一次使用或是重新登錄,通常都是以廣播的方式來取得 DHCP 伺服
器的資訊,而且只會接受第一個回應的 DHCP 伺服器所提供的網路配置參數。如果在網路存在多
台的 DHCP 伺服器 ( 可能有一台以上的 DHCP 伺服器是未經授權的 ) ,由於 DHCP 是採用誰先回
應那麼使用者就採用先回應的 DHCP 伺服器所提供的網路配置參數,假如使用者先接收到未經授
權 DHCP 伺服器的回應,這樣一來使用者所取得的網路配置參數即為非授權的網路配置參數,可
能會被有心人士竊取到使用者通訊的相關資訊。
國立雲林科技大學 自由軟體研發中心
4
實驗二 網路設備之安全性設定與操作

何謂 MAC address spoofing ?
何謂 MAC address spoofing ?

MAC address spoofing 的目的是藉由送出一個來源 MAC address 為攔截目標的 MAC address 的封包
給交換器,讓交換器上的 CAM table 紀錄錯誤的訊息,讓其後要送給目標主機的訊息都傳送攻擊
者所在的連接埠。
MAC address spoofing 攻擊範例
國立雲林科技大學 自由軟體研發中心
5
實驗二 網路設備之安全性設定與操作

何謂 ARP (Address Resolution Protocol) ?


過多的 ARP 封包也可能佔用到網路頻寬並造成網路擁塞,因此當有 ARP 封包經過時,電腦或是
網路設備會儲存相對應的 IP 與 MAC Address,這就是 ARP Cache 。之後可不需要再發送 ARP 封
包詢問便可直接傳輸資料,可減少對網路頻寬的影響。
何謂 ARP 攻擊 (ARP Poisoning 、 ARP Spoofing) ?


ARP是將 IP 位址轉換成 MAC Address 的一種通訊協定,當某一台電腦要傳送資料到某個 IP 位址
時,首先會先傳送 ARP 封包詢問網路上哪台電腦的 MAC Address 對應到這個 IP 位址,當目的主
機接收到這個 ARP 封包之後便會回應給來源電腦進行資料傳送。
何謂 ARP Cache ?


何謂 ARP spoofing ?
發送一個假的 ARP 封包並竄改 ARP Cache 使得資料無法正確傳輸到目的地,造成網路無法連結,
便稱作 ARP 攻擊。由於一般的 ARP Cache 是根據經過的 ARP 封包不斷的變更本身的 ARP 列表,
所以假設接收到的 ARP 封包所提供的資料是偽造的,就會讓資料無法傳輸到實際的目的地。甚至
可能因為假造的 ARP 封包而將資料導向某特定電腦,駭客便可利用這種方式竊取封包資料或修改
封包內容。
如何預防ARP病毒攻擊?

某些網路設備可以啟用 Dynamic ARP inspection 功能,該功能可以檢查 ARP 訊息並拒絕假的 ARP
封包。
國立雲林科技大學 自由軟體研發中心
6
實驗二 網路設備之安全性設定與操作

DHCP Snooping 的目的


DHCP Snooping 簡介
DHCP snooping 最主要的目的是防止因 DHCP spoofing 而造成的不當 DHCP 租用行為,其中包含
非法 DHCP 伺服器的 IP 位址派送行為及 DHCP 租用者對 DHCP 伺服器的不當租用行為,甚至以
不當的 DHCP 封包影響其他使用者的 DHCP 租用結果。
DHCP Snooping 的運作架構

在 DHCP snooping 的架構中主要有 DHCP server 、 DHCP relay agent 及 DHCP client 三個角色。
DHCP server 可以支援或不支援 option-82 ,單視是否需要從 option-82 提供的資訊去控管 IP 位址的
發配;DHCP relay agent 為支援 DHCP relay 及 DHCP snooping 的 Switch ; DHCP client 指的是發
送 DHCP request ,要求從 DHCP server 取得 IP 位址的主機。同時, DHCP snooping 的運行架構可
以用防火牆的觀念來描述,以 DHCP relay agent 為中心(視為防火牆),接往 DHCP server 的介面
稱為 trust interface ;所有接 DHCP client 的介面稱為 untrust interface 。
國立雲林科技大學 自由軟體研發中心
7
實驗二 網路設備之安全性設定與操作
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.
資料來源 http://www.cisco.com
DHCP Snooping
用來過濾來路不明的 DHCP messages 並保護使
用者不會從網路上不合法的 DHCP 伺服器取得
錯誤的網路設定資訊。將連接埠與 vlan 分為
trust 或 untrust 的介面,只有 trust 的介面才可以
收送 DHCP Offer 封包。
設定DHCP Snooping的指令如下:
switch(config)#
ip dhcp snooping
在交換器上啟動 DHCP Snooping 的功能。
switch(config)#
ip dhcp snooping vlan [number or range]
設定哪些 vlan 需要被控管。
Switch(config-if)#
ip dhcp snooping trust
設定介面是 trust 還是 untrust 。
Switch(config-if)#
ip dhcp snooping limit rate rate
每秒最多能收多少 DHCP 封包。
國立雲林科技大學 自由軟體研發中心
8
實驗二 網路設備之安全性設定與操作

DHCP Snooping 設定步驟
如下圖的設定,我們啟動了 DHCP Snooping 的功能監測 vlan 1 ,並且將交換器的第24埠設為 trust ,只
有在該連接埠上的 DHCP Server 能夠配給使用者 IP 位址、閘道器位置、 DNS 伺服器等設定。
cisco3560#configure Terminal
Enter configuration commands, one per line. End with CNTL/Z.
cisco3560(config)#ip dhcp snooping
cisco3560(config)#ip dhcp snooping vlan 1
cisco3560(config)#int fa0/24
cisco3560(config-if)#ip dhcp snooping trust
cisco3560(config-if)#exit
cisco3560(config)#^Z
cisco3560#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
1
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/24
yes
unlimited
Cisco3560#
國立雲林科技大學 自由軟體研發中心
9
實驗二 網路設備之安全性設定與操作


DHCP Snooping 設定步驟
將 Client 1 設為自動取得 IP 位址,下圖1為 Client 1 經由 DHCP Server 取得的網路設定。
如下圖2,使用 show ip dhcp snooping binding 指令查看現在有哪些 IP 位址是經由 DHCP Server 發給使用
者。
圖1
cisco3560#show ip dhcp snooping binding
MacAddress
IpAddress
Lease(sec) Type
----------------------------------------------------00:60:97:14:A1:0D 192.168.2.11 86072
dhcp-snooping
Total number of bindings: 1
VLAN
---1
Interface
-------------------FastEthernet0/1
國立雲林科技大學 自由軟體研發中心
圖2
10
實驗二 網路設備之安全性設定與操作

DHCP Snooping 設定步驟
檢驗 DHCP snooping 是否有發揮功用。
1.
2.
將 DHCP Server 移到交換器的第23連接埠, Client 1 試著重新使用自動取得 IP 位址的方式(請停用
網路介面卡後再重新啟用)向 DHCP Server 索取 IP 位址,檢驗是否能夠取得網路設定,若不能的
話,代表 DHCP Snooping 設定正確,接著將 DHCP Server 移回到交換器的第24連接埠。
接著如下圖,自行指定 Client 1 的 IP 位址為192.168.2.12,其餘設定皆與經由 DHCP Server 取得的
一樣,試看看能不能正常連線,如果不能正常連線代表實驗至此都是正確的(因為 DHCP Snooping
binding table 中並沒有紀錄192.168.2.12)。
國立雲林科技大學 自由軟體研發中心
11
實驗二 網路設備之安全性設定與操作

IP Source Guard 的功能


IP Source Guard 簡介
當網路管理人員試圖利用流量管制的方式管控每個使用者的流量,並進而對違法流量政策的使用
者採取封鎖 IP 的處罰時,懂得 IP 設定的使用者便開始嘗試更改 IP 位址,造成被盜用者也無法使
用網路,或是被盜用者也嘗試使用其他人的 IP 位址,造成網路管理的困擾,而 IP Source Guard 可
以避免合法使用的 IP 位址被其他人盜用的情形。
IP Source Guard 的運作方式

IP Source Guard 運作上是依據 IP Source Binding Table 來檢視比對來自 untrust interface 的 Source IP
或 Source IP/MAC-address 。而 IP Source Binding Table的來源是 DHCP Snooping 產生的 DHCP
Snooping Binding Database 或手動設定的 IP Source Binding 。手動設定的 IP Source Binding 適用於
網路環境並非是由 DHCP server 來配發 IP 位址,因此想要做到全面性的 IP/MAC-address Binding
,網管人員對於使用者的I P/MAC-address 資料蒐集必須非常完整。
國立雲林科技大學 自由軟體研發中心
12
實驗二 網路設備之安全性設定與操作
IP Source Guard 設定步驟

在前面的設定中設定了 DHCP snooping ,讓 Client 1 無法使用 DHCP Server 沒有發配出的 IP 位址,但
若如下圖所示,自行指定 Client 1 的網路設定與透過 DHCP Server 取得的設定一樣,將 IP 位址設為
192.168.2.11,並將 Client 的 MAC address 改成與原先的 MAC address 不同,此時仍然能夠正常的存取
網路。

因此為了消除這種情形,可以使用 IP Source Guard , IP Source Guard 利用 DHCP Snooping Binding
Table 中紀錄的 IP 位址與 MAC address 來過濾不合法的封包。
國立雲林科技大學 自由軟體研發中心
13
實驗二 網路設備之安全性設定與操作

IP Source Guard 設定步驟
IP Source Guard 有兩種封包過濾的方式:


ip verify source
僅檢查封包的 Source IP 位址是否存在 DHCP Snooping Binding Table 中,存在的話就讓該封包通過
。
Ip verify source port-security
同時檢查封包的 Source IP 位址與 MAC address 的對映關係,對映關係正確才讓該封包通過。
Command
Purpose
interface interface-id
Specify the interface to be configured, and enter interface configuration
mode.
ip verify source
or
ip verify source port-security
Enable IP source guard with source IP address filtering.
Enable IP source guard with source IP and MAC address filtering.
Note When you enable both IP Source Guard and Port Security by
using the ip verify source port-security interface configuration
command, there are two caveats:
• The DHCP server must support option 82, or the client is not
assigned an IP address.
• The MAC address in the DHCP packet is not learned as a secure
address. The MAC address of the DHCP client is learned as a
secure address only when the switch receives non-DHCP data
traffic.
ip source binding mac-address vlan
vlan-id ip-address inteface interface-id
Add a static IP source binding.
Enter this command for each static binding.
資料來源 http://www.cisco.com
國立雲林科技大學 自由軟體研發中心
14
實驗二 網路設備之安全性設定與操作

IP Source Guard 設定步驟
因此要消除偽造MAC address的問題,需採用同時檢查 Source IP 位址與 MAC address 的方
式,設定如下圖1:
cisco3560(config)#int fastEthernet 0/1
cisco3560(config-if)#ip verify source port-security

圖1
檢查現在 IP 位址與 MAC address 的對映關係的指令如下圖2所示:
cisco3560#show ip verify source interface fa0/1
Interface Filter-type Filter-mode IP-address
Mac-address
Vlan
--------- ----------- ----------- --------------- ----------------- ---------Fa0/1
ip-mac
active
192.168.2.11 permit-all
1
國立雲林科技大學 自由軟體研發中心
圖2
15
實驗二 網路設備之安全性設定與操作

IP Source Guard 設定步驟
檢驗 IP Source Guard 是否有發揮功用

如下圖所示,自行指定 Client 1 的網路設定與透過 DHCP Server 取得的設定一樣,將 IP 位址設為
192.168.2.11,並將 Client 的 MAC address 改成與原先的 MAC address 不同,如果無法正常存取網
路代表設定正確。
國立雲林科技大學 自由軟體研發中心
16
實驗二 網路設備之安全性設定與操作

Dynamic ARP Inspection 的功能


Dynamic ARP Inspection (DAI) 簡介
ARP 提供同一廣播領域中主機之間互相了解彼此 IP 與MAC Address對應的關係,然而在 ARP 的
運作原理上會使用到廣播的方式,且 ARP 廣播的發送者對於回應的對象並不會作進一步的檢視動
作,進一步造成安全上的漏洞。而 Dynamic ARP Inspection 的作用是避免同一個廣播領域中的惡意
攻擊行為。
Dynamic ARP Inspection 的運作方式





Dynamic ARP Inspection 的作用就是記錄與檢視合法的 IP/MAC Address 對應表來防止不當散佈的
ARP 資訊。
Switch 會先攔截所有在 untrust interface 上的 ARP request 與 ARP response 封包。
在 Switch 的 ARP cache 更新及將 ARP 封包轉發出去之前,在 DHCP 的環境中, Switch 會先檢查
攔截到的 ARP 封包是否符合正確 IP DHCP Snooping Binding Database;在非 DHCP 的環境中,
Switch 檢查的依據為網管人員為每個使用者自行設定的 ARP ACL 。
如果 Switch 同時存在 IP DHCP Snooping Binding Database 與 ARP ACL 的設定, ARP ACL 會優先
被採用作為檢查的依據,且被 ARP AC L丟棄的封包將不會接受 DHCP Snooping Binding Database
的檢查。
在檢查完後, Switch 會轉送所有與 Binding Database 或 ARP ACL 內容相符合的封包而丟棄所有不
符合的 ARP 封包。
國立雲林科技大學 自由軟體研發中心
17
實驗二 網路設備之安全性設定與操作

Dynamic ARP Inspection (DAI) 設定步驟
最後,有了前面所設定的 DHCP Snooping 功能所得到的 Binding Table , DAI 會根據
Binding Table 上的資訊檢查arp封包中的 IP 位址與 MAC address 的對映關係是否正確,用
來防止 ARP spoofing ,消除了中間人攻擊的疑慮。
資料來源 http://www.cisco.com
國立雲林科技大學 自由軟體研發中心
18
實驗二 網路設備之安全性設定與操作

Dynamic ARP Inspection (DAI) 設定步驟
如圖1,設定監測來自 vlan 1 的arp封包,除了來自於設定為 trust 的arp封包不監測,在這邊
我們要將 DHCP Server 所在的第24埠設為 trust ,否則網路無法連通。
cisco3560(config)#ip arp inspection vlan 1
cisco3560(config)# int fa0/24
cisco3560(config-if)#ip arp inspection trust

圖1
在 Client 2 上使用 ettercap 這套軟體,嘗試使用 arp poisoning 來做中間人攻擊 (詳細步驟請
參閱實驗1網路攻擊軟體之操作),啟動攻擊後,交換器偵測到異常的狀況,因此將 Client 2
所在的連接埠關閉,如圖2。
圖2
國立雲林科技大學 自由軟體研發中心
19
實驗二 網路設備之安全性設定與操作

總結
利用 DHCP Snooping 、 IP Source Guard 、 Dynamic ARP Inspection 這三個功能,在使用
DHCP 的方式取得 IP 位圵的網路環境下,不需要像以往一樣手動設定 port-security 等來對
映 IP 位址與 MAC address 來抵禦 ARP spoofing 、 MAC address spoofing 、 DHCP spoofing
,省下許多管理上的麻煩。
國立雲林科技大學 自由軟體研發中心
20
實驗二 網路設備之安全性設定與操作
參考資料

「http://en.wikipedia.org/wiki/DHCP_snooping」
「http://www.networkdictionary.com/security/d.php」
「http://blog.yam.com/magicianlee/article/14018860」
「 http://www.ringline.com.tw/epaper/Forum961101.htm 」
「http://blog.chinaunix.net/u1/34087/showart_347267.html」
「http://hi.baidu.com/yj88278/blog/item/34c341975ad0536554fb9621.html」
「http://tw.trendmicro.com/tw/support/tech-support/board/tech/article/20070926085046.html」
「http://pluscom.ru/cisco_product/cc/td/doc/product/lan/cat4000/12_2_25/conf/dynarp.htm#wp1039231」

「http://www.cisco.com/en/US/docs/switches/lan/catalyst3750/software/release/12.2_40_se/configuration/guide/swdynarp.html 」







國立雲林科技大學 自由軟體研發中心
21