Configure a SIP trunk on Asterisk
This is the complete configuration of a Vohippo trunk on Asterisk with the PJSIP driver (Asterisk 16 and later). All you need is the username and password of the SIP account, which you find in the portal under SIP accounts.
1. The trunk in pjsip.conf
Four sections: the credentials, where to reach us, the registration and the endpoint itself. The last section (identify) is what recognises the calls coming from us.
; /etc/asterisk/pjsip.conf — trunk towards Vohippo
[vohippo-auth]
type=auth
auth_type=userpass
username=USER_FROM_PORTAL
password=PASSWORD_FROM_PORTAL
[vohippo-aor]
type=aor
contact=sip:sip.vohippo.com:5060
qualify_frequency=60
[vohippo-reg]
type=registration
transport=transport-udp
outbound_auth=vohippo-auth
server_uri=sip:sip.vohippo.com
client_uri=sip:USER_FROM_PORTAL@sip.vohippo.com
retry_interval=60
expiration=600
[vohippo]
type=endpoint
transport=transport-udp
context=from-vohippo
aors=vohippo-aor
outbound_auth=vohippo-auth
from_user=USER_FROM_PORTAL
from_domain=sip.vohippo.com
disallow=all
allow=alaw,ulaw,g722
dtmf_mode=rfc4733
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
[vohippo]
type=identify
endpoint=vohippo
match=sip.vohippo.com
2. The dialplan
One context for outbound calls from your phones and one for the calls arriving from the trunk. Numbers go out in international format, without the plus sign.
; /etc/asterisk/extensions.conf
[from-internal-custom] ; the context of your phones
exten => _X.,1,Set(CALLERID(num)=390212345678) ; your verified number
same => n,Dial(PJSIP/${EXTEN}@vohippo,60)
same => n,Hangup()
[from-vohippo] ; calls arriving from the trunk
exten => _.,1,NoOp(Inbound call from ${CALLERID(num)})
same => n,Dial(PJSIP/101&PJSIP/102,25)
same => n,Voicemail(101@default,u)
same => n,Hangup()
3. Caller ID
The number you show to the person you call is decided in one of two ways, and the platform handles both.
- If you set a fixed caller ID on the account in the portal, that one always wins: whatever the PBX sends is ignored
- If you leave it free, we take the number from the From field or the P-Asserted-Identity of your INVITE
- In that case the number must match one of the caller IDs already verified in the portal, otherwise the call is rejected
4. Check that it works
From the Asterisk console (asterisk -rvvv) three commands tell you where things stopped.
pjsip show registrations ; must say Registered
pjsip show endpoint vohippo ; state and negotiated codecs
pjsip set logger on ; full SIP trace, to understand a rejection
If something does not work
The three most common stumbles, in order of frequency.
- Registration stuck at Rejected: username or password copied with a trailing space
- Call rejected immediately: caller ID not verified, or destination not enabled on the account
- Audio only one way: almost always NAT, solved by rtp_symmetric, force_rport and rewrite_contact, which the example already has
Let's talk: the demo is given by a person, not a video
One of our operators walks you through the portal live and answers the questions that matter for your case. If you would rather write, we are on WhatsApp.
Signing up is free and with no commitment: we credit your account with trial credit so you can make your test calls.