天天看点

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攻击时,它消除了半开连接的数量,从而减少了服务器上的负载,并允许合法的连接尝试处理。