Saturday, January 22, 2011

Utilizing Home VoIP Server from Remote (over internet)

Background
Once I had a chat with a colleague and he came up with this question, "How could I use my home's PSTN or VoIP line from a remote location?" For example, he were working overseas and wishes to contact his family at home (without using his company's mobile or the customer's phone), or the other way around. The most obvious answer would be to setup a SIP client on his laptop to register with a VoIP server located at home. 
To make it more interesting, the SIP client on his laptop would also be able to use his home's Asterisk server to dial out phone calls as well as receive them (virtual "call-forwarding", if you like).


First let's cover the easy part, setting up Asterisk server at his home to accept public client registration. This includes two basic operations: Registering the server's dynamic address using DynDNS and listening on port 5060 (UDP). Note: please take a look at a previous blog on setting up Asterisk on BSD to register with a public SIP server (and be assigned a public PSTN number):

Configuration 
Firstly on the home's Asterisk server, setup a new SIP account by configuring the "sip.conf" file:
;XLite over Internet - Remote VoIP testing
[user-name]
type=friend
secret=secret
host=dynamic                   ; This device needs to register
nat=yes                        ; X-Lite is behind a NAT router
disallow=all
allow=ulaw
allow=alaw

Also, set Asterisk to listen on all interfaces, including internet-facing ones.
bindport=5060                   ; UDP Port to bind to (SIP standard port is 5060)
                                ; bindport is the local UDP port that Asterisk will listen on
bindaddr=0.0.0.0
On a personal note, I would prefer Asterisk to support the configuration option of setting "bindaddr" to a particular interface (e.g. em0) allowing for more user control. 

Add an extension for this SIP client locally by configuring the "extensions.conf" file:
[outbound-local]
exten => 12345678,1,Dial(SIP/user-name)

In this example, the extension given to SIP client is 12345678. "outbound-local" is binded to the locally attached PSTN phone, remember to include this under "default" context.
  
DynDNS - Remote Access over Internet
DynDNS (http://www.dyndns.com/) provides free reverse DNS service. The idea behind this service is that, you can basically access your home computer via the internet, by typing a domain name of your choice. Diving into more details... a dyndns client is installed on your home computer. Whenever the home computer receives a public ip address, it registers with its allocated URL on the DynDNS server. The DynDNS server then updates the DNS record and make it publicly available. So, when you access your home computer using its URL, DNS lookup returns your home computer's latest registered public IP.

It is a free service, as mentioned, as a matter of fact I have seen lots of DSL broadband routers providing this setting also... which opens up opportunities for other applications such as remote home monitoring, but I shall leave those for another blog. 

Configuration for Dynamic DNS.
There is a good tutorial on DynDNS page for setting up "ddclient", along with configuration step-guide (http://www.dyndns.com/support/kb/using_ddclient_with_dyndns_services.html)

Herewith my configuration: 
/usr/local/etc/ddclient.conf
# Basic configuration file for ddclient
#
# /etc/ddclient.conf
daemon=600
cache=/tmp/ddclient.cache
pid=/var/run/ddclient.pid
ssl=yes
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=
password=
protocol=dyndns2
server=members.dyndns.org
wildcard=YES
custom=yes, example.com

XLite Configuration
XLite is a free Windows program. Setting it up as a VoIP client is quite straightforward. Just configure the username, password and domain (home Asterisk server's URL). Once the registration is successful, you are ready to go. 

Testing Scenarios
Moment of truth. My colleague and I have tried the following scenarios with their results attached. 
XLite calls homephone                           OK
XLite calls local number                         OK*
(caller is PSTN number, however after mobile denies incoming call, XLite is still ringing)
homephone calls XLite                          OK (extension 12345678)
Mobile calls XLite                                 Not OK.
(This is because the extension is not registered to the public PSTN network... )

In conclusion, this exercise shows that it is possible to setup a VoIP server at home and offloading most of its functions onto a light-weighted VoIP client registered over the public internet. To fully offload the SIP server's functions onto the VoIP client, the PSTN phone number must also be set for the VoIP client - effectively removing the home phone usage. 

No comments:

Post a Comment