Asterisk 1.8.5.0 behind NAT and clients behind NAT

The server is Fedora release 15 (Lovelock), Asterisk 1.8.5.0, installed trough “yum install asterisk” from Fedora rep.

The net is as follows:

Server side:
Asterisk external IP: 215.121.158.147
Asterisk internal IP: 192.168.0.77
Asterisk SIP port: 45789
Asterisk RTP ports: 10000 to 10036
Open ports in the Router: 45789 and from 10000 to 10036

Client side:
Client external IP: 77.78.2.79
Client internal IP: 192.168.0.102
Client rtp port: 3333

Configuration files:

sip.conf
udpbindaddr=0.0.0.0:45789
matchexternaddrlocally = no
localnet=192.168.0.0/255.255.255.0
externaddr = 215.121.158.147:45789
nat = force_rport
media_address = 215.121.158.147
directmedia=no

rtp.conf:
rtpstart=10000
rtpend=10036

The problem:
When making calls all controls are OK,
But the rtp packets from the server to the client are transmitted not to external IP of the client, but to the internal IP. This is visible when at CLI I have issued command “rtp set debug on”:

Sent RTP packet to 192.168.0.102:3333 (type 00, seq 063049, ts 009280, len 000160)

At one of every 50 cases the server transmits rtp packets to the right address of the client (external) and the voice can be heard, but at other cases there is no voice.

When there is a voice, the debug shows following:
Sent RTP packet to 77.78.2.79:3333 (type 00, seq 063049, ts 009280, len 000160)

Please, if I have mistake on configuration of the Asterisk or the net, help me to resolve it.

Is it possible this to be a bug of the version?

It is very strange, that from time to time rtp packets are transmitted to the right destination…

Your client can not figure out what its external IP address is.
You should try setting nat=comedia for this device or fixing the problem on the client side.

It turn out, that the router at the server side changes destination port of the rtp packets when they arrived from the client to the server.

For example, the client sends rtp packet to the server to port 10033, but the router send this packet to port 10000.
In this way the server doesn’t received any rtp packets from client.

There is no information why when the server does not receive rtp packets tries to send rtp packets not to external IP address of the client (which can be calculated and taken from the sip-information), but to the internal IP of the client.

The problem is solved!

Thank You very much for the support.

i have a problem in the RTP packets, when i set the “media_address” no voice transferred.
seems no RTP between the extensions and the external media server.

please share your experience and if there is a certain configuration must be set on the external media server?