如何停止星号上的注册尝试

主要问题:

我的星号日志充斥着像这样的消息:

[2012-05-29 15:53:49] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 15:53:50] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 15:53:55] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 15:53:55] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 15:53:57] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device <sip:[email protected]>;tag=cb23fe53 [2012-05-29 15:53:57] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device <sip:[email protected]>;tag=cb23fe53 [2012-05-29 15:54:02] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 15:54:03] NOTICE[5578] chan_sip.c: Registration from '<sip:[email protected]>' failed for '37.75.210.177' - No matching peer found [2012-05-29 21:20:36] NOTICE[5578] chan_sip.c: Registration from '"55435217"<sip:[email protected]>' failed for '65.218.221.180' - No matching peer found [2012-05-29 21:20:36] NOTICE[5578] chan_sip.c: Registration from '"1731687005"<sip:[email protected]>' failed for '65.218.221.180' - No matching peer found [2012-05-30 01:18:58] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=dEBcOzUysX [2012-05-30 01:18:58] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=9zUari4Mve [2012-05-30 01:19:00] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=sOYgI1ItQn [2012-05-30 01:19:02] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=2EGLTzZSEi [2012-05-30 01:19:04] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=j0JfZoPcur [2012-05-30 01:19:06] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=Ra0DFDKggt [2012-05-30 01:19:08] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=rR7q7aTHEz [2012-05-30 01:19:10] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=VHUMtOpIvU [2012-05-30 01:19:12] NOTICE[5578] chan_sip.c: Sending fake auth rejection for device "unknown" <sip:[email protected]>;tag=JxZUzBnPMW 

我使用Asterisk作为自动电话系统。 它所做的唯一的事就是接收传入的调用并执行一个Perl脚本。 没有拨出电话,没有来电到实际的电话,没有电话注册与星号。

似乎应该有一个简单的方法来阻止所有未经授权的注册尝试,但我一直在为此奋斗了很长一段时间。 似乎应该有一个更有效的方法来防止这些尝试,甚至远远达不到我的星号日志。 一些设置我可以打开/closures,不允许注册尝试什么的。 有没有办法做到这一点?

另外,我是否正确地假设“注册来自…”消息可能是试图访问我的Asterisk服务器(可能是在我的帐户上拨打电话)的人? 这些消息和“发送假身份validation拒绝…”消息有什么区别?

更多细节:

我知道“从…注册”行是入侵者试图访问我的Asterisk服务器。 通过设置Fail2Ban,这些IP在5次尝试之后被禁止(由于某种原因,有6次尝试,但是w / e)。

但是我不知道“发送伪造授权拒绝…”消息是什么意思或者如何阻止这些潜在的入侵企图。 据我所知,他们从来没有成功(没有看到我的账单或任何奇怪的指控)。

这是我所做的:

  1. 设置硬件防火墙规则如下所示。 这里, xx.xx.xx.xx是服务器的IP地址, yy.yy.yy.yy是我们设施的IP地址, aa.aa.aa.aabb.bb.bb.bbcc.cc.cc.cc是我们的VoIP提供商使用的IP地址。 从理论上讲,10000-20000端口只能由这三个IP访问。
     +-------+-----------------------------+----------+-----------+--------+-----------------------------+------------------+ | Order | Source Ip | Protocol | Direction | Action | Destination Ip | Destination Port | +-------+-----------------------------+----------+-----------+--------+-----------------------------+------------------+ | 1 | cc.cc.cc.cc/255.255.255.255 | udp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 10000-20000 | | 2 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 80 | | 3 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 2749 | | 4 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 443 | | 5 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 53 | | 6 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 1981 | | 7 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 1991 | | 8 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 2001 | | 9 | yy.yy.yy.yy/255.255.255.255 | udp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 137-138 | | 10 | yy.yy.yy.yy/255.255.255.255 | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 139 | | 11 | yy.yy.yy.yy/255.255.255.255 | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 445 | | 14 | aa.aa.aa.aa/255.255.255.255 | udp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 10000-20000 | | 17 | bb.bb.bb.bb/255.255.255.255 | udp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 10000-20000 | | 18 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 1971 | | 19 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 2739 | | 20 | any | tcp | inbound | permit | xx.xx.xx.xx/255.255.255.255 | 1023-1050 | | 21 | any | all | inbound | deny | any on server | 1-65535 | +-------+-----------------------------+----------+-----------+--------+-----------------------------+------------------+ 
  2. 设置Fail2Ban。 这是一种工作,但它是被动的而不是主动的,似乎并没有阻止一切(如“发送假身份validation拒绝…”消息)。
  3. 在sip.conf中设置规则来拒绝除了我的VoIP提供商之外的所有规则。 这是我的sip.conf几乎删除了所有注释行(以节省空间)。 在底部的通知是我的企图否认所有除了我的VoIP提供商:
     [general] context=default allowguest=no allowoverlap=no bindport=5060 bindaddr=0.0.0.0 srvlookup=yes 
    disallow=all allow=g726 allow=ulaw allow=alaw allow=g726aal2 allow=adpcm allow=slin allow=lpc10 allow=speex allow=g726
    insecure=invite
    alwaysauthreject=yes
    ;registertimeout=20 registerattempts=0 register => user:pass:[email protected]:5060/700
    [mysipprovider] type=peer username=user fromuser=user secret=pass host=sip.mysipprovider.com fromdomain=sip.mysipprovider.com nat=no ;canreinvite=yes qualify=yes context=inbound-mysipprovider disallow=all allow=ulaw allow=alaw allow=gsm insecure=port,invite
    deny=0.0.0.0/0.0.0.0 permit=aa.aa.aa.aa/255.255.255.255 permit=bb.bb.bb.bb/255.255.255.255 permit=cc.cc.cc.cc/255.255.255.255

这些防火墙规则已经存在多久了? 如果您刚才只configuration了它们,并且取决于您如何configuration它们,规则可能只适用于新的连接尝试,但是仍然允许任何已build立的连接。 因此,在已经build立的连接上进行的注册尝试仍将被允许。

您没有提供有关所使用的防火墙types的足够信息,但是请查看是否可以在端口5060上find已build立连接的列表,然后手动删除它们。 现在应根据您的防火墙规则阻止后续的新连接尝试。

我也看到你已经在你的星号configuration文件中设置了bindaddr=0.0.0.0 ,这会导致Asterisk侦听所有可用的接口。 这台服务器有多less个IP地址? 如果IP地址超过1个,则需要在防火墙规则中指定所有IP地址,因为目前只列出xx.xx.xx.xx作为目标IP,以阻止端口5060上的传入通信。

总之,你阻止了错误的端口。 SIP注册发生在端口5060(TCP或UDP)上。 10000+端口将用于实际的RTP承载业务,而不是呼叫build立。 调整您的防火墙阻止5060和5061入站,你应该停止看到消息。 当您处于这个状态时,您可能还会考虑您是否希望或需要您的系统监听所有接口上的SIP注册。 请记住 – 您可能会连接到您的提供商,反之亦然。

在这种情况下我要做的就是在防火墙上设置一个特定的拒绝规则 – 阻止端口5060上的stream量到你的Asterisk盒​​子。 如果注册仍然被允许 – 那么你将不得不仔细看看你的防火墙configuration,并确定为什么它不工作。

当然 – 应该通过你目前所掌握的拒绝规则来阻止,但显然没有抓住它。

希望这可以帮助。

显然,注册可以通过端口5060/5061进入。 即使你指定

端口= 5061

要么

bindport = 5061

要么

bindaddr = 0.0.0.0:5061

星号似乎仍然接受端口5060注册,一切仍然有效。