Following code snippet from default kamailio.cfg never gives 403 if you smart enough to set "fromdomain" parameter on Asterisk to Kamailio's IP. How to fix it? I want password-based registration (which is OK now) and permit calls via Kamailio only from permitted IPs.
# if caller is not local subscriber, then check if it calls # a local destination, otherwise deny, not an open relay here if (from_uri!=myself && uri!=myself) { sl_send_reply("403","Not relaying"); exit; }