Summary:ASTERISK-07941: [patch] Enable specifying SDP RTP IP address
Reporter:Jon Leren Schøpzinsky (jonleren)Labels:
Date Opened:2006-10-17 04:42:55Date Closed:2006-10-29 15:11:28.000-0600
Versions:Frequency of
Environment:Attachments:( 0) rtpip.patch
Description:When running OpenSER as a proxy in front of a group of Asterisk servers, where Asterisk handles the SDP portion of the SIP commuincation, if the asterisk server has a local ip, such as the 192.168.xxx.xxx range, it will respond with this address in the SDP message, as it is not aware of its external IP address.
This patch enables the user to set rtpip=external ip address, so that this IP always gets sent in the SDP portion of the message, regardless of NAT.
rtpip gets configured in sip.conf, and is set to auto from default. This lets Asterisk determine what IP address to use for the SDP message. To enable the patch, you need to set it to the IP address you want the RTP traffic to be sent to.
Comments:By: Olle Johansson (oej) 2006-10-17 07:01:06

Isn't it better to use the existing externip setting, or does this not work?

And OpenSER definitely has support for rewriting the iP address.

Just trying to figure out what problem you want to solve.

By: Jon Leren Schøpzinsky (jonleren) 2006-10-17 07:07:44

The externip setting works great, if the request comes from an external ip address, outside the localnet setting.
The problem is that this is the setup we are using:

Phone -> OpenSER -> Asterisk.
INET         |     LOCAL NET

In this setup, OpenSER relays the INVITE message to asterisk, over the local network, so the request that asterisk has to respond to, is actually from a local ip address, and therefore it uses its local IP address in the invite message. This is fixed by being able to set the ip address, that it should use in the INVITE it sends out.
Regarding OpenSER, we only use it to rewrite the rest of the SIP message, not the SDP part.

By: Olle Johansson (oej) 2006-10-17 10:31:52

But then you will need to rewrite more. You really need to set localnet to an undefined random network to force asterisk to use the externIP for both contact and SDP.

By: Olle Johansson (oej) 2006-10-25 12:54:44

Any comments?

By: Jon Leren Schøpzinsky (jonleren) 2006-10-25 16:10:22

I think i will code a new version of the patch, in which the SDP RTP IP address can be specified per peer/user.
I would think its a better fix, than "cheating" by changing the localnet property, since one could imagine a scenario, where one would actually have to use the localnet setting, and still need to be able to change the SDP RTP IP address.

By: Olle Johansson (oej) 2006-10-26 01:15:54

Please describe that "imagined" scenario to see if it makes sense. In order to change the current code, I need a reason to. The problem you had could be solved by the current code, right?

By: Jon Leren Schøpzinsky (jonleren) 2006-10-26 02:33:08

Heres a scenario, its pretty specific for our problem, so this might not be interesting as a general patch to asterisk:
You have an internal network, behind a firewall. The addresses of the internal network is in the 192.168.1.xxx range In this network you have an OpenSER server at, and an asterisk server at We also have a client at, and a some 1000 external clients who comes in from the internet to the OpenSER server.
The OpenSER server relays all SIP messages, excluding REGISTER messages, which it handles itself. When an INVITE is issued, it relays the message to Asterisk at, and relayes the message back to the client, without changing the SDP part of the message. This is where the RTP IP patch comes in. Asterisk will return its as RTP IP address, and this ofcourse will not work, as the internet client can not connect to this address. But when the internal client at connects to OpenSER, the address is correct, and therefore the localnet property is set to, and Asterisk handles the RTP as normal.

This is not a very general scenario, so i dont know if it should be included in general Asterisk.

By: Olle Johansson (oej) 2006-10-29 15:09:44.000-0600

Moving this discussion to duplicate bug ASTERISK-7064. Thanks.