When configuring a SIP trunk in Asterisk, it's important to choose the right channel module. chan_pjsip is recommended over the older chan_sip due to its better performance and support for modern SIP features. This guide walks you through setting up a SIP trunk with Internetport using chan_pjsip.
Difference between chan_sip and chan_pjsip
To understand why chan_pjsip is the recommended choice, it's important to know the differences. chan_sip is the older channel module with limited support for modern SIP features and is less flexible than chan_pjsip. In contrast, chan_pjsip is built on the PJPROJECT library, which offers better performance, more advanced features, and support for SIP advanced functions like WebRTC.
Configure /etc/asterisk/pjsip.conf
Step 1: Transport
Start by defining the transport in
pjsip.conf. This specifies how communication occurs between Asterisk and the SIP server.[transport-udp] type=transport protocol=udp bind=0.0.0.0 local_net=192.168.1.0/24Step 2: Endpoint
The next step is to create an endpoint representing the SIP trunk with Internetport.
[internetport] type=endpoint context=default disallow=all allow=g711a,g711u,g722,g729 transport=transport-udp auth=internetport_auth aors=internetport_aorStep 3: Auth
To authenticate with Internetport's SIP server, you need to specify the username and password.
[internetport_auth] type=auth auth_type=userpass username=ditt_anvandarnamn password=ditt_losenordStep 4: AOR
AOR (Address of Record) is used to manage SIP addresses and registration.
[internetport_aor] type=aor contact=sip:sip.internetport.se:5060
Configure Registration with sip.internetport.se
To enable automatic registration with Internetport's SIP server, add the following to pjsip.conf.
[internetport]
... ; previous configuration
outbound_auth=internetport_auth
registration=sip:sip.internetport.se:5060Dialplan in extensions.conf for Incoming and Outgoing Calls
To handle incoming and outgoing calls, configure the dialplan in extensions.conf.
Incoming Calls
[default]
extension => 1000,1,NoOp(Incoming call)
same => n,Dial(PJSIP/internetport/${EXTEN})Outgoing Calls
[default]
extension => _X.,1,NoOp(Outgoing call)
same => n,Dial(PJSIP/internetport/${EXTEN})Reload Asterisk Modules
Once the configurations are complete, reload Asterisk's modules to apply the changes.
asterisk -rx 'core reload'Verify Registration
To verify that the SIP trunk is correctly registered, use the following command in the Asterisk CLI:
pjsip show registrationsTroubleshooting
- Check logs for any error messages.
- Use
pjsip set logger onto enable detailed logging and identify issues.
For more help, visit Internetport's support pages.