This is a really common question and it’s been answered literally thousands of times.
It doesn’t sound like your firewall is set up correctly. If your server lives behind a NAT router, you will need to redirect the traffic from the public address to your PBX. If your PBX lives on the Internet, you probably need to remove the NAT = YES, setting.
When I set up my system I limit the number of RTP ports to about 2 per line and allow this range to come through your firewall.
Without a reasonable minimum of information, though, it’s really hard to say. Your version of Asterisk/FreePBX/CentOS/Windows/firewall/etc. would really be helpful for us to be able to answer your question.