Hi just sharing a simple bit of dialplan to catch anon callers ip addresses when using freepbx and Anonymous callers is set to yes, which is needed for some suppliers.
Normally I would say lock your firewall to only known IPs, but in some cases this isn’t possible
Im sure if you have a Asterisk server with a public IP you will have seen calls on the console screen where the call is to a destination but the callers are exten@yourserver . Well this little bit of dialplan at the end of you default sip context should catch them and log them with the ip of the originating server
In extensions_custom.conf add the dialplan below
-
[catchall] exten => s,1,Noop(Dead calls rising) exten => s,n,Set(uri=${SIPCHANINFO(uri)}) exten => s,n,Verbose(3,Unknown call from ${uri} to ${EXTEN}) exten => s,n,System(echo "[${STRFTIME(${EPOCH},,%b %d %H:%M:%S)}] SECURITY[] Unknown Call from ${CALLERIDNUM} to ${FROM_DID} IPdetails ${uri}" >> /var/log/asterisk/sipsec.log) exten => s,n,Hangup()
Then in Custom Destinations add a destination as catchall,s,1
so you now get in your logs
[May 1 00:11:06] SECURITY[] Unknown Call from to 900441516014742 IPdetails sip:101@37.75.209.113:21896
- I hope this is some help to you, It allows other scripts to pick up this address and add it to your firewall.