返回列表 回复 发帖

Limiting icmp unreach response from 217 to 200 packets/sec

【现象】
view source
print?
1.Limiting open port RST response from 28 to 10 packets/sec
2.Limiting open port RST response from 28 to 10 packets/sec
3.Limiting open port RST response from 27 to 10 packets/sec
4.Limiting open port RST response from 29 to 10 packets/sec
5.Limiting open port RST response from 18 to 10 packets/sec
6.Limiting open port RST response from 84 to 10 packets/sec

【说明】

FreeBSD 中 sysctl 有个 icmplim 变量,缺省值为200。还有个 icmplim_output 控制它是否输出。如果为1,就输出你看到的信息,为0,就没有输出。

在sysctl中如下:
view source
print?
1.net.inet.icmp.icmplim: 200
2.net.inet.icmp.icmplim_output: 1

icmplim 的含义好像是规定内核每秒接受 ICMP 包的最大数量。你看到的信息是由内核中的一个函数通过测试每秒接受 ICMP 包的实际最大数量所打印的。

当实际的数量大于 icmplim 时就会打印你看到的信息。84表示当前实际接受的数量,10就是你设置的上限数量。

这种信息只是让你知道系统曾经的状态。你这里的信息意思是:曾经有个时候,你机器中的ICMP不可达包的数量每秒达到了84。

涉及具体的代码如下:
view source
print?
01./*
02. * badport_bandlim() - check for ICMP bandwidth limit
03. *
04. *  Return 0 if it is ok to send an ICMP error response, -1 if we have
05. *  hit our bandwidth limit and it is not ok.
06. *
07. *  If icmplim is <= 0, the feature is disabled and 0 is returned.
08. *
09. *  For now we separate the TCP and UDP subsystems w/ different 'which'
10. *  values.     We may eventually remove this separation (and simplify the
11. *  code further).
12. *
13. *  Note that the printing of the error message is delayed so we can
14. *  properly print the icmp error rate that the system was trying to do
15. *  (i.e. 22000/100 pps, etc...).     This can cause long delays in     printing
16. *  the 'final' error, but it doesn't make sense to solve the printing
17. *  delay with more complex code.
18. */
19.
20.int
21.badport_bandlim(int which)
22.{
23.    static int lticks[BANDLIM_MAX + 1];
24.    static int lpackets[BANDLIM_MAX + 1];
25.    int dticks;
26.    const char *bandlimittype[] = {
27.        "Limiting icmp unreach response",
28.        "Limiting icmp ping response",
29.        "Limiting icmp tstamp response",
30.        "Limiting closed port RST response",
31.        "Limiting open port RST response"
32.        };
33.
34.    /*
35.     * Return ok status if feature disabled or argument out of
36.     * ranage.
37.     */
38.
39.    if (icmplim <= 0 || which > BANDLIM_MAX || which < 0)
40.        return(0);
41.    dticks = ticks - lticks[which];
42.
43.    /*
44.     * reset stats when cumulative dt exceeds one second.
45.     */
46.
47.    if ((unsigned int)dticks > hz) {
48.        if (lpackets[which] > icmplim && icmplim_output) {
49.            printf("%s from %d to %d packets per second\n",
50.                bandlimittype[which],
51.                lpackets[which],
52.                icmplim
53.            );
54.        }
55.        lticks[which] = ticks;
56.        lpackets[which] = 0;
57.    }
58.
59.    /*
60.     * bump packet count .bump means add
61.     */
62.
63.    if (++lpackets[which] > icmplim) {
64.        return(-1);
65.    }
66.    return(0);
67.}

【解释】

这是由于某些主机正试图快速的访问你的主机上一些没有开放的端口,你的主机正在回复RST报文。这是正常的反应。但是FreeBSD内核限制了每秒钟回复RST报文的数量,以防止发生可能的DoS攻击。例如,如果攻击者通过伪造源IP来向你的未开端口发送大量连接请求,就可能诱使你的主机向该主机发送RST报文。这可能导致受害主机所在网络的带宽占用。如果你不想看到上述信息,你可以通过打开黑洞模式来停止响应RST报文。这也可以减缓远程攻击者对你的主机的扫描速度。

【处理】

你可以使用如下命令来打开balckhole支持:
view source
print?
1.sysctl -w net.inet.tcp.blackhole=2
2.sysctl -w net.inet.udp.blackhole=1

也可以在/etc/sysctl.conf中增加下列选项:
view source
print?
1.net.inet.tcp.blackhole=2
2.net.inet.udp.blackhole=1

使这种模式每次启动后都生效。

【补充一下】

FreeBSD 系统中有一个 blackhole 的功能。

blackhole sysctl(8) MIB 用来控制当对一些没有 socket 监听的 TCP 或者 UDP port 接收到连接请求时所操作的行为,你可以使用 man blackhole 获得详细的信息,当设置这个选项後,对那些连接没有 socket 监听的 TCP 或者 UDP 通讯埠的连接,系统将马上丢弃这个包而不发 RST 包。
Postfix技术专业支持论坛
http://www.thismail.org/bbs
-----------------------------------
提供专业postfix技术支持,邮件系统开发定制
QQ:187159779 注明(Postfix技术支持)
成都成都Linux维护,代维。FreeBSD维护,代维,维护各种服务器。
返回列表
开源邮件服务器 开源邮件服务器 web 开源邮件 开源 mail 开源 邮件服务器 邮件技术 mail技术 反垃圾邮件 反垃圾mail mail投递
邮件服务器 mail服务器 开源软件 mail软件 mail服务新品牌 开源邮件服务新品牌
开源mail服务新网站 邮件服务新品牌 mail tmail mailserver 163邮件 sendmail |Linux维护|Linux代维|成都Linux维护|成都Linux代维