Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hello Rudy, Be sure you use "t_relay()" when forwarding the REGISTER request (and not forward() function). Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 23.02.2014 20:32, Rudy Eschauzier wrote: Ok, I think I am getting there. I am able to forward the client registration to Asterisk, and Twinkle reports "registration succeeded" (YES!). I am having some trouble saving the location, however. This is what I have: onreply_route { xlog("incoming reply\n"); xlog("L_INFO","\n\n$C(bc)[ Reply $rs ($rr) from $si concerning $rm ]$C(xx)\n$mb$C(bc)[ End of Reply ]$C(xx)\n"); if ($rs==200) { save("location"); } exit; } The forwarding is done in the main route block like this: if(!t_relay()) sl_reply_error(); But the result that OpenSips gives is: Feb 23 19:22:29 [26043] ERROR:registrar:save: Transaction not created on Register - can not save on reply That seems to make sense, as the transaction is created by the t_relay. How else would OpenSips know where the response is coming from? Any suggestions? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Ok, I think I am getting there. I am able to forward the client registration to Asterisk, and Twinkle reports "registration succeeded" (YES!). I am having some trouble saving the location, however. This is what I have: onreply_route { xlog("incoming reply\n"); xlog("L_INFO","\n\n$C(bc)[ Reply $rs ($rr) from $si concerning $rm ]$C(xx)\n$mb$C(bc)[ End of Reply ]$C(xx)\n"); if ($rs==200) { save("location"); } exit; } The forwarding is done in the main route block like this: if(!t_relay()) sl_reply_error(); But the result that OpenSips gives is: Feb 23 19:22:29 [26043] ERROR:registrar:save: Transaction not created on Register - can not save on reply That seems to make sense, as the transaction is created by the t_relay. How else would OpenSips know where the response is coming from? Any suggestions? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Alright. Maybe I am getting the hang of it then ;) Thanks for your help! Rudy. On Sat, 2/22/14, Bogdan-Andrei Iancu wrote: Subject: Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT To: "Rudy Eschauzier" , "users@lists.opensips.org" Date: Saturday, February 22, 2014, 10:41 PM I was just explaining the scenarios for using the 2 functions :). In your case, saving the REGISTER local and forwarding it also, you will need to use both functions in the same time. Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
I was just explaining the scenarios for using the 2 functions :). In your case, saving the REGISTER local and forwarding it also, you will need to use both functions in the same time. Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 22.02.2014 19:24, Rudy Eschauzier wrote: If you simply forward the REGISTERs (without localing handling them with registrar module), makes no sense to use fix_nated_registrar() -> use only fix_nated_contact(). Don't I need to fix the registration and save to usrloc to allow keepalive through the nat? I thought that is what fix_nated_registrar() does. How else will nathelper know what IP & port to ping? ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
If you simply forward the REGISTERs (without localing handling them with registrar module), makes no sense to use fix_nated_registrar() -> use only fix_nated_contact(). >> Don't I need to fix the registration and save to usrloc to allow keepalive >> through the nat? I thought that is what fix_nated_registrar() does. How else >> will nathelper know what IP & port to ping? ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Rudy, Yes, you can see the messages sent out by OpenSIPS with any network capturing tool like wireshark, ngrep , tcpdump. OpenSIPS does not print the outgoing messages in order to avoid flooding the logs (keep in mind an OpenSIPS instance can do more than 10K cps!). If you simply forward the REGISTERs (without localing handling them with registrar module), makes no sense to use fix_nated_registrar() -> use only fix_nated_contact(). Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 22.02.2014 17:51, Rudy Eschauzier wrote: Hi Bogdan, So you cannot "see" your own changes in the script, but you can see them in the outbound message. You mean using WireShark, right? Is there any way to have OpenSips itself report on the message it sends out? Other than that, is the use of fix_nated_register() and fix_nated_contact() the right way to handle registration forwarding to Asterisk? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hi Bogdan, So you cannot "see" your own changes in the script, but you can see them in the outbound message. >> You mean using WireShark, right? Is there any way to have OpenSips itself >> report on the message it sends out? >> Other than that, is the use of fix_nated_register() and fix_nated_contact() >> the right way to handle registration forwarding to Asterisk? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hello Rudy, fix_nated_contact() changes the URI in the contact HDR - as any change (in OpenSIPS) over the message is not done in realtime (updating the message buffer). The changes are recorded (as lumps) and applied to the message only when the message is sent out on the network. So you cannot "see" your own changes in the script, but you can see them in the outbound message. Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 22.02.2014 10:36, Rudy Eschauzier wrote: Bogdan, One more question about logging. I want to check if the sip message is properly mangled by fix_nated_register() and fix_nated_contact(). I've tried it like this: fix_nated_register(); xlog("L_INFO","$avp(rcv)"); fix_nated_contact(); xlog("L_INFO","\n\n$ct, $(ct[1])\n"); xlog("L_INFO","\n\n$C(bc)[ Method $rm from $si ]$C(xx)\n$mb$C(bc)[ End of Request ]$C(xx)\n"); The $avp(rcv) variable is properly updated by fix_nated_register(), and it correctly logs the public ip address. I cannot get the rewritten contact or sip message to log, however. What is the best way to check what the effect was of fix_nated_contact? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Bogdan, One more question about logging. I want to check if the sip message is properly mangled by fix_nated_register() and fix_nated_contact(). I've tried it like this: fix_nated_register(); xlog("L_INFO","$avp(rcv)"); fix_nated_contact(); xlog("L_INFO","\n\n$ct, $(ct[1])\n"); xlog("L_INFO","\n\n$C(bc)[ Method $rm from $si ]$C(xx)\n$mb$C(bc)[ End of Request ]$C(xx)\n"); The $avp(rcv) variable is properly updated by fix_nated_register(), and it correctly logs the public ip address. I cannot get the rewritten contact or sip message to log, however. What is the best way to check what the effect was of fix_nated_contact? Thanks, Rudy. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
This is extremely helpful. I think I have enough to get started. Thanks so much! Rudy. On Thu, 2/20/14, Bogdan-Andrei Iancu wrote: Subject: Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT To: "Rudy Eschauzier" , "users@lists.opensips.org" Date: Thursday, February 20, 2014, 12:22 PM Yes, it work for it, but for TCP based protocols you need (aside the pinging) to take care of keeping the connection up (opensips may close it if not used) - but using registrar (via save()) will take care of this automatically. Also look into "tcp_no_new_conn_bflag": http://www.opensips.org/Documentation/Script-CoreParameters-1-10#toc93 Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Yes, it work for it, but for TCP based protocols you need (aside the pinging) to take care of keeping the connection up (opensips may close it if not used) - but using registrar (via save()) will take care of this automatically. Also look into "tcp_no_new_conn_bflag": http://www.opensips.org/Documentation/Script-CoreParameters-1-10#toc93 Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 19.02.2014 23:19, Rudy Eschauzier wrote: Thanks so much for looking into this! One last question: will this approach also work with TCP & TLS? Regards, Rudy I see, but doesn't that mean that the uac will need to register with OpenSips, instead of what I am trying to do: forward registration to Asterisk? You can do both - pass the REGISTER through (to FS) and have it also locally registered on OpenSIPS ( use the save() function in the reply route when you get the 200 OK for REGISTER). ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
On 19.02.2014 20:29, Rudy Eschauzier wrote: Nathelper is using the usrloc (registration based) for doing the nat pinging (to remember which destinations need to be pinged). I see, but doesn't that mean that the uac will need to register with OpenSips, instead of what I am trying to do: forward registration to Asterisk? You can do both - pass the REGISTER through (to FS) and have it also locally registered on OpenSIPS ( use the save() function in the reply route when you get the 200 OK for REGISTER). Regards, Bogdan ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hello, Nathelper does not require rtpproxy for nat keepalive - the nat keepalive is at signaling level, while rtpproxy is exclusively for media pinning. >> Ah, ok. Nathelper is using the usrloc (registration based) for doing the nat pinging (to remember which destinations need to be pinged). >> I see, but doesn't that mean that the uac will need to register with >> OpenSips, instead of what I am trying to do: forward registration to >> Asterisk? ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hello, Nathelper does not require rtpproxy for nat keepalive - the nat keepalive is at signaling level, while rtpproxy is exclusively for media pinning. Nathelper is using the usrloc (registration based) for doing the nat pinging (to remember which destinations need to be pinged). Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 19.02.2014 10:57, Rudy Eschauzier wrote: Hi Bogdan, Thanks for your response. I did investigate both nathelper and nat_traversal. My conclusion was that nathelper doesn't qualify per the requirements below, because it requires rtpproxy to do the nat keepalive. I probably missed something there. With nat_traversal being the better choice (or at least thinking that that is the case), I started looking for examples, but I couldn't find any (which I thought was a little weird). I _think_ what I would need is to use $source_uri to rewrite the contact header of the REGISTER request, before forwarding it to the Asterisk box. In Asterisk I would then need to define the OpenSips server as the outbound proxy. Does that make sense? Regards, Rudy. > What I would like is the following: > > -Run OpenSips on the router > -Have OpenSips act as a stateless proxy, only forwarding and mangling messages > -Handle all registration requests on the Asterisk box > -Make sure NATed clients are kept alive & can be reached > -Avoid OpenSips database use (not to overload the router) > -Not use a RTP proxy (the public RTP ports can be forwarded to Asterisk, so clients can talk directly to the PBX) ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
You will need RTPProxy to manage the media and proxy that over to asterisk in order not to get `retransmission timeouts`. RTP Proxy is very versatile, perfect for far-end NAT setups. We use it in our deployment. You can hit me up if you require a working config. OpenSIPS does not manage media (ie, RTP Stream) Kind Regards, Nick. ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hi Bogdan, Thanks for your response. I did investigate both nathelper and nat_traversal. My conclusion was that nathelper doesn't qualify per the requirements below, because it requires rtpproxy to do the nat keepalive. I probably missed something there. With nat_traversal being the better choice (or at least thinking that that is the case), I started looking for examples, but I couldn't find any (which I thought was a little weird). I _think_ what I would need is to use $source_uri to rewrite the contact header of the REGISTER request, before forwarding it to the Asterisk box. In Asterisk I would then need to define the OpenSips server as the outbound proxy. Does that make sense? Regards, Rudy. > What I would like is the following: > > -Run OpenSips on the router > -Have OpenSips act as a stateless proxy, only forwarding and mangling messages > -Handle all registration requests on the Asterisk box > -Make sure NATed clients are kept alive & can be reached > -Avoid OpenSips database use (not to overload the router) > -Not use a RTP proxy (the public RTP ports can be forwarded to Asterisk, so clients can talk directly to the PBX) ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Re: [OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
Hello, yes, you can do all of those with OpenSIPS - it is just a matter of scripting logic and using the one of the nat handling modules: nathelper - http://www.opensips.org/html/docs/modules/1.10.x/nathelper.html nat_traversal - http://www.opensips.org/html/docs/modules/1.10.x/nat_traversal.html Both modules will help you with mangling the SIP messages and with doing SIP pinging. Regards, Bogdan-Andrei Iancu OpenSIPS Founder and Developer http://www.opensips-solutions.com On 18.02.2014 12:57, Rudy Eschauzier wrote: My Asterisk appliance works poorly with NATed clients. Now I'd like to run OpenSips on my internet-facing router to help the NAT performance. Although I understand that OpenSips is the preferred choice for registrating clients, the fact that the Asterisk appliance is a closed box forces me to find an alternative. What I would like is the following: -Run OpenSips on the router -Have OpenSips act as a stateless proxy, only forwarding and mangling messages -Handle all registration requests on the Asterisk box -Make sure NATed clients can be are kept alive & can be reached -Avoid OpenSips database use (not to overload the router) -Not use a RTP proxy (the public RTP ports can be forwarded to Asterisk, so clients can talk directly to the PBX) This way, from a user perspective nothing will change in the setup, except that OpenSips takes care of NAT. Is this at all possible? ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users
[OpenSIPS-Users] OpenSips as simple frontend to Asterisk to deal with NAT
My Asterisk appliance works poorly with NATed clients. Now I'd like to run OpenSips on my internet-facing router to help the NAT performance. Although I understand that OpenSips is the preferred choice for registrating clients, the fact that the Asterisk appliance is a closed box forces me to find an alternative. What I would like is the following: -Run OpenSips on the router -Have OpenSips act as a stateless proxy, only forwarding and mangling messages -Handle all registration requests on the Asterisk box -Make sure NATed clients can be are kept alive & can be reached -Avoid OpenSips database use (not to overload the router) -Not use a RTP proxy (the public RTP ports can be forwarded to Asterisk, so clients can talk directly to the PBX) This way, from a user perspective nothing will change in the setup, except that OpenSips takes care of NAT. Is this at all possible? ___ Users mailing list Users@lists.opensips.org http://lists.opensips.org/cgi-bin/mailman/listinfo/users