There are two protocols in Asterisk that can accomplish this. We've already encountered SIP so we'll stay with that for now. We'll talk about IAX2 in a later post.
In order for our test you might want to get a Free World Dialup account. If you have a FWD account great, if not you have to sign up and give some personal information (like your snail mail address). I guess nothing is free, but they have to eat too. The process is fairly straightforward. Pop over there and grab yourself an account.
Step 1
As always backup your files:
# cd /opt/etc/asterisk
# cp -p users.conf users.conf.hold
# cp -p sip.conf sip.conf.hold
# cp -p extensions.conf extensions.conf.hold
We are going to have to cut a paste a macro from extensions.conf.org into our hacked extensions.conf (you did make a backup right!?!). Take a look at the original extensons.conf file and find the macro:
[macro-trunkdial]
;
; Standard trunk dial macro (hangs up on a dialstatus that should
; terminate call)
; ${ARG1} - What to dial
;
exten => s,1,Dial(${ARG1})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Hangup
exten => _s-.,1,NoOp
Copy and paste this into your working extensions.conf file.
Step 2
Fire up the GUI:
http://IP.ADDRESS.OF.ASTERISK:8088/asterisk/static/config/cfgbasic.html
Step 3
Click on Service Providers, Add Service Provider, and select Custom VoIP under Provider Type. Fill in the fields selecting:
Comment FWD_SIP
SIP as the protocol
Check Register
Host fwd.pulver.com
Username: Your 6 digit FWD number
Password: Your FWD password
Click Save and Activate Changes. Your users.conf file will be appended like this:
[trunk_1]
allow = all
context = DID_trunk_1
dialformat = ${EXTEN:1}
hasexten = no
hasiax = no
hassip = yes
host = fwd.pulver.com
port = 5060
registeriax = no
registersip = yes
secret = XXXXXX
trunkname = Custom - FWD_SIP
trunkstyle = customvoip
username = XXXXXX
Where XXXXXX are your 6 digit FWD account number and password.
Step 4
Click on Calling Rules.
You'll see that a "A default DialPlan is not found !!"
Click on "click here to create a default DialPlan."
Click on Add a Calling Rule
and fill in the fileds like this:
Rule Name: FWD_SIP_Rule
Place this call through: Custom - FWD_SIP
Dialing Rules : If the number begins with 8
followed by 3 digits x or more
Strip 01 digits from the front and prepend 0 before dialing
This allows us to dial the FWD number by pressing 8 on our SIP phone.
Click on Save and Activate Changes.
If you look at extensions.conf you'll see that the GUI added the following:
trunk_1 = SIP/trunk_1
and at the bottom:
[DID_trunk_1]
include = default
[numberplan-custom-1]
include = default
plancomment = FWD
parked = no
exten = _8XXX!,1,Macro(trunkdial,${trunk_1}/${EXTEN:01})
comment = _8XXX!,1,FWD_SIP_RULE,standard
The GUI also adds an inbound context:
[DID_trunk_1]
You can configure this under Incoming Calls in the GUI. We'll put aside that step for now.
Step 5
Now take the context
[numberplan-custom-1]and include it in
[default]
include => numberplan-custom-1
This will enable Asterisk to understand that when you dial 8 it will pull your SIP trunk and send the calls to FWD.
Step 6 (For NAT'd Networks)
In order for this to work behind a NAT'd firewall you must add the following to the users.conf entry for
[trunk_1]
canreinvite = no
This allows Asterisk to pass all the voice data (RTP media stream) through the Asterisk server rather than directly between calling stations. It's necessary to avoid NAT issues.
You must also edit sip.conf and configure the NAT section. Edit the externip, externhost (one or the other) and localnet settings and add the values that correspond to your network. The final thing is to forward the appropriate ports to you Asterisk box. 5084 seems to be specific to FWD:
5060 For SIP both UDP and TCP
5084 For SIP both UDP and TCP
10000-20000 For RTP UDP
That's it. Configure a softphone with your FWD account information. Pick up your regular SIP phone (or another softphone that terminates on your Asterisk server) and dial 8 plus your FWD number. Your softphone should ring! Dial 8613 and check out the echo test form your Asterisk terminated SIP phone. If you have access to a computer outside your network you can do further tests to see how well this works. The acid test is phoning 8613 from your Asterisk terminated SIP phone. If you get the echo test to work you should be good to go.
I've tidied up extensions.conf a bit so here's the complete file as it stands at this point:
;!
;! Automatically generated configuration file
;! Filename: extensions.conf (/opt/etc/asterisk/extensions.conf)
;! Generator: Manager
;! Creation Date: Mon Dec 24 21:02:51 2007
;!
[general]
;
; If static is set to no, or omitted, then the pbx_config will rewrite
; this file when extensions are modified. Remember that all comments
; made in the file will be lost when that happens.
;
; XXX Not yet implemented XXX
;
static = yes
;
;
; if stati=yes and writeprotect=no, you can save dialplan by
; CLI command 'save dialplan' too
;
writeprotect = yes
[globals]
PHONE1 = SIP/2203
; These variables are to avoid the irritating problem
; with inability to use regexp's on strings that have
; not been defined.
;
CALLFILENAME = foo
FOO = foo
trunk_1 = SIP/trunk_1
[macro-trunkdial]
;
; Standard trunk dial macro (hangs up on a dialstatus that should
; terminate call)
; ${ARG1} - What to dial
;
exten => s,1,Dial(${ARG1})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s-NOANSWER,1,Hangup
exten => s-BUSY,1,Hangup
exten => _s-.,1,NoOp
[macro-stdexten];
;
; Standard extension macro:
; ${ARG1} - Extension (we could have used ${MACRO_EXTEN} here as well
; ${ARG2} - Device(s) to ring
;
exten => s,1,Dial(${ARG2},20) ; Ring the interface, 20 seconds maximum
exten => s,2,Goto(s-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHAN
exten => s-NOANSWER,1,Voicemail(${ARG1},u) ; If unavailable, send to voicemail
exten => s-BUSY,2,Goto(default,s,1) ; If they press #, return to start
exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer
exten => a,1,VoicemailMain(${ARG1}) ; If they press *, send the user in
[macro-failann]
; Failure announcement playback macro:
; ${ARG1} - Status of the call, one of:
; (CHANUNAVAIL | CONGESTION | BUSY | NOANSWER |
; ANSWER | CANCEL | DONTCALL | TORTURE)
;
exten => s,1,Goto(s-${ARG1},1)
exten => s-CHANUNAVAIL,1,Playback(all-circuits-busy-now)
exten => s-CHANUNAVAIL,2,Playback(pls-try-call-later)
exten => s-CHANUNAVAIL,3,Hangup
exten => s-CONGESTION,1,Playback(cannot-complete-temp-error)
exten => s-CONGESTION,2,Playback(pls-try-call-later)
exten => s-BUSY,1,Playback(the-party-you-are-calling)
exten => s-BUSY,2,Playback(is-curntly-busy)
exten => s-BUSY,3,Hangup
exten => s-NOANSWER,1,Playback(the-party-you-are-calling)
exten => s-NOANSWER,2,Playback(is-curntly-unavail)
exten => s-NOANSWER,3,Hangup
exten => s-ANSWER,1,Hangup
exten => _s-.,1,Playback(cannot-complete-network-error)
exten => _s-.,2,Playback(pls-try-call-later)
exten => _s-.,3,Hangup
[pstn-outgoing]
exten => 911,1,Dial(SIP/${EXTEN}@LinksysFXO,,T)
exten => 911,2,Macro(failann,${DIALSTATUS})
exten => _604NXXXXXX,1,Dial(SIP/${EXTEN}@LinksysFXO,60,T)
exten => _604NXXXXXX,2,Macro(failann,${DIALSTATUS})
exten => _778NXXXXXX,1,Dial(SIP/${EXTEN}@LinksysFXO,60,T)
exten => _778NXXXXXX,2,Macro(failann,${DIALSTATUS})
exten => _18XXNXXXXXX,1,Dial(SIP/${EXTEN}@LinksysFXO,60,T)
exten => _18XXNXXXXXX,2,Macro(failann,${DIALSTATUS})
[answer]
exten => s,1,Wait(1) ; Wait a second, just for fun
exten => s,n,NoOp(CURRENT CALLER ID= ${CALLERID(num)})
exten => s,n,Answer ; Answer the line
[dial]
exten => s,n,Macro(stdexten,6002,SIP/6002)
exten => 6000,1,VoiceMailMain
[default]
include => answer
include = dial
include => pstn-outgoing
include => numberplan-custom-1
[asterisk_guitools]
exten = executecommand,1,System(${command})
exten = executecommand,n,Hangup()
exten = record_vmenu,1,Answer
exten = record_vmenu,n,Playback(vm-intro)
exten = record_vmenu,n,Record(${var1})
exten = record_vmenu,n,Playback(vm-saved)
exten = record_vmenu,n,Playback(vm-goodbye)
exten = record_vmenu,n,Hangup
exten = play_file,1,Answer
exten = play_file,n,Playback(${var1})
exten = play_file,n,Hangup
hasbeensetup = Y
[DID_trunk_1]
include = default
[numberplan-custom-1]
plancomment = DialPlan1
include = default
include = parkedcalls
exten = _8XXX!,1,Macro(trunkdial,${trunk_1}/${EXTEN:1})
comment = _8XXX!,1,FWD_SIP_Rule,standard
3 comments:
I was able to ring FWD ext.'s but could not get any back-and-forth voice comm. It seems to be a NAT issue, I am new to asterik and linux and am learning as I go along. Any help would be appreciated. Thanks, again.
Happy New Year!
Try the following:
1)Make sure RTP ports 10000-20000 are port forwarded to the IP of your Asterisk server. See if that works.
2) Try setting a STUN server in the SIP phone you are using. A STUN server will help Asterisk traverse the firewall. stunserver.org is a public STUN server.
3) Toggle the phone's NAT setting using the GUI or by editing users.conf.
4) Make sure you have the correct settings in sip.conf. Likely that's OK as the phone is being signaled properly.
I struggled with this a while too. Eventually I got it working ... you will too!
I'm really enjoying the theme/design of your site.
Post a Comment