How to setup Asterisk Prefix Based dialing

Hello Guys,

I'm newbie in VOIP world and playing with Asterisk PBX.
I Have setup two Asterisk server (1.6.2) and configured SIP end points for both and connected each with other with IAX2 trunk

I'm successfully able to call between Asterisks with below dialplan, But I want to do prefix based dialing where in I just dial prefix number to reach extension of other asterisk and vice versa

Any help appreciated

Asterisk server 1 Dialplan (Extn 4XXX)

exten => 4000,1,Dial(SIP/4000)
exten => _1X.,1,Dial(IAX2/server2/${EXTEN})
exten => _4X.,1,Dial(SIP/${EXTEN},20,tr)

Asterisk server 1 Dialplan (Extn 1XXX)
include => parkedcalls

include => parkedcalls
exten => _1XXX,1,Dial(SIP/${EXTEN},10,tr)
exten => _1XXX,2, VoiceMail(${EXTEN}@voicemail_test,u,b)
exten => _1XXX,3,Playback(vm-goodbye)
exten => _1XXX,4,Hangup()
exten => 9998,1,VoiceMailMain(_1XXX@voicemail_test)

exten => _4X.,1,Dial(IAX2/server1/${EXTEN})

exten => _1X.,1,Dial(SIP/${EXTEN},20,tr)erisk server 1 Dialplan (Extn 4XXX)

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnanthahkAuthor Commented:
I was able to set up perfix based dialing by following code

exten => _801X.,1,Dial(IAX2/server2/${EXTEN:2})

exten => _811X.,1,Dial(IAX2/server1/${EXTEN:2})

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
IP Telephony

From novice to tech pro — start learning today.