My most recent project has been to set up a VOIP setup on my Droid so that I can VPN into my home network using either my 3G service or WiFi and use the unused landline that I have so that I don’t burn minutes. As a secondary objective, I’d also like to be able to have calls made to my house ring on my cell phone after a few rings on my house phone.
In order to accomplish this task, I needed 2 things:
A means to connect my landline to my Asterisk server
An old machine to run Asterisk on
The old machine was easy. I have an old Compaq that has been sitting idle since the early 2006 or 2007. It had Ubuntu Dapper Drake. Although I would have liked to have put something newer, it appears that most newer distributions don’t agree with the hardware, and I really don’t have time to mess around with passing in various kernel parameters in a trial and error manner since the error messages were non-existent. Since this was the case, I enabled the universe repository under /etc/apt/sources.list, and ran the following command to get Asterisk running:
apt-get –f install asterisk
I didn’t change any of the configuration files, I want to keep them stock since I will use a special configuration wizard.
Now, the hardware I used to connect the phone was a Linksys 3102 ATA. I also did not do anything in configuration outside of enabling configuration through the outside WAN since this is only connected to my Intranet.
Configuration, despite how confusing all this looked initially, turned out to be a piece of cake, thanks to this handy dandy configuration utility, courtesy of the nice folks at Voxilla. I simply followed the wizard, which automatically configured the 3102 to work with Asterisk. To configure Asterisk, I made a backup of the sip.conf, voicemail.conf, and extensions.conf, removed them, and copy and pasted in the appropriate configuration sections from the wizard into the appropriate files. So, to do that, it looked something like:
root@cloya-desktop:/etc/asterisk# mkdir backup
root@cloya-desktop:/etc/asterisk# cp sip.conf backup/
root@cloya-desktop:/etc/asterisk# cp extensions.conf backup/
root@cloya-desktop:/etc/asterisk# cp voicemail.conf backup/
root@cloya-desktop:/etc/asterisk# rm sip.conf
root@cloya-desktop:/etc/asterisk# nano sip.conf
root@cloya-desktop:/etc/asterisk# rm voicemail.conf
root@cloya-desktop:/etc/asterisk# nano voicemail.conf
root@cloya-desktop:/etc/asterisk# rm extensions.conf
root@cloya-desktop:/etc/asterisk# nano extensions.conf
root@cloya-desktop:/etc/asterisk# cat sip.conf
[digiassn]
type=friend
host=dynamic
context=home
secret=secretPassword
mailbox=digiassn
dtmfmode=rfc2833
disallow=all
allow=ulaw
[pstn]
; If you're using Asterisk, this goes into the Incoming settings
; For your Trunk
type=friend
host=dynamic
; If using Asterisk@home, change the below line to context=from-internal
context=home
secret= secretPassword
dtmfmode=rfc2833
disallow=all
allow=ulaw
insecure=very
[pstn-spa3k]
; If you're using Asterisk, this section goes into the Outgoing Settings
; for your trunk.
type=peer
auth=md5
host=192.168.1.110
port=5061
secret= secretPassword
username=asterisk
fromuser=asterisk
dtmfmode=rfc2833
; If using Asterisk@home, change the below line to context=from-internal
context=home
insecure=very
root@cloya-desktop:/etc/asterisk# cat voicemail.conf
[default]
digiassn => digiassn,John Ward,user.com,user-pager.com,tz=pacific
root@cloya-desktop:/etc/asterisk# cat extensions.conf
[home]
exten => digiassn,1,Ringing
exten => digiassn,2,Dial(SIP/digiassn,20,T)
exten => digiassn,3,Voicemail(udigiassn)
exten => digiassn,4,Hangup
exten => 911,1,Dial(SIP/911@pstn-spa3k,60,)
exten => 911,2,Congestion
exten => _XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _XXXXXXX,2,Congestion
exten => _1800XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1800XXXXXXX,2,Congestion
exten => _1888XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1888XXXXXXX,2,Congestion
exten => _1877XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1877XXXXXXX,2,Congestion
exten => _1866XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1866XXXXXXX,2,Congestion
Then, I need to edit the /etc/default/asterisk file to change the line that says
RUNASTERISK=no
to say
RUNASTERISK=yes
Now, before I actually start this up, I needed to make one final change. When I actually started this up and played with it, the dial in from my land line did not ring the VOIP setup on my Droid the way I wanted. The reason is the extension.conf file was not set up correctly from the script. The way it works by default is that any calls coming in the digiassn extension would ring the digiassn extension for 20 seconds then go to voice mail. This is not what I want. I want calls coming in the pstn extension to ring the pstn extension for 20 seconds (which would be the physical home phone line), then ring my VOIP setup on my cell (digiassn) for 10 seconds, then go to voicemail. Most normal configurations won’t require this, but I included it here to show my final configuration. First, go into the SPA configuration utility, and under Voice/Line 1/Proxy and Registration, change the value of Use Outbound Proxy to true. I don’t know why, but the handset wouldn’t ring without this set. Then change the below configuration for extensions.conf:
[home]
exten => pstn,1,Ringing
exten => pstn,2,Dial(SIP/digiassn,20,T) #ring the handset first
exten => pstn,3,Dial(SIP/pstn,15,T) #then ring the SIPDroid
exten => pstn,4,Voicemail(udigiassn)
exten => pstn,5,Hangup
exten => 911,1,Dial(SIP/911@pstn-spa3k,60,)
exten => 911,2,Congestion
exten => _XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _XXXXXXX,2,Congestion
exten => _1800XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1800XXXXXXX,2,Congestion
exten => _1888XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1888XXXXXXX,2,Congestion
exten => _1877XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1877XXXXXXX,2,Congestion
exten => _1866XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1866XXXXXXX,2,Congestion
Now, I can start up Asterisk by running /etc/init.d/asterisk restart.
Now, I need a VOIP client. I am using SIPDroid to make my connections. To do this, I configure SIPDroid as follows:
Under SIP Account Settings:
Authorization Username: pstn
Password:
Server: 192.168.1.111 (The address of the Asterix box).
Port: 5060
Protocol: UDP
Everything else I leave default. That’s it. When I’m connected to my WiFi network, I can use the VoIP setup to connect directly to my landline.
So, after using this for a day, there were some definite things I wanted to change. The dial plan that is on by default sucked. Since I am using Android and SIPVoice to dial, and by default SIPDroid uses the full number mask stored in contacts (XXX-XXX-XXXX), Asterisk refused to dial. I would see SIPDroid try to dial but hang up immediately without completing the call. Took me a while to figure out what was going on, so some new dial masks needed to be created. Voicemail was not set up correctly. Since I don’t have an answering machine on my landline, I figured Asterisk can play double duty and serve as an answering machine as well. The wizard doesn’t create a workable voicemail password, so that needed to be fixed. Also, after some investigation, it turns out that Asterisk also has a little feature that works just like the Telezapper, and will play the “out of service” tone when you answer a phone so telemarketers and such will register you in the Do Not Call database. This is a feature that I need to have since the National Do Not Call database is such a joke. There are also all sorts of neat scripts you can run to forward telemarketers to annoying endless voice prompt loops, or just hang up on them, but I won’t cover them here.
So, to accomplish what I wanted, I modified all three configuration files like so.
Voicemail.conf:
[default]
digiassn => 1234,John Ward,john@email,tz=pacific
Note the 1234. This is the 4 digit numeric password you need to enter to check and manage your voicemailbox.
Extensions.conf:
[home]
exten => pstn,1,Ringing
#add zapateller
exten => pstn,2,Zapateller(answer)
exten => pstn,3,Dial(SIP/digiassn,15,T)
exten => pstn,4,Dial(SIP/pstn,10,T)
exten => pstn,5,Voicemail(udigiassn)
exten => pstn,6,Hangup
exten => 911,1,Dial(SIP/911@pstn-spa3k,60,)
exten => 911,2,Congestion
#dialing 9999 will get me my voicemail box
exten => 9999,1,VoiceMailMain(digiassn)
#dialmasks, local calls
exten => _XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _XXXXXXX,2,Congestion
#if coming from cell phone, only take the phone number, minus the 1 and the area code
exten => _1210XXXXXXX,1,Dial(SIP/${EXTEN:-7}@pstn-spa3k,60,)
exten => _1210XXXXXXX,2,Congestion
#same as above, only without the 1. this is for local calls
exten => _210XXXXXXX,1,Dial(SIP/${EXTEN:-7}@pstn-spa3k,60,)
exten => _210XXXXXXX,2,Congestion
#Any other number, with the 1
exten => _1XXXXXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1XXXXXXXXXX,2,Congestion
#without the 1
exten => _XXXXXXXXXX,1,Dial(SIP/1${EXTEN}@pstn-spa3k,60,)
exten => _XXXXXXXXXX,2,Congestion
#dont believe the rest need to be here, but I will leave them jic
exten => _1800XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1800XXXXXXX,2,Congestion
exten => _1888XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1888XXXXXXX,2,Congestion
exten => _1877XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1877XXXXXXX,2,Congestion
exten => _1866XXXXXXX,1,Dial(SIP/${EXTEN}@pstn-spa3k,60,)
exten => _1866XXXXXXX,2,Congestion
2 comments:
This post seems so geeky but still this is one of my jobs.. To learn about technology, setting it up and all.. i a geek because i am a programmer.
Thanks for this tech support.
Post a Comment