0
if (method=="INVITE" && uri=~"NUMBER")
   {
       #rewriteuri("sip:+45NUMBER@voipXXX.opensips.local");
       rewritehost("voipXXX.opensips.local");
       t_relay();
       exit;

this is an example of how my openSIPS server handles invites, i want to make it so that i'm only able to accept invites from certain ips? do anyone know how this could be done.

this only takes into account which number is calling, not which ip its from

Claudi
  • 125
  • 1
  • 1
  • 9

2 Answers2

0

&& $si == '10.0.0.1'

http://www.opensips.org/Documentation/Script-CoreVar

Section 3.79

Oliver Tynes
  • 954
  • 4
  • 11
0

Instead of hardcoding the source IPs you want to allow, take a look at the PERMISSIONS module.

http://www.opensips.org/html/docs/modules/1.11.x/permissions.html

Especially take a look at the check_source_address command.

You may create a group and put inside all the authorized IPs. For example, if you created group 1, you can use this snippet in your script:

if(!check_source_address("1")) {
    send_reply("403","Forbidden");
    exit;
} 
manash
  • 6,985
  • 12
  • 65
  • 125