Jump to content

This is the support site for Andrews & Arnold Ltd, a UK Internet provider. Information on these pages is generally for our customers but may be useful to others, enjoy!

VoIP Phones - Asterisk: Difference between revisions

Content deleted Content added
Drsox (talk | contribs)
Adsb (talk | contribs)
m Don't feel comfortable with live number in example. No point in allowing ulaw because AAISP don't use it
 
(13 intermediate revisions by 2 users not shown)
Line 7: Line 7:


= Configuration =
= Configuration =
Asterisk has two methods to configure SIP connections. The legacy "sip.conf" (SIP) and the more modern "pjsip.conf" (PJSIP).
Asterisk historically had two methods to configure SIP connections: the legacy "sip.conf" (SIP) and the more modern "pjsip.conf" (PJSIP). As of Asterisk 21 "sip.conf" has been officially removed so there's no longer a choice (other than running an older Asterisk version).


Newer installations of Asterisk should be configured to use PJSIP as it will be more supported as Asterisk development continues, '''however''' it's been reported that PJSIP doesn't support in-band DTMF detection properly. You may need to switch back to legacy sip.conf if this affects you. The official recommendation on the [https://trac.pjsip.org/repos/wiki/FAQ#dtmf PJSIP FAQ] seems to be to write your own plugin if you need it. In-band DTMF support seems like an important thing to have, so we suggest raising a bug to report a missing feature in PJSIP if this affects you!
Newer installations of Asterisk should be configured to use PJSIP as it will be more supported as Asterisk development continues, '''however''' it's been reported that PJSIP doesn't support in-band DTMF detection properly. You may need to switch back to legacy sip.conf if this affects you. The official recommendation on the [https://trac.pjsip.org/repos/wiki/FAQ#dtmf PJSIP FAQ] seems to be to write your own plugin if you need it. In-band DTMF support seems like an important thing to have, so we suggest raising a bug to report a missing feature in PJSIP if this affects you!
Line 14: Line 14:


When reading the instructions below be aware which are for sip.conf and which are for pjsip.conf.
When reading the instructions below be aware which are for sip.conf and which are for pjsip.conf.

=indications.conf=
Here's an easy change to make, to use UK call progress tones in the [general] section change the country code from us to uk (assuming you are in the UK).
[general]
country = us ; default location
to
[general]
country = uk


=pjsip.conf (PJSIP)=
=pjsip.conf (PJSIP)=


==PJSIP: Trunk registration==
==PJSIP: Trunk registration==
Here is an example of a working pjsip.conf setup where Asterisk will register with A&A to receive calls.<br />
Here is an example of a working pjsip.conf setup where Asterisk will register with A&A in the same way as a SIP phone does in order to make outgoing calls. Incoming calls are sent to all registered SIP "phones".<br />
It is recommended you read the "PJSIP: NAT Issues: Keep-Alive / Anti-Idle" section below as you may wish to comment out or drastically increase the qualify_frequency line(s) if your Asterisk is not behind NAT.
It is recommended you read the "PJSIP: NAT Issues: Keep-Alive / Anti-Idle" section below as you may wish to comment out or drastically increase the qualify_frequency line(s) if your Asterisk is not behind NAT.


In pjsip.conf:
In pjsip.conf:
[reg_442082881111]
[reg_441234567890]
type = registration
type = registration
retry_interval = 20
retry_interval = 20
Line 31: Line 39:
contact_user = maininbound
contact_user = maininbound
expiration = 120
expiration = 120
outbound_auth = auth_reg_442082881111
outbound_auth = auth_reg_441234567890
client_uri = sip:+442082881111@voiceless.aa.net.uk
client_uri = sip:+441234567890@voiceless.aa.net.uk
server_uri = sip:voiceless.aa.net.uk
server_uri = sip:voiceless.aa.net.uk
[auth_reg_442082881111]
[auth_reg_441234567890]
type = auth
type = auth
password = BusinessPaidGrewCome
password = SecretPasswordGoesHere
username = +442082881111
username = +441234567890
[aaisptrunk]
[aaisptrunk]
type = aor
type = aor
contact = sip:+442082881111@voiceless.aa.net.uk
contact = sip:+441234567890@voiceless.aa.net.uk
qualify_frequency=20
qualify_frequency=20


[aaisptrunk_servera]
[aaisptrunk_servera]
type = aor
type = aor
contact = sip:+442082881111@a.voiceless.aa.net.uk
contact = sip:+441234567890@a.voiceless.aa.net.uk
qualify_frequency=20
qualify_frequency=20


[aaisptrunk_serverb]
[aaisptrunk_serverb]
type = aor
type = aor
contact = sip:+442082881111@b.voiceless.aa.net.uk
contact = sip:+441234567890@b.voiceless.aa.net.uk
qualify_frequency=20
qualify_frequency=20
Line 66: Line 74:
disallow = all
disallow = all
allow = alaw
allow = alaw
allow = ulaw
direct_media = no
direct_media = no
rtp_symmetric = yes
rtp_symmetric = yes
aors = aaisptrunk,aaisptrunk_servera,aaisptrunk_serverb
aors = aaisptrunk,aaisptrunk_servera,aaisptrunk_serverb
outbound_auth=auth_reg_442082881111
outbound_auth=auth_reg_441234567890


The "contact_user" option in the registration section sets the context for incoming calls to Asterisk, in this example calls come into the context "maininbound" in extensions.conf
Calls come into the context "maininbound" in extensions.conf - in this example calls get sent onto extension 222 and 205 for 20 seconds and then go to voicemail.

===extensions.conf===
In this example calls get sent onto extension 222 and 205 for 20 seconds and then go to voicemail.
[maininbound]
[maininbound]
exten = maininbound,1,Dial(PJSIP/222&PJSIP/205,20)
exten = maininbound,1,Dial(PJSIP/222&PJSIP/205,20)
exten = maininbound,n,Voicemail(222@default,us)
exten = maininbound,n,Voicemail(222@default,us)


In extensions.conf you can dial out via the trunk with:
You can dial out via the trunk with (probably in a context like "from-internal"):

exten => _X.,1,Dial(PJSIP/${EXTEN}@aaisptrunk,,)
exten => _X.,1,Dial(PJSIP/${EXTEN}@aaisptrunk,,)
Line 86: Line 97:


==PJSIP: Trunk without registration==
==PJSIP: Trunk without registration==
Use the above example but do not include the top section for "[reg_442082881111]".
If you don't need Asterisk to make outgoing calls, you can have A&A send incoming calls directly to Asterisk. Use the above example but do not include the top section for "[reg_442082881111]" and the 'outbound_auth' item in the aaisptrunk endpoint.


Then set the AAISP control panel to point to your server by hostname or IP address:<br />
Then set the AAISP control panel to point to your server by hostname or IP address:<br />

Outgoing calls require registration, and you'll automatically receive incoming calls to registered "phones". If you register Asterisk and have calls sent directly to Asterisk you'll receive 2 copies of each call.

[[File:Asterisk pjsip noregistration.png|border]]
[[File:Asterisk pjsip noregistration.png|border]]


==PJSIP: NAT Issues: Keep-Alive / Anti-Idle==
==PJSIP: NAT Issues: Keep-Alive / Anti-Idle==
If you are using a firewall or NAT router with short timeouts on UDP sessions you can force packets to be sent over the connection to keep it alive.
If you are using a firewall or NAT router with short timeouts on UDP sessions the example registration configuration above enables OPTIONS packets to be sent over the connection to keep it alive.
A symptom of NAT issues can be inbound call delivery working, then not working for a bit (with the code "183" in the CDR in the control panel) then calls working again without you doing anything (or possibly reloading or restarting asterisk will solve it for a bit).
A symptom of NAT issues can be inbound call delivery working for a bit after startup, then not working (with the code "183" in the CDR in the control panel) then calls working again a number of minutes later without you doing anything (or possibly reloading or restarting asterisk will solve it for a bit).


As Andrews & Arnold have multiple call servers it is possible calls can come from multiple IP addresses. Your NAT session or SIP helper/ALG may only be allowing SIP traffic from the server your Asterisk registered to.
As Andrews & Arnold have multiple call servers it is possible for call signalling to come from multiple IP addresses. Your NAT session or SIP helper/ALG may only be allowing SIP traffic from the IP address your Asterisk registered to.


In the PJSIP registration example above this is mitigated by having three AOR (Address of Record) sections. All three have qualify_frequency set (this makes asterisk send keepalive packets). The endpoint section then references the 3 aor entries.<br />
In the PJSIP registration example on this page the problem is solved by having three AOR (Address of Record) sections. All three have qualify_frequency set (this makes asterisk send keepalive packets). The endpoint section then references the 3 aor entries.<br />
Your Asterisk server will send outbound packets to the shared hostname, and the two call servers specifically. This has the effect of keeping the NAT session on your router alive for all the call servers meaning it doesn't matter which call server delivers the INVITE (call), it should always reach your Asterisk server.
Your Asterisk server will send outbound packets to the shared hostname, and the two call servers specifically. This has the effect of keeping the NAT session on your router alive for all the call servers meaning it doesn't matter which call server delivers the INVITE (call), it should always reach your Asterisk server.


Line 220: Line 234:
exten => _X.,1,Dial(SIP/voiceless-out/${EXTEN})
exten => _X.,1,Dial(SIP/voiceless-out/${EXTEN})
</syntaxhighlight>
</syntaxhighlight>
For inbound calls (assuming you're routing call to a registered Snom):
For inbound calls (assuming you're routing calls to a context named "snom"):
<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
[voiceless-in]
[voiceless-in]