{"id":726,"date":"2014-06-27T14:32:29","date_gmt":"2014-06-27T08:32:29","guid":{"rendered":"http:\/\/alexeyka.zantsev.com\/?p=726"},"modified":"2025-05-13T14:25:03","modified_gmt":"2025-05-13T09:25:03","slug":"brute-your-trunks-dial-out","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=726","title":{"rendered":"Brute your trunks, dial out"},"content":{"rendered":"<p>A small snippet of dialplan how to dial if some trunk is not reachable.<\/p>\n<p>Imagine, we have two SIP-trunks to dial out &#8211; [trunk1] and [trunk2]. You have to set &#8216;qualify=yes&#8217; for both, otherwise this method will not work.<br \/>\nWe&#8217;ll use the <a href=\"https:\/\/docs.asterisk.org\/Certified-Asterisk_20.7_Documentation\/API_Documentation\/Dialplan_Functions\/SIPPEER\/\" target=\"_blank\" rel=\"noopener\">SIPPEER<\/a> function with the &#8216;status&#8217; argument:<\/p>\n<pre>; Func SIPPEER\nexten =&gt; 401040,NoOp\n    same =&gt; n,NoOp( [trunk1] SIPPEER info: ${SIPPEER(trunk1,status)})\n    same =&gt; n,NoOp( ;===================================== )\n    same =&gt; n,NoOp( [trunk2] SIPPEER info: ${SIPPEER(trunk2,status)})\n    same =&gt; n,NoOp( ;===================================== )\n    same =&gt; n,GotoIf($[${SIPPEER(trunk1,status)}= \"OK\"]?t1dial:t2)\n    same =&gt; n(t1dial),Dial(SIP\/trunk1\/${EXTEN},5)\n    same =&gt; n,Hangup\n    same =&gt; n(t2),NoOp( [trunk1] is UNREACHABLE, trying [trunk2] in 1 second ... )\n    same =&gt; n,Wait(1)\n    same =&gt; n,GotoIf($[${SIPPEER(trunk2,status)}= \"OK\"]?t2dial:hang)\n    same =&gt; n(t2dial),Dial(SIP\/trunk2\/${EXTEN},5)\n    same =&gt; n,Hangup\n    same =&gt; n(hang),Playback(have-a-rest)\n    same =&gt; n,Hangup\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A small snippet of dialplan how to dial if some trunk is not reachable. Imagine, we have two SIP-trunks to dial out &#8211; [trunk1] and [trunk2]. You have to set &#8216;qualify=yes&#8217; for both, otherwise this method will not work. We&#8217;ll use the SIPPEER function with the &#8216;status&#8217; argument: ; Func SIPPEER exten =&gt; 401040,NoOp same [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[43,190,191],"class_list":["post-726","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-asterisk","tag-sippeer","tag-trunk"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=726"}],"version-history":[{"count":5,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/726\/revisions"}],"predecessor-version":[{"id":12565,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/726\/revisions\/12565"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}