In this guide, we will provide you with a generic example of the pjsip.conf configuration file for use with Asterisk PBX.
This file contains settings that define how Asterisk interacts with your SIP Trunk provider and handles incoming and outgoing calls.
Please note that this is only an example configuration, and you may need to modify the settings based on your specific requirements and setup.
pjsip.conf example:
;=============== TRANSPORTS ============================================
[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
external_media_address = (Your PBX Public IP)
external_signaling_address = (Your PBX Public IP)
external_signaling_port = 5060
local_net = 192.168.0.0/255.255.0.0 (change this IP Based on your PBC local network)
[transport-tcp]
type = transport
protocol = tcp
bind = 0.0.0.0
external_media_address = (Your PBX Public IP)
external_signaling_address = (Your PBX Public IP)
external_signaling_port = 5060
local_net = 192.168.0.0/255.255.0.0 (change this IP Based on your PBX local network)
;=============== SIP TRUNK ===========================================
[megacall]
type=endpoint
transport=transport-udp
context=from_megacall
disallow=all
allow=alaw
allow=ulaw
outbound_auth=megacall
aors=megacall
direct_media=no
send_pai=yes
send_rpid=yes
[megacall]
type=auth
auth_type=digest
password= (password)
username= (username)
realm=gw.megacall.es
[megacall]
type=aor
contact=sip:18.153.197.168
[megacall]
type=identify
endpoint=megacall
match=18.153.197.168
Firewall
Signalling: Make sure you allow ALL traffic from the following IP Address: 18.153.197.168
RTP: By default, we will always send this traffic through the same Signaling IP, however, we recommend allowing all traffic from ANY IP in Port Range: 10000-20000.
Here are the steps you can take to meet the requirements:
- Allow traffic from the signalling IP address:
- Log in to your firewall/router configuration page.
- Look for the option to add a new firewall rule or allow traffic.
- Add a new rule to allow traffic from the IP address 18.153.197.168 for the SIP signalling traffic.
- Save the changes to the firewall.
- Allow traffic for the RTP Port Range:
- Log in to your firewall/router configuration page.
- Look for the option to add a new firewall rule or allow traffic.
- Add a new rule to allow traffic for the RTP port range 10000-20000 from any IP address.
- Save the changes to the firewall.
Note: The steps to configure your firewall/router may vary depending on the manufacturer and model. It's important to consult the documentation or support for your specific device.
You can also edit your Asterisk configuration:
To configure Asterisk to allow signalling only from IP 18.153.197.168 and RTP traffic from any IP through ports 10000-20000, you can follow these steps:
- Open the Asterisk configuration file, sip.conf, using a text editor such as vi or nano.
- Find the section [general] and add the following line:
bindaddr=18.153.197.168
This will bind Asterisk to listen only on IP 18.153.197.168 for SIP signalling.
- Find the section [udp] and add the following lines
; RTP ports range rtpstart=10000 rtpend=20000 ; Allow RTP traffic from any IP icesupport=yes
This will allow RTP traffic from any IP through ports 10000-20000.
- Save the sip.conf file and reload the Asterisk configuration by running the command:
asterisk -rx "reload"
Now Asterisk should only allow signalling from IP 18.153.197.168 and RTP traffic from any IP through ports 10000-20000.
DNS SERVER
If you have a virtual phone number with your SIP Trunk service, you may need to add a configuration setting to ensure that inbound calls can be properly routed. Asterisk, the software that powers your PBX, does not support DNS server lookups for inbound calls, so it's important to disable this feature by adding the following line to the "sip_general_custom.conf" file:
srvlookup=no
This setting will prevent Asterisk from attempting to resolve virtual phone numbers using DNS, which can cause issues with call routing. By disabling srvlookup, your PBX will rely on the SIP Trunk service to properly route incoming calls based on the configured phone number.
To implement the DNS server requirement, you can follow these steps:
- Open the "sip_general_custom.conf" file in a text editor.
- If the srvlookup parameter is not already present, add it to the file with the value set to no.
- Save the changes to the file and close it.
- Restart the Asterisk service to apply the changes.
To restart the Asterisk service, you can use the following command, depending on your operating system:
For CentOS/RedHat:
For Ubuntu/Debian:
After completing these steps, Asterisk will no longer perform DNS server lookups for inbound calls, as specified by the SIP Trunk provider's requirements
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article