Sunday, January 20, 2013

More PBX adventures

UPDATE: SIPStation must have made some more changes - trunk2 no longer works for incoming calls.  But trunk1 does. Caveat lector (the sip.conf below shows trunk2. At some point, that will probably be correct again...)

I've been using my Intel Atom computer for home phone PBX service for the last couple of weeks using Asterisk/FreePBX.

Several callers complained that incoming calls were either being dropped or "answered" with a fast-busy.  I verified that this was the case; calling in from work for a couple of days, I found that about 50% of the attempts to call home were successful. That's not good.  A service request to AXVoice got them to attempt to dial in.  Of course the few times they called, it worked...

So, I did some digging - using a different computer for the PBX, loading the PBX onto the Raspberry Pi, putting the PBX outside of the firewall/router, using a different router, changing NAT settings in the PBX, changing QOS settings in the router, turning on port forwarding, etc., etc.

Based on the log files and activity log at AXVoice, I concluded that AXVoice was just not connecting about half the time.  So I signed up with another SIP provider for a test.  For this test I used a SIPStation trunk and dialin line.  

I had played with an earlier version of Asterisk before (1.8) and got a couple of extensions and incoming/outgoing calling going on it.  This time, I loaded the latest version (11) and took it for a spin.  While I was at it I loaded a new version of Ubuntu server on the Intel Atom platform and used that.  During this testing, I moved the house phones back to our cable phone provider.

Turns out that SIPstation incoming calls worked just fine... 

But, wait: there's more.  

SIPStation only offers domestic calling. My AXVoice plan has unlimited calling to 40 countries, including Switzerland (where Cindy's mom lives.)  So, it looks like I'll just keep both services for now - at least until SIPStation offers international service, or until AXVoice fixes their problem.  Even paying for both of them is cheaper than our monthly bill used to be from Telecom*USA.  If it continues to work well, I'll drop the phone service I have with our cable company and port that number over to SIPStation.

If you're interested in the sip.conf and extensions.conf that make Asterisk go,  you'll find them below.  There are also some Netgear router settings that I needed to adjust (just ask...)

There must be thousands of Asterisk implementations in small business around the world - the interwebs are just brimming with information on configuring Asterisk.  Unfortunately, there are so many different versions and front-ends that much of it is a little misleading.  The best resource is O'Reilly's Asterisk, The Definitive Guide [ISBN: 978-0-596-51734-2] (an on-line version is available for free...)

It gets more interesting the further down the rabbit hole one goes!


[general]  ; because we're using dynamic dns
localnet= ; used for NAT traversal (necessary?)
externrefresh=60                   ; how often to recheck the external IP

context=unauthenticated            ; default context for incoming calls
allowguest=no                      ; disable unauthenticated calls
srvlookup=yes                      ; DNS SRV lookup - mostly for external SIP
udpbindaddr=                ; listen for UDP requests on all interfaces
tcpenable=no                       ; disable TCP support

register => [username]:[password] ; trunk1 doesn't work...

[office-phone](!)                  ; create a template for our devices
type=friend                        ; channel driver matches username then IP
context=phones                     ; calls from the device enter the dialplan here
host=dynamic                       ; the device will register with asterisk
nat=no                             ; the office phones are on the same net as PBX 
secret=[phone password]            ; a secure password for this device
dtmfmode=auto                      ; accept touch-tones from the devices
disallow=all                       ; disallow codecs except those allowed below
allow=ulaw                         ; which audio codecs to allow...
allow=alaw                         ; the order we prefer

[201](office-phone)                ; set up phones using the "macro" above

[sstn]                             ; set up SIPStation trunk, used for incoming calls
type = peer
host =       ; only trunk2 appears to work...
username = [username]
context = incoming_calls           ; where incoming calls go
secret = [password]
insecure = invite,port             ; apparently "very" is deprecated
dtmfmode = rfc2833
disallow = all
allow = ulaw
allow = alaw
nat=no                             ; this appears to work, though we use NAT...
canreinvite=no                     ; ... took a lot of time to figure this out.

[AXVoice]                          ; set up AXVoice trunk, (used for unlimited outgoing calls)
type = peer
host =
username = [username]
secret = [password]
insecure = invite,port 
dtmfmode = rfc2833
disallow = all
allow = ulaw
allow = alaw

exten => _X.,1,Dial(SIP/201&SIP/204&SIP/205)   ; a cheap ring group...

exten => _011.,1,Set(CALLERID(all)="Amos"<[my phone number]>)
same => n,Dial(SIP/AXVoice/${EXTEN})
same => n,Hangup()

exten => _1NXXNXXXXXX,1,Set(CALLERID(all)="Amos"<[my phone number]>)
same => n,Dial(SIP/AXVoice/${EXTEN})
same => n,Hangup()

exten => _911.,1,Set(CALLERID(all)="Amos"<[my phone number]>)
same => n,Dial(SIP/AXVoice/${EXTEN})
same => n,Hangup()

exten => _NXXNXXXXXX,1,Set(CALLERID(all)="Amos"<[my phone number]>)
same => n,Dial(SIP/AXVoice/${EXTEN})
same => n,Hangup()

exten => 201,1,Verbose(1,Extension 201)       ; just puts something in the log 
exten => 201,n,Dial(SIP/201,30)
exten => 201,n,Hangup()

exten => 204,1,Verbose(1,Extension 204)
exten => 204,n,Dial(SIP/204,30)
exten => 204,n,Hangup()

exten => 205,1,Verbose(1,Extension 205)
exten => 205,n,Dial(SIP/205,30)
exten => 205,n,Hangup()

include => internal
include => outgoing_calls

No comments:

Post a Comment