2015-10-15 26 views

回答

0

IP地址与 deny=0.0.0.0/0.0.0.0 permit=192.168.50.0/255.255.255.0

0
做吧

在星号dialplan.` [全局] IP = 192.168.50.0 MASK = 24

[test] 
    exten => _X.,1,Set(OutPUT=$[${SHELL(php -f ${ASTVARLIBDIR}/agi-bin/ipnotify.php ${recvip} ${GLOBAL(IP)} ${GLOBAL(MASK)})}]) 
    exten => _X.,n,Set(recvip=${CHANNEL(recvip)}) 
    exten => _X.,n,Gotoif($["${OutPUT}"="1"]?InOffice:outOfOffice) 

In ipnotify.php

<?php 
    $ip=$argv[1]; 
    $net_addr=$argv[2]; 
    $net_mask=$argv[3]; 

    function ip_in_network($ip, $net_addr, $net_mask){ 
    if($net_mask <= 0){ return false; } 
    $ip_binary_string = sprintf("%032b",ip2long($ip)); 
    $net_binary_string = sprintf("%032b",ip2long($net_addr)); 
    return (substr_compare($ip_binary_string,$net_binary_string,0,$net_mask) === 0); 
    } 
    echo ip_in_network("$ip","$net_addr",$net_mask); 
    ?>` 
+0

永远不要使用agi进行访问检查。这将导致服务器停止任何单一的低容量攻击。 – arheops

0

正确的设置将使用iptables规则:

iptables -A INPUT -m udp -p udp --destination-port 5060 -s 192.168.50.0/30 -j ACCEPT 
iptables -A INPUT -m udp -p udp --destination-port 5060 -j DROP 

所有其他解决方案(包括星号许可证),会吃,而你在自动攻击你的resouces。

相关问题