[asterisk-dev] SIP replies to via or to ip/port (according to RFC)

Alex Hermann alex at speakup.nl
Thu Dec 17 03:17:17 CST 2009

On Thursday 17 December 2009 08:20:45 Olle E. Johansson wrote:
> Asterisk currently send SIP responses to the address in the address in the
>  last VIA header in the SIP message received. If NAT support is turned on,
>  we reply to the sender's IP and port.

> I suggest we take a final stab at resolving this bug report like this:
> - We add a setting "replytovia" with yes | no
> - We set it default to yes in the code and sample config for all releases
>  (1.4, 1.6.x) - We set it to no in the code and sample config for trunk
> This way, we won't disturb current installs and will make it optional to
>  follow the RFC in these versions. In trunk, we follow the RFC and make it
>  optional (like in Kamailio) to not follow the RFC.

May I suggest an alternative approach:

By default, strictly follow rfc3261 section 18.2.2 and rfc3581 when it comes 
to sending replies. It covers all situations (including NAT) and as such there 
is no need for a replytovia setting (the setting is removed from kamailio/sip-
router because it was acknowledged it was an unnecessary hack that served no 
goal except to _create_ interoperability issues) .

Convert the nat option to do the following:

nat=no: do nothing special, just follow rfc's strictly, thus allowing all 
kinds of funny tricks with Via's and ip-addresses and allow for asymmetric 


1) Force an rport parameter in the first Via header. The (default) procedures 
described in paragraph A above will do the rest.

2) Force symmetric RTP.

Maybe splitting the nat= option to 2 separate options doing the above 
functions might be a better choice. The ambiguous nat= option can be 
eliminated altogether then.
Alex Hermann

More information about the asterisk-dev mailing list