<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ahmed El Gamil &#187; Zap</title>
	<atom:link href="http://www.blog.manhag.org/tag/zap/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.manhag.org</link>
	<description></description>
	<lastBuildDate>Thu, 09 Sep 2010 10:54:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<image>
<link>http://www.blog.manhag.org</link>
<url>http://www.blog.manhag.org/wp-content/mbp-favicon/favicon.ico</url>
<title>Ahmed El Gamil</title>
</image>
	<atom:link rel='hub' href='http://www.blog.manhag.org/?pushpress=hub'/>
		<item>
		<title>Routing calls from Zap Trunks to SIP trunks in Asterisk</title>
		<link>http://www.blog.manhag.org/2010/03/routing-calls-from-zap-trunks-to-sip-trunks-in-asterisk/</link>
		<comments>http://www.blog.manhag.org/2010/03/routing-calls-from-zap-trunks-to-sip-trunks-in-asterisk/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 12:35:40 +0000</pubDate>
		<dc:creator>Ahmed El Gamil</dc:creator>
				<category><![CDATA[Asterisk/VoIP]]></category>
		<category><![CDATA[Open Source Technologies]]></category>
		<category><![CDATA[UNIX/Linux]]></category>
		<category><![CDATA[Asterisk]]></category>
		<category><![CDATA[FreePBX]]></category>
		<category><![CDATA[LinkedIn]]></category>
		<category><![CDATA[SIP]]></category>
		<category><![CDATA[Zap]]></category>

		<guid isPermaLink="false">http://www.blog.manhag.org/?p=429</guid>
		<description><![CDATA[So i had this situation where i have 2 Asterisk boxes, the 1st one of them had a PRI card and the 2nd one is just attached to the network through an ethernet card Goal: redirect all of the incoming calls on the PRI to the 2nd Asterisk box through a SIP Trunk (The 2nd [...]]]></description>
			<content:encoded><![CDATA[<p>So i had this situation where i have 2 Asterisk boxes, the 1st one of them had a PRI card and the 2nd one is just attached to the network through an ethernet card</p>
<p><strong><span style="text-decoration: underline;">Goal:</span></strong> redirect all of the incoming calls on the PRI to the 2nd Asterisk box through a SIP Trunk (The 2nd box holds the IVR and all of those stuff, all of the IP phones are connecting to this one), There was no decent documentation about this out there so i am documenting this and may be someone will find it useful.</p>
<p>Here is what you should do (I am assuming you are using an Asterisk installation that uses FreePBX):</p>
<ul>
<li>Create the Zap Trunk as you normally do from the FreePBX interface: Trunks -&gt; Add Zap Trunk</li>
<li>Create a SIP trunk that points to the 2nd Asterisk box, we will use this Trunk later in the configuration: Trunks -&gt; Add SIP Trunk, scroll down to outgoing settings and add the following
<ul>
<li>Trunk name: to-2ndAsterisk</li>
<li>Peer details:</li>
</ul>
</li>
</ul>
<blockquote><p>type=peer</p>
<p>host=&lt;IP Address of 2nd Asterisk Box&gt;</p></blockquote>
<ul>
<li>Connect to the 1st Asterisk box using SSH and edit the file /etc/asterisk/dahdi-channels.conf, you will find some configuration like</li>
</ul>
<blockquote>
<div id="_mcePaste">group=0,11</div>
<div id="_mcePaste"><strong>context=from-pstn</strong></div>
<div id="_mcePaste">switchtype = euroisdn</div>
<div id="_mcePaste">signalling = pri_cpe</div>
<div id="_mcePaste">channel =&gt; 1-15,17-31</div>
<div id="_mcePaste">context = default</div>
<div id="_mcePaste">group = 63</div>
</blockquote>
<ul>
<li>So as you can see all of the incoming calls are directed to the from-pstn context, we will now edit this line to direct the calls to the from-pstn-custom context and do the rest of the magic in this context so the file should be as follows</li>
</ul>
<blockquote>
<div id="_mcePaste">group=0,11</div>
<div id="_mcePaste"><strong>context=from-pstn-custom</strong></div>
<div id="_mcePaste">switchtype = euroisdn</div>
<div id="_mcePaste">signalling = pri_cpe</div>
<div id="_mcePaste">channel =&gt; 1-15,17-31</div>
<div id="_mcePaste">context = default</div>
<div id="_mcePaste">group = 63</div>
</blockquote>
<ul>
<li>Now edit the file /etc/asterisk/extensions_custom.conf and add the following at the end of the file</li>
</ul>
<blockquote><p>[from-pstn-custom]<br />
exten =&gt; _.,1,Dial(SIP/to-2ndAsterisk/${EXTEN:2},20,rt)</p></blockquote>
<p>So what this does is that it matches all of the calls (_.) then redirect them through the SIP trunk to the 2nd Asterisk box</p>
<ul>
<li>And the last step is to allow calls coming from the 1st Box to the 2nd Box, you should do IP-based authentication on the 2nd box by editing /etc/asterisk/sip_custom.conf and add the following</li>
</ul>
<blockquote><p>[1stAsterisk]<br />
type=peer<br />
canreinvite=no<br />
host=&lt;IP Address of 1st Asterisk Box&gt;<br />
context=from-pstn<br />
nat=no<br />
dtmfmode=rfc2833<br />
disallow=all<br />
allow=ulaw<br />
insecure=port<br />
qualify=yes</p></blockquote>
<p>Of course you can now create any inbound routes on the 2nd Asterisk Box to match your needs.</p>
<p>I hope this works for you, and if you need any assistance please don&#8217;t hesitate to ask me in the comments</p>
<p>Thanks for listening <img src='http://www.blog.manhag.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.manhag.org/2010/03/routing-calls-from-zap-trunks-to-sip-trunks-in-asterisk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
