In this guide, we will provide you with a generic example of the sip.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.
Let's dive into the example sip.conf configuration file:
[general]
nat=force_rport,comedia
externip=(your Server Public IP:Port)
localnet=192.168.0.0/255.255.0.0
callcounter=yes
busylevel=50 (number of concurrent calls)
qualify=yes
sendrpid=pai
trustrpid=yes
directmedia=no
sipreinvite=no
allowguest=no
alwaysauthreject=yes
language=en
dtmfmode=rfc2833
tcpenable=yes
[megacall] (change with your SIP Trunk Username)
type=peer
username=megacall (change with your SIP Trunk Username)
fromuser=megacall (change with your SIP Trunk Username)
secret=your_password (change with your SIP Trunk Password)
authname=megacall (change with your SIP Trunk Username)
insecure=invite,port
host=18.153.197.168
fromdomain= (only use if your PBX is behind NAT, then add your Server domain name)
disallow=all
allow=alaw,ulaw
context=from_megacall
transport=udp,tcp
Firewall
Signalling: Make sure you allow ALL traffic from the following IP Addresses: 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:
systemctl restart asterisk
For Ubuntu/Debian:
service asterisk restart
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