Claim your Biolink Click Here
0 like 0 dislike
5 views

Asterisk NAT Traversal and RTP Flow Handling

In our Asterisk setup, the server is deployed behind a NAT, and the clients (extensions/softphones) are on the public side or NATed networks. Since we do not want to require any client-side configuration (such as STUN, TURN, or ICE), we handle NAT traversal entirely on the server side within the Asterisk pjsip.conf endpoint configuration.

To ensure that media (RTP) flows through Asterisk — allowing us to monitor RTP streams in tools like sngrep — we set:



ini
direct_media=no

This forces Asterisk to remain in the media path. When direct_media is set to yes, the RTP stream bypasses Asterisk and flows directly between endpoints. While this allows proper voice communication, the RTP does not pass through Asterisk, hence it is not visible in sngrep or other monitoring tools running on the Asterisk server.

We also observed that without the following NAT-related settings, calls were getting disconnected after approximately 30 seconds. This was due to missing RTP and NAT traversal issues. Adding these settings resolved the disconnection issue:



ini
rtp_symmetric=yes rewrite_contact=yes force_rport=yes

These settings ensure that Asterisk correctly handles symmetric RTP, rewrites the contact IP to match the source IP of the request, and forces the use of the received port (instead of the one advertised by the client), effectively allowing proper NAT traversal and call stability.

in Computers & Internet by (4.7k points) | 5 views

Please log in or register to answer this question.

Related questions

2 like 0 dislike
2 answers
1 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
0 answers
asked Sep 19, 2017 in Education & Reference by Sam (1.6k points) | 269 views
2 like 0 dislike
1 answer
3 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
1 like 0 dislike
1 answer

Where your donation goes
Technology: We will utilize your donation for development, server maintenance and bandwidth management, etc for our site.

Employee and Projects: We have only 15 employees. They are involved in a wide sort of project works. Your valuable donation will definitely boost their work efficiency.

How can I earn points?
Awarded a Best Answer 10 points
Answer questions 10 points
Asking Question -20 points

1,318 questions
1,479 answers
569 comments
4,809 users