Asterisk NAT RTP issue

asterisk ip:192.168.255.161----firwall(ip-120.X.X.X)–internet

asterisk behind NAT
firwall set static port mapping to 192.168.255.161
port:5060 10000:20000

sip client call to asterisk ,sometimes send rtp to the 192.168.255.161,not send to 120.X.X.X
what issue?

if set:
localnet=192.168.255.161/255.255.255.255
externaddr = 120.X.X.X
nat = yes
directmedia=no
sometime there’s only one side rtp.

if set
media_address = 120.x.x.x
there’s RTP is one side too

Although many people don’t seem to have problems with this set wrongly, why do you have nat=yes? You don’t appear to have a configuration that needs it. Also the keyword “yes” is deprecated, here.

Also note that specifying a single address for localnet is non-standard, and is also redundant, as Asterisk can detect that the whole of that subnet is local, but I don’t think that is causing a problem.

I think I remember a recent bug report about Asterisk sometimes failing to send the correct media address, so I would try the very latest versions and also look for recent bug reports.

Otherwise, you need to capture the SIP packet in a case where Asterisk is sending incorrect SDP.

Thank you very much.
Is it the asterisk bug?

To find out if it is a bug, you need to either find the bug report on issues.asterisk.org/jira, or provide sip set debug on output, with all the addresses recognizable and the distinction between public and private addresses clear.

However, you should try the latest version before getting the traces.