{"id":859,"date":"2016-10-22T13:29:04","date_gmt":"2016-10-22T12:29:04","guid":{"rendered":"http:\/\/cyber-cottage.co.uk\/en\/?p=859"},"modified":"2016-10-23T00:14:28","modified_gmt":"2016-10-22T23:14:28","slug":"catching-the-ip-of-anonymous-callers-on-asterisk-servers","status":"publish","type":"post","link":"https:\/\/www.cyber-cottage.co.uk\/?p=859","title":{"rendered":"Catching the IP of anonymous callers on Asterisk servers"},"content":{"rendered":"<p>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.<\/p>\n<p>Normally I would say lock your firewall to only known IPs, but in some cases this isn&#8217;t possible<\/p>\n<p>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<\/p>\n<p>In extensions_custom.conf add the dialplan below<\/p>\n<dl>\n<dd style=\"padding-left: 60px;\">\n<pre class=\"p1\"><span class=\"s1\">[catchall]<\/span>\r\n<span class=\"s1\">exten =&gt; s,1,Noop(Dead calls rising)<\/span>\r\n<span class=\"s1\">exten =&gt; s,n,Set(uri=${SIPCHANINFO(uri)})<\/span>\r\n<span class=\"s1\">exten =&gt; s,n,Verbose(3,Unknown call from ${uri} to ${EXTEN})<\/span>\r\n<span class=\"s1\">exten =&gt; s,n,System(echo \"[${STRFTIME(${EPOCH},,%b %d %H:%M:%S)}] SECURITY[] Unknown Call from ${CALLERIDNUM} to ${FROM_DID} IPdetails ${uri}\" &gt;&gt; \/var\/log\/asterisk\/sipsec.log)<\/span>\r\n<span class=\"s1\">exten =&gt; s,n,Hangup()<\/span><\/pre>\n<\/dd>\n<\/dl>\n<p>Then in\u00a0Custom Destinations add a destination as \u00a0<b>catchall,s,1<\/b><\/p>\n<p>so you now get in your logs<\/p>\n<p style=\"padding-left: 90px;\"><span style=\"color: #0000ff;\"><code>[May 1 00:11:06] SECURITY[] Unknown Call from\u00a0 to<a><span style=\"color: #0000ff;\">\u00a0900441516014<\/span><\/a>742 IPdetails sip:101@37.75.209.113:21896<\/code><\/span><\/p>\n<dl>\u00a0I hope this is some help to you, It allows other scripts to pick up this address and add it to your firewall.<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t possible Im sure if you have a Asterisk [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[88,11,82],"tags":[23,33,35,40,51,68,73,100,76,77],"class_list":["post-859","post","type-post","status-publish","format-standard","hentry","category-astsupport","category-knowledge","category-security-knowledge","tag-asterisk","tag-digium","tag-elastix","tag-freepbx","tag-linux","tag-security","tag-support","tag-technical","tag-voip","tag-xorcom"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p5daZy-dR","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=859"}],"version-history":[{"count":3,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/859\/revisions"}],"predecessor-version":[{"id":1747,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/859\/revisions\/1747"}],"wp:attachment":[{"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cyber-cottage.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}