We have some Asterisk servers that we are moving behind a NAT to preserve public addresses and make room for growth. This is Asterisk 1.4
NAT works very good with the externip/localnet-setting when we are connected directly to our teleco. But when I try to use NAT and put them behind our Kamailio something interesting happens: The media-address in the SDP is the internal ip and not the external.
This is the setup:
Teleco <-> Kamailio <-> Asterisk
SIP –> 22.214.171.124
10.0.0.1 –> 10.0.0.2
RTP <----------------> 126.96.36.199 (NAT:ed to 10.0.0.2)
On an incomming call from the teleco -> to kamailio (public addr) -> to asterisk in the private net. Asterisk responds with the following SDP:
o=root 1889 1889 IN IP4 10.0.0.2
s=session c=IN IP4 10.0.0.2
m=audio 23344 RTP/AVP 8 0 101
Asterisk seems to think that because the proxy is on the localnet, the media is too, so it doesn’t use the externip as the RTP-ip.
This is a incomming call and the RTP ip of the other leg is another public address. So the RTP-ip should the public address (externip).
If I connect to the teleco directly from the pbx (bypassing kamailio)
Asterisk correctly uses the externip as the rtp-ip in the SDP.
I know this is an old and unsupported version of Asterisk, but any input on the topic is welcome. If this is supported in later versions we can maybe work around until we migrate later.