If you’re running Asterisk on a VPS or a dedicated server then setting up your iptables firewall can be a tricky.
I thought I’d post my firewall script to help get you started. I save this script as /usr/local/bin/firewall.sh and then add a line to run it from /etc/rc.local
It allows SSH’ing to the machine plus rules required for SIP connections (you will need other rules if you use IAX) plus some basic “bad stuff” filtering.
I’ve commented it so, hopefully, you’ll be able to figure out and chages you need.