天天看點

DoS Attacks Prevention with TCP Intercept

【實驗說明】

在路由器上配置,使用 TCP intercept 檢查所有TCP連接配接。

【實驗拓撲】

DoS Attacks Prevention with TCP Intercept

【實驗配置】

tcp intercept 攔截有兩種模式一種是攔截,一種是監視。預設為攔截模式,

R1:

interface FastEthernet0/0

ip address 12.1.1.1 255.255.255.0

no sh

ip route 23.1.1.0 255.255.255.0 12.1.1.2

R2:

ip address 12.1.1.2 255.255.255.0

interface FastEthernet1/0

ip address 23.1.1.2 255.255.255.0

!首先定義要保護的網絡

access-list 199 permit tcp any 23.1.1.0 0.0.0.255 eq telnet

!配置攔截模式,預設為intercept ,還有一種模式為watch

ip tcp intercept mode intercept

!調用通路控制清單

ip tcp intercept list 199

!設定半開連接配接逾時時間,1小時,(預設TCP連接配接是永遠不逾時的)

ip tcp intercept connection-timeout 3600

! 設定半開連接配接的數量限制 low 1200,high 1500;所有半開連接配接數達到1500後,進入主動模式,主動模式會将所有的逾時時間減半,比如上面配置的connection-timeout會由3600s變成1800s。當連接配接數低于1200時,再恢複正常。

ip tcp intercept max-incomplete low 1200

ip tcp intercept max-incomplete high 1500

!設定丢棄模式為随機,另一種為丢棄模式為oldest ,丢棄老的連接配接

ip tcp intercept drop-mode random

!開啟intercept的debug模式

debug ip tcp intercept

R3:

ip address 23.1.1.3 255.255.255.0

!

ip route 12.1.1.0 255.255.255.0 23.1.1.2

------------------------------------------------------說明-------------------------------------------------------

兩種模式的對比

intercept Active mode in which the TCP intercept software intercepts TCP packets from clients to servers that match the configured access list and performs intercept duties. This is the default.
watch Monitoring mode in which the software allows connection attempts to pass through the router and watches them until they are established.

【實驗驗證】

在R1上telnet R3,建立TCP連接配接

R1#telnet 23.1.1.3

Trying 23.1.1.3 ... Open

User Access Verification

在R4上觀察debug資訊

R4:

*Mar 1 00:12:22.199: INTERCEPT: new connection (12.1.1.1:21323

SYN

-> 23.1.1.3:23)

*Mar 1 00:12:22.203: INTERCEPT(*): (12.1.1.1:21323 <-

ACK+SYN

23.1.1.3:23)

*Mar 1 00:12:22.263: INTERCEPT: 1st half of connection is established (12.1.1.1:21323 ACK -> 23.1.1.3:23)

*Mar 1 00:12:22.263: INTERCEPT(*): (12.1.1.1:21323 SYN -> 23.1.1.3:23)

*Mar 1 00:12:22.315: INTERCEPT: 2nd half of connection established (12.1.1.1:21323 <- ACK+SYN 23.1.1.3:23)

*Mar 1 00:12:22.315: INTERCEPT(*): (12.1.1.1:21323 ACK -> 23.1.1.3:23)

*Mar 1 00:12:22.319: INTERCEPT(*): (12.1.1.1:21323 <- WINDOW 23.1.1.3:23)

TCP intercept 模式工作原理

1、用戶端發送SYN包

2、中間的路由器僞裝自己作為伺服器來處理對用戶端發送的SYN

3、用戶端和路由器建立三次握手之後,證明會話沒有問題(若無法形成會話,則丢棄)

4、此時路由器再僞裝為用戶端向伺服器發送SYN包

5、伺服器發送SYN/ACK給僞裝用戶端的路由器

6、僞裝用戶端的路由器發送ACK給伺服器

7、三次握手之後,路由器和伺服器也形成了會話,于是用戶端和伺服器形成會話。

R2#show tcp intercept connections

Incomplete:

Client Server State Create Timeout Mode

Established:

12.1.1.1:12267 23.1.1.3:23 ESTAB 00:00:15 00:59:56 I

R2#show tcp intercept statistics

Intercepting new connections using access-list 199

0 incomplete, 1 established connections (total 1)

1 connection requests per minute

----------------------------------------------------------watch 模式的配置---------------------------------------------------

R2:增加

!配置為監聽模式

ip tcp intercept watch

!設定監聽

ip tcp intercept watch-timeout 15

【驗證監聽模式】

R2(config)#ip tcp intercept watch-timeout

*Mar 1 00:56:50.767: INTERCEPT: new connection (12.1.1.1:61984 SYN -> 23.1.1.3:23)

*Mar 1 00:56:50.871: INTERCEPT: (12.1.1.1:61984 <- ACK+SYN 23.1.1.3:23)

*Mar 1 00:56:50.923: INTERCEPT: (12.1.1.1:61984 ACK -> 23.1.1.3:23)

-------------------------------------------------兩種模式的對比--------------------------------

攔截模式,而采取主動的方式處理TCP SYN洪水攻擊,watch模式需要一個時間反應的方法。攔截模式的主要優點之一是,它消除内部伺服器處理TCP SYN洪水的負載。然而,這是一把雙刃劍,因為,在大多數時間内,不會發生TCP SYN洪水,但路由器仍然是執行攔截,它将消耗路由器的負載。

為了緩解這個問題,您可以使用TCP 攔截中的watch模式。watch模式是被動的。在watch模式中,路由器被動地觀察從用戶端到伺服器的TCP連接配接。它可以通過監視這些連接配接的逾時時間。然後與預先設定的逾時值(它預設為30秒)比較。如果一個TCP連接配接在預設值内沒有完成三次握手,思科IOS發送的TCP重置,删除該連接配接。當伺服器受到TCP syn攻擊時,它消除了半開連接配接的數量,進而減少了伺服器上的負載,并允許合法的連接配接嘗試處理。