[OpenSER-Users] Fix up source address.

Robert Dyck rob.dyck at telus.net
Fri Jan 11 18:22:49 CET 2008


Is your public IP dynamic? I am curious how other people handle the problem of 
dynamic IP's within the context of openser. If you hard code an address in 
the script it has to be manually changed whenever your IP changes.

On Friday 11 January 2008, Peter P GMX wrote:
> Hello Robert,
>
> I think it may have to do with the following point, which I found?
>
> http://openser.org/pipermail/devel/2007-May/007701.html
>
>
>
> <Quote>
>
> This is not a bug, but a known limitation of openser. In openser, message
> rewriting is done at the end of the routing. All the openser.cfg functions
> which manipulates the message generates "lumps". This lumps are applied at
> just before sending out the message. Thus, all functions always see the
> original received message even if another function already manipulated the
> message (added a lump). Thus, if the same part of the message is rewritten
> twice, the behavior is undefined.
>
> In your case, the manipulate the Contact header 2 times:
> 1. subst()
> 2. fix_nated_contact() or fix_contact()
>
> </Quote>
>
> In my case  after this replacement there is another fix_contact() and
> then this function breaks.
>
> How do I set the var?
> $var(my_ip)="33.222.111.0";
>
>
> Best regards Peter.
>
> Robert Dyck schrieb:
> > The example I gave works for me with openser 1.3.0 and I have not tried
> > it with other versions.
> >
> > In the example the substring contained within the ( ) like (Contact:.+@)
> > is supposed to be preserved by /\1whatever/ and the remainder of the left
> > side should be discarded.
> >
> > It's too bad that openser is designed primarily for service providers
> > With a few tweaks it would be easier for SIP users to set up. Like I
> > mentioned earlier there is an old patched version of nathelper that did
> > the contact mangling quite well. And the typical small user has to deal
> > with dynamic IP's as well. I think the IP's of eth0 or whatever should be
> > made available to the routing script like a pseudo var. Another nice
> > thing would be a well thought example script that would serve the needs
> > of a home or small business phone system. It's time to get off the soap
> > box.
> >
> > I am curious, how do you go about setting $var(my_ip)?
> >
> > On Thursday 10 January 2008, Peter P GMX wrote:
> >> I have a similar problem, but this regexp solution caused a strange
> >> behaviour
> >>
> >> The original Contact Address, which shall replaced is:
> >> sip:49xxxxxx1200 at 10.10.1.51:5060
> >> with $var(my_ip)=33.222.111.0 (Example)
> >>
> >> subst('/(Contact:.+@)[0-9.]+.*>/\1$var(my_ip)>/');
> >> leads to
> >> <sip:49xxxxxx1200 at 10.10.1.51:506049xxxxxx1200 at 33.222.111.0>
> >> So the secod address is simply added.
> >>
> >>
> >> I tried another way:
> >> replace_all("sip:49xxxxxx1200 at 10.10.1.51>",
> >> "sip:49xxxxxx1200 at 33.222.111.0>");
> >> leads to
> >> Contact: <sip:49xxxxxx1200 at 33.222.111.0>sip:49xxxxxx1200 at 10.10.1.51:5060
> >>
> >> Best regards
> >> Peter
> >>
> >> Robert Dyck schrieb:
> >>> I assume you are referring to a SIP message and not its IP wrapper. And
> >>> I also assume you are using fix_nated_contact() from nathelper. This
> >>> function is working as it was designed. I quote from the documentation
> >>> "Rewrites Contact HF to contain request's source address:port".
> >>>
> >>> I believe nathelper was built to aid service providers who might
> >>> receive SIP messages with unroutable contacts.
> >>>
> >>> In the past I have used a patched version of nathlper that let you
> >>> specify the address you wanted in the Contact. I did not write the
> >>> patch and I am not a programmer so I did not want to build a new patch
> >>> for each new version of openser. I finally settled for a textops
> >>> equivalent. $var(my_ip) is set elsewhere in the script.
> >>>
> >>> subst('/(Contact:.+@)[0-9.]+.*>/\1$var(my_ip)>/');
> >>>
> >>> On Friday 28 December 2007, Alex Balashov wrote:
> >>>> Greetings,
> >>>>
> >>>> I have a strange problem using OpenSER 1.3.x with nathelper.
> >>>>
> >>>> Two ethernet interfaces:
> >>>>
> >>>> eth0 = 192.168.0.0/24
> >>>> eth1 = outside.ip/29
> >>>>
> >>>> For some reason, no matter what I do to mangle the requests with
> >>>> nathelper's functions, the packet is *always* sent out of eth1 with
> >>>> the *source address* of the machine's eth0.  Obviously, the response
> >>>> from the far-end SIP peer never gets back.
> >>>>
> >>>> The packet does physically go over eth1, I know that much from packet
> >>>> captures.  I don't even see how this is possible;  when OpenSER issues
> >>>> a packet, shouldn't it originate according to the machine's routing
> >>>> table, take the most specific route, and consequently, adopt the right
> >>>> source address?
> >>>>
> >>>> What gives?
> >>>>
> >>>> I have OpenSER 'listening' on both interfaces, and have tried both on
> >>>> and off with this setting.
> >>>>
> >>>> Thanks,
> >>>>
> >>>> --
> >>>> Alex Balashov
> >>>> Evariste Systems
> >>>> Web    : http://www.evaristesys.com/
> >>>> Tel    : +1-678-954-0670
> >>>> Direct : +1-678-954-0671
> >>>>
> >>>> _______________________________________________
> >>>> Users mailing list
> >>>> Users at lists.openser.org
> >>>> http://lists.openser.org/cgi-bin/mailman/listinfo/users
> >>>
> >>> _______________________________________________
> >>> Users mailing list
> >>> Users at lists.openser.org
> >>> http://lists.openser.org/cgi-bin/mailman/listinfo/users






More information about the Users mailing list