[OpenSER-Users] How to check if $rd lies in an IP range

Sergio Gutierrez saguti at gmail.com
Fri Mar 21 02:41:28 CET 2008


Hi Josh.

An approach we used is execute an external script through function exec_msg;
the script receives as argument the source ip address, and by external
means, it checks whether it belongs to a particular subnet, defined on a
table in database or a file; we used PHP and a table in MySQL with the
reference subnets.

The script should return 0 or 1; when returns 0, exec_msg returns true, and
when it returns 1; exec_msg returns false, so you can check it into an if
statement.

Hope it helps.

Best regards.

Sergio Gutiérrez.

On Thu, Mar 20, 2008 at 4:34 PM, Josh Mahonin <jmahonin at cbnco.com> wrote:

> Hi folks,
>
> In my setup, I've got two disjoint subnets (call then A and B) that
> cannot communicate directly to each other, but devices on each can both
> communicate to my OpenSER server and Asterisk box (both on their own
> subnet, C).  There is no NAT involved, so I only want to use rtpproxy
> when it's the case that device from subnet A attempts to call a device
> on subnet B, or vice-versa.
>
> I would ideally not like to use rtp proxy for communication between A-C
> and A-B (this will enable RTP media between both subnets, but that
> solution will not scale very well...)
>
> I'm attempting do something like this:
>
> if (src_ip == a.b.c.d/24 && dst_ip == w.x.y.z/24)
>    use rtp proxy
>
> But unfortunately, on an INVITE, after a lookup, dst_ip is set to the
> OpenSER server.  The pseudovariable $rd is set to the value I'd like to
> check against, but it complains loudly when I attempt to substitute
> dst_ip for $rd.
>
> Is there any way to use avp_check() or the like to verify that the value
> in $rd lies in a given subnet?  I don't want to match just one IP, but a
> whole range.  I found a similar question on the SER mailing list asked
> several years ago, with no response.
>
> Thanks,
>
> Josh
>
>
> _______________________________________________
> Users mailing list
> Users at lists.openser.org
> http://lists.openser.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kamailio.org/pipermail/users/attachments/20080320/85200f22/attachment.htm 


More information about the Users mailing list