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
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@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@lists.kamailio.org http://lists.kamailio.org/cgi-bin/mailman/listinfo/users http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
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@evaristesys.comwrote:
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@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@lists.kamailio.org http://lists.kamailio.org/cgi-bin/mailman/listinfo/users http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
Done,
I had a lot of errors so I'll just show the final version that works OK.
=~ "192.168.([0-9]{1,3}).([0-9]{1,3})
The only drawback is that I could pass as valid 192.168.999.999 but as these IPs come from a DNS query, I assume they'll be fine.
Cheers, Uriel
On Fri, Mar 26, 2010 at 11:29 AM, Uriel Rozenbaum <uriel.rozenbaum@gmail.com
wrote:
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@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@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@lists.kamailio.org http://lists.kamailio.org/cgi-bin/mailman/listinfo/users http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
On 3/26/10 4:25 PM, Uriel Rozenbaum wrote:
Done,
I had a lot of errors so I'll just show the final version that works OK.
=~ "192.168.([0-9]{1,3}).([0-9]{1,3})
The only drawback is that I could pass as valid 192.168.999.999 but as these IPs come from a DNS query, I assume they'll be fine.
I think you can reduce it to be just: "^192.168."
Since it comes from dns server or socket attributes, then you are safe.
The other option is to convert it to integer (with transformations) and check it as net mask via bit wise operators.
Cheers, Daniel
Cheers, Uriel
On Fri, Mar 26, 2010 at 11:29 AM, Uriel Rozenbaum <uriel.rozenbaum@gmail.com mailto:uriel.rozenbaum@gmail.com> wrote:
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@evaristesys.com <mailto:abalashov@evaristesys.com>> wrote: 172.16.0.0/12 <http://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@gmail.com <mailto:uriel.rozenbaum@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@lists.kamailio.org <mailto:Users@lists.kamailio.org> http://lists.kamailio.org/cgi-bin/mailman/listinfo/users http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
Kamailio (OpenSER) - Users mailing list Users@lists.kamailio.org http://lists.kamailio.org/cgi-bin/mailman/listinfo/users http://lists.openser-project.org/cgi-bin/mailman/listinfo/users
On Friday 26 March 2010, Uriel Rozenbaum wrote:
I had a lot of errors so I'll just show the final version that works OK.
=~ "192.168.([0-9]{1,3}).([0-9]{1,3})
The only drawback is that I could pass as valid 192.168.999.999 but as these IPs come from a DNS query, I assume they'll be fine.
Hi Uriel,
thank you for sharing this. As Alex mentioned, the easier (and also probably more faster) way is to use the src_ip construct, which 'understand' network ranges.
Cheers,
Henning
Daniel and Henning, thanks for your input. In some cases I have to compare IPs that are not PV. In those cases I'll have to use the regex operator.
Cheers, Uriel
On Tue, Mar 30, 2010 at 11:34 AM, Henning Westerholt < henning.westerholt@1und1.de> wrote:
On Friday 26 March 2010, Uriel Rozenbaum wrote:
I had a lot of errors so I'll just show the final version that works OK.
=~ "192.168.([0-9]{1,3}).([0-9]{1,3})
The only drawback is that I could pass as valid 192.168.999.999 but as these IPs come from a DNS query, I assume they'll be fine.
Hi Uriel,
thank you for sharing this. As Alex mentioned, the easier (and also probably more faster) way is to use the src_ip construct, which 'understand' network ranges.
Cheers,
Henning