Asterisk/MemberPBX

From NURDspace

Introduction

The following page describes the step taken by one of the members to connect an asterisk installation running at home of the member to the instance that is running @ nurdspace.

For FreePBX configuration click the blue text in this line.

Requirements

There are various things you need in order to get this working:

  • Some networked machine or vm on which you can run Asterisk
  • A SIP account in the NURDspace asterisk server
  • A VPN tunnel that links your server to the NURDspace network

To make the setup more interesting, you can get 1/more free SIP phones from NURDspace which you can hookup to your local network.

Demo setup

At home I run a setup using the following.

  • OS: OpenBSD 7.1
  • Asterisk: 18.x

Configuration of asterisk is relatively straightforward. Install the package, and modify the below two files.

pjsip.conf

This file is used to configure the SIP driver. SIP is the main (only) transport that will be used here, both to provide in-home telephony, but also to phone with the NURDspace asterisk setup.

; =========================
; Primary transport
;
; It is also possible to configure (mutual) TLS encrypted+authenticated links, but this is out of scope
;
[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0

; =========================
; NURDspace trunk
;
; This is the 'dialin' account that your asterisk instance will use to login to the NURDspace asterisk
; instance (running at 10.208.1.8).
;
[nurdspace-trunk]
type = registration
transport=transport-udp
outbound_auth = nurdspace-trunk-auth
server_uri = sip:10.208.1.8
client_uri = sip:r3boot@10.208.1.8
retry_interval = 5

[nurdspace-trunk-auth]
type = auth
auth_type = userpass
username = yourusername
password = PASSWORD_HERE
realm = asterisk

; ============================
; NURDspace endpoint
;
; This is the endpoint which is used to map extensions to. By adding '@nurdspace' to an extension, you can
; use this endpoint to forward the calls towards that endpoint
;
[nurdspace]
type=endpoint
transport=transport-udp
context = phones
allow = !all,g722,ulaw
outbound_auth = nurdspace-auth
aors = nurdspace-aor
direct_media = no

[nurdspace-auth]
type = auth
auth_type = userpass
username = YOUR_MEMBER_USERNAME
password = PASSWORD_HERE
realm = asterisk

[nurdspace-aor]
type = aor
contact = sip:10.208.11.13

[nurdspace-identify]
type=identify
endpoint = nurdspace
match = 10.208.11.13

; ==================
; Mitel 6865i Desk Phone
;
; This is a physical SIP phone. By convention, these are registered using their MAC addresses. Do
; not bind this phone to an extension / user, since this is done using extensions.conf.
;
[00085DAABBCC]
type=endpoint
transport=transport-udp
context=phones
disallow=all
allow=ulaw
auth=00085DAABBCC
aors=00085DAABBCC

[00085DAABBCC]
type=auth
auth_type=userpass
password=PASSWORD_HERE
username=00085DAABBCC

[00085DAABBCC]
type=aor
max_contacts=1

; ==================
; Softphone
;
; This is a SIP account which can be used by a SIP client running on your phone or laptop
;
[softphone]
type=endpoint
transport=transport-udp
context=phones
disallow=all
allow=ulaw
auth=softphone
aors=softphone

[softphone]
type=auth
auth_type=userpass
password=PASSWORD_HERE
username=USERNAME_OF_SOFTPHONE

[softphone]
type=aor
max_contacts=1

extensions.conf

In this file you map extensions (numbers you can dial on your PBX) to destinations (SIP endpoints). It uses this ... weird programming language and it is somewhat flexible in what it can do. This is where you build IVR menus.

[general]

; Define global variables
[globals]
r3boot_DeskPhone = PJSIP/00085DAABBCC
r3boot_SoftPhone = PJSIP/softphone

; Default extensions that came with asterisk
[default]
exten => *99,1,VoiceMailMain(${FILTER(0-9,${CALLERID(NUM)})})

exten => *98,1,Answer()
exten => *98,n,ConfBridge(*98,c,M)

exten => _XXX,1,Dial(SIP/${FILTER(0-9,${EXTEN})},12,tr)
exten => _XXX,n,Voicemail(${FILTER(0-9,${EXTEN})})
exten => _XXX,n,Hangup
[phones]
; ======================
; The following are extensions that are configured in my own house
; 100 - Deskphone
; 101 - A softphone I run on my mobile
; 200 - Play a hello world sample for testing purposes
;
; r3boot deskphone
exten => 100,1,NoOp()
 same => n,Dial(${r3boot_DeskPhone}, 10)
 same => n,HangUp()

; r3boot softphone
exten => 101,1,NoOp()
 same => n,Dial(${r3boot_SoftPhone}, 10)
 same => n,HangUp()

; Test extension
exten => 200,1,NoOp()
 same => n,Answer(.25)
 same => n,Playback(hello-world)
 same => n,Hangup()

; ======================
; The following extensions are mapped to various extensions at NURDspace
;
; 666 - Flok
; 1900 - Boots
; 1111 - Flok
; 2222 - NURDspace radio
; 2223 - Skip naar de volgende track op NURDspace radio
; 2992 - Flok
; 3010 - Tahtkev
; 4001 - Bar
; 4200 - buZz
; 4222 - Rookhok
; 4300 - Niz
; 4333 - Studio
; 4500 - Boots
; 4666 - Zaal 1
; 4667 - Zaal 3
; 4700 - r3boot
; 4701 - r3boot
; 9999 - Party Line
;

; Bar
exten =>  4001,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Rookhok
exten => 4222,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Studio
exten => 4333,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Zaal 1
exten => 4666,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Zaal 3
exten => 4667,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Party line
exten => 9999,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; play hold music
exten => 2222,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; skip mpd
exten => 2223,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; buZz
exten => 4200,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; boots
exten => 1990,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

exten => 4500,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Niz
exten => 4300,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; r3boot deskphone
exten => 4700,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; r3boot softphone
exten => 4701,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Flok 1
exten => 1111,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Flok 2
exten => 2992,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Flok 3
exten => 666,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

; Tahtkev
exten => 3010,1,NoOp()
 same => n,Dial(PJSIP/${EXTEN}@nurdspace, 10)
 same => n,HangUp()

Verification that things are working

Check SIP transports

pjsip show transports

Check SIP endpoints

pjsip show endpoints