[Kamailio-Users] Quick REGEX to match Private IP

Uriel Rozenbaum uriel.rozenbaum at gmail.com
Fri Mar 26 15:29:15 CET 2010


Hi Alex,

Actually what I'm trying to do is check the IPs on a request on a
Kamailio+RTPProxy acting as border of our network.

So I have the ingress IP and egress IP and need to check if I have to bridge
ii, ei, ie or ee.
I managed to obtain all IPs in AVPs, but now I have to check if they are
public or private.

So far our network uses only 192.168.x.x class for private servers.

Thanks for the quick reply
Uriel

On Fri, Mar 26, 2010 at 10:56 AM, Alex Balashov
<abalashov at evaristesys.com>wrote:

> 172.16.0.0/12 does not line up on octet boundaries.  You will need to do
> something other than a regular expression.  Fortunately, 'src_ip' is a
> composite that supports comparisons against subnets in shorthand CIDR
> notation.
>
> It might also be that whatever you are trying to accomplish can be done
> better some other way, but since you did not pose the question in terms of
> the objective, I cannot speak to that.
>
> --
> Sent from mobile device
>
>
> On Mar 26, 2010, at 9:46 AM, Uriel Rozenbaum <uriel.rozenbaum at gmail.com>
> wrote:
>
>  Hi guys,
>>
>> Does anyone have a REGEX syntax to match a private IP on the 192.168.x.x
>> range?
>>
>> I'm trying with:
>> if($avp(s:ip_origen)=~"192.168(\.([1]?\d{1,2}|2[0-4]{1}\d{1}|25[0-5]{1})){2}"
>> )
>>
>> But all IPs pass as private, even public ones.
>>
>> Thanks!
>> Uriel
>> _______________________________________________
>> Kamailio (OpenSER) - Users mailing list
>> Users at lists.kamailio.org
>> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
>> http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20100326/07c4086d/attachment.htm>


More information about the sr-users mailing list