newspaint

Documenting Problems That Were Difficult To Find The Answer To

Asterisk – Setting Up A Simple Home/Office Phone Network

Goal

My goal was to set up a very simple home/office phone network with a single upstream VoIP connection that allowed dialling into the plain old telephone system (POTS) via SIP. I used Voipfone as my provider in the UK and was paying £2.40/month for an ordinary geographical phone number.

The idea was to have several extensions at home which could call each other. Each extension should be able to call the outside world by prefixing the number with the digit 9.

Incoming calls to the ordinary phone number would cause all extensions to ring – with the first one picking up to take the call.

Home PABX Design Goal

Home PABX Design Goal

Setting Up

Linux

On an Ubuntu server I merely issued the command:

apt-get install asterisk

Configuration Files

I deleted the provided sip.conf and extensions.conf files.

Then I set up my trunk/peer (Voipfone SIP provider) along with 3 extensions numbered 201, 202, and 203.

[general]
register => username:password@sip.voipfone.net/voipfone
transport=udp

[voipfone]
type=peer
insecure=invite
dtmfmode=rfc2833
context=fromvoipfone
deny=0.0.0.0/0.0.0.0
permit=195.189.173.27/255.255.255.255
defaultuser=username
secret=password
fromdomain=myhomedomain.net
host=sip.voipfone.net

[201]
type=friend
dtmfmode=rfc2833
context=fromhomeoffice
secret=ext201
host=dynamic
mailbox=201@default

[202]
type=friend
dtmfmode=rfc2833
context=fromhomeoffice
secret=ext202
host=dynamic
mailbox=202@default

[203]
type=friend
dtmfmode=rfc2833
context=fromhomeoffice
secret=ext203
host=dynamic
mailbox=203@default

It is worth noting that the context refers to a block in the dialplan that gets called when a number originates from that extension. Clearly we want phone calls coming from the plain old telephone system (POTS) to be treated differently to calls coming from internal extensions.

The dialplan is stored in a file called extensions.conf.

;----------
; calls from the outside world ring all extensions
;----------
[fromvoipfone]
exten => voipfone,1,NoOp()
exten => voipfone,n,Dial(SIP/201&SIP/202&SIP/203)

;----------
; first check intra-office call, then outbound call
;----------
[fromhomeoffice]
include => internal
include => remote

;----------
; calling POTS by putting a 9 prefix
;----------
[remote]
exten => _9XX.,1,NoOp()
exten => _9XX.,n,Dial(SIP/voipfone/${EXTEN:1})
exten => _9XX.,n,Hangup()

;----------
; internal extensions calling internal extensions
;----------
[internal]
exten => _2XX,1,Dial(SIP/${EXTEN})

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: