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

no edit summary
mNo edit summary
No edit summary
Asterisk is extremely flexible and covering different uses for it is outside the scope of this example as the setup used here was very basic. You should read through the included documentation, especially the security documentation, before configuring Asterisk for the first time.
 
= Configuration =
==Define proxies for inbound calls==
== Incoming Calls ==
Some background first:
=== Peer Section ===
 
*Accept authenticated calls and route them to a context.
Asterisk performs a '''forward''' DNS lookup on incoming calls. This means that even where the Asterisk box has registered, if the call comes in from the IP it registered to on a dual stack box but the lookup returns the other IP, Asterisk gets confused about where to route the call. It does not seem to cache the IP address it finds for the duration of the TTL either, so you can register one minute, then have a call from the same IP fail the next.
 
Unfortunately the only way around this seems to be to define a peer for each potential IP address that a call can come from. We only have two live "voiceless" servers at present (and a third test box) but it means that as we expand the service in future Asterisk users would have to keep updating their SIP configs. We therefore created a list of 10 servers (C and onwards are just A records pointing to the A server for now). Sadly this means that we needed to created 20 peers as they will all be dual stack!
 
If your Asterisk box is not dual stack you only need to include the IPv4 '''or''' [[IPv6]] hostnames; whichever you're using.
 
If you are not registering you will need to set up the username, password and host name for the trunk in the "SIP to your server" settings on the control pages. We do not recommend registering unless you're on a dynamic IP or behind NAT.
 
Here is what the config looks like for a dual stack Asterisk box on static public IPs:
 
sip.conf:
<syntaxhighlight>
[aaisp-incoming-username]
; Config for inbound calls
[voiceless-common](!)
type=peer
context=aaisp-incoming-context
; The following 2 values are set in the "SIP to your server" trunk settings on the control pages.
secret=aaisp-incoming-password
; They should be commented out, and trunk settings removed from the control pages, if using Asterisk to register to the far end.
fromuser=voiceless-in ; Their user for authenticating with us.
secret=incomingpass ; Their password for authenticating with us
context=voiceless-in
insecure=invite
transport=udp
disallow=all
allow=alaw
trustrpid=yes
</syntaxhighlight>
*We send Remote-Party-Id with the privacy and screen settings, setting trustrpid=yes in the incoming SIP config will allow asterisk to pass withheld/unknown on.
 
=== Authentication ===
; IPv4 hostnames
*Voiceless must authenticated so that calls are recognised as the above peer section.
[voiceless-1](voiceless-common)
*You need to use the '''match_auth_username=yes''' setting otherwise Asterisk will not recognise Voiceless' initial requests.
host=a4.voiceless.aa.net.uk
[voiceless-2](voiceless-common)
host=b4.voiceless.aa.net.uk
[voiceless-3](voiceless-common)
host=c4.voiceless.aa.net.uk
[voiceless-4](voiceless-common)
host=d4.voiceless.aa.net.uk
[voiceless-5](voiceless-common)
host=e4.voiceless.aa.net.uk
[voiceless-6](voiceless-common)
host=f4.voiceless.aa.net.uk
[voiceless-7](voiceless-common)
host=g4.voiceless.aa.net.uk
[voiceless-8](voiceless-common)
host=h4.voiceless.aa.net.uk
[voiceless-9](voiceless-common)
host=i4.voiceless.aa.net.uk
[voiceless-10](voiceless-common)
host=j4.voiceless.aa.net.uk
 
sip.conf:
; [[IPv6]] hostnames
<syntaxhighlight>
[voiceless-11](voiceless-common)
[general]
host=a6.voiceless.aa.net.uk
match_auth_username=yes
[voiceless-12](voiceless-common)
host=b6.voiceless.aa.net.uk
[voiceless-13](voiceless-common)
host=c6.voiceless.aa.net.uk
[voiceless-14](voiceless-common)
host=d6.voiceless.aa.net.uk
[voiceless-15](voiceless-common)
host=e6.voiceless.aa.net.uk
[voiceless-16](voiceless-common)
host=f6.voiceless.aa.net.uk
[voiceless-17](voiceless-common)
host=g6.voiceless.aa.net.uk
[voiceless-18](voiceless-common)
host=h6.voiceless.aa.net.uk
[voiceless-19](voiceless-common)
host=i6.voiceless.aa.net.uk
[voiceless-20](voiceless-common)
host=j6.voiceless.aa.net.uk
</syntaxhighlight>
 
==Withheld/unknown caller ID - trustrpid==
We send Remote-Party-Id with the privacy and screen settings, setting trustrpid=yes in the incoming SIP config will allow asterisk to pass withheld/unknown on.
 
== Outgoing Calls ==
==Define a proxy for outbound calls==
*Either use a separate '''type=user''' section or combine incoming and outgoing in one '''type=friend''' section
Defining us as a SIP proxy for outbound calls:
 
=== Separate Section ===
sip.conf:
<syntaxhighlight>
[aaisp-outgoing-account]
; Config for outbound calls.
type=user
[voiceless-out]
type=peer
remotesecret=outgoingpass ; Our password to their service *some older asterisk versions require secret, not remotesecret, here*
defaultuser=+441234567890 ; Authentication user for outbound *some older asterisk versions require username, not defaultuser, here*
host=voiceless.aa.net.uk
defaultip=81.187.30.111
username=aaisp-phone-number
remotesecret=aaisp-outgoing-password
transport=udp
disallow=all
allow=alaw
</syntaxhighlight>
 
=== Combined Section ===
sip.conf:
<syntaxhighlight>
[aaisp-incoming-username]
type=friend
transport=udp
disallow=all
allow=alaw
; incoming
context=aaisp-incoming-context
secret=aaisp-incoming-password
trustrpid=yes
; outgoing
host=voiceless.aa.net.uk
defaultip=81.187.30.111
username=aaisp-phone-number
remotesecret=aaisp-outgoing-password
</syntaxhighlight>
 
 
==Note: Order of sip.conf is important==
In sip.conf, ensure that your incoming config is before the config for the outgoing.
 
 
==Note: Asterisk and IPv6 SLAAC addresses==
Asterisk will bind to all [[IPv6]] addresses if it is set to use [[IPv6]]. This means that if you have a static IP and a SLAAC IP, Asterisk sometimes replies to invites sent to the static IP from the SLAAC IP instead which breaks things. We recommend using static IP addresses and disabling SLAAC (and privacy extensions) on the box running Asterisk until its [[IPv6]] support is more mature.
 
 
==Registration==
register => +441234567980:outgoingpass@voiceless.aa.net.uk/extn
</syntaxhighlight>
In this example, extn is the extension that Asterisk will pass the call to. Asterisk matches the hostname against the peers later on in the config and so the only change you have to make is to remove the fromuser and secret from the [common] template in the inbound proxy example above.
Localnet should of course be set to whatever RFC1918 range you are using on your LAN.
 
[voiceless-in]
exten => _X.,1,Dial(SIP/snom)
</syntaxhighlight>
 
 
==Test server==
We have a test server for debugging problems and testing new features.
If you wish to allow our test server to make calls in to you as well, you can include its IPs by defining these peers too:
<syntaxhighlight>
; Test server IPv4 hostname
[voiceless-test4](voiceless-common)
host=z4.voiceless.aa.net.uk
 
; Test server [[IPv6]] hostname
[voiceless-test6](voiceless-common)
host=z6.voiceless.aa.net.uk
</syntaxhighlight>
 
 
=Firewall & Security=
*You will also want to set up firewall rules, as per the [[VoIP Firewall]] page.
*Also see the [[VoIP Security]] page for information about securing your VoIP service.
 
42

edits