Block Outbound Calls Based On IP Address

Home » Asterisk Users » Block Outbound Calls Based On IP Address
Asterisk Users 3 Comments

Hi,

You can try with SIPCHANINFO function otherwise you need to modify chan_sip.c for getting this addresses.

thanks Dhaval

3 thoughts on - Block Outbound Calls Based On IP Address

  • Thanks.

    exten => s,n,Set(foo=${CHANNEL(peerip)}) ; Doesn’t return anything exten => s,n,Set(foo=${CHANNEL(recvip)}) ; Doesn’t return anything exten => s,n,Set(foo=${SIPCHANINFO(peerip)}) ; Returns public IP when calling from a SIP device

    Strange that CHANNEL doesn’t return anything.

  • Hi,

    How many Public IPs connect to you ? If they are less than 15 or 10 , I
    suggest you make sip.conf peers for them with host=Publicip and then decide if you want that to be blocked or rerouted to some other direction !

    If that isn’t doable then try extracting/parsing some IP using the SIP_HEADER function. Collect some header on incoming call and extract your required IP field and then do some DB operation etc

    Regards, Sammy

  • Thanks for the reply however it is not possible to get the public IP address using the SIP_HEADER function (see my original post).

    We have many devices connecting from hundreds of dynamic external IPs.