In this lesson NAT and Public IP based Asterisk servers will be discussed. A majority of Asterisk servers setup for this course will be using a NAT connection to the Internet, so that will be the focus.
NAT Connection
The typical Internet connection for desktop computers is through a router that offers network address translation (NAT). This allows a home or business to use a single public Internet connection for all the computers at their location. Only the router has an actual public IP address that can communicate with the Internet, the devices in the home or business will then have private IP addresses. Private addresses are easy to identify as they start with either 10, 172.16-31, or 192.168.
When using a private IP address, devices on the Internet cannot directly communicate the local Asterisk computer. There are two options that can be used to allow communication to the local computer. One is to open the port 5060 on the router and forward the Internet traffic to the Asterisk computer within the local network. This can be complicated to setup. The second option is to start the SIP communication from within the local network to the SIP provider and keep the connection open. This is the preferred option and it involves registering SIP provider in the sip.conf file.
To register a SIP provider open the /etc/asterisk/sip.conf file for editing. In the [general] context a new line will need to be added to register the SIP provider. Each provider should provide information on how to register Asterisk to them. The syntax should be similar to register => username:password@domainname
To use an example of registering the Asterisk server with Questblue enter the following line in the [general] context of the /etc/asterisk/sip.conf file:
register => username:[email protected]
Once saved in the sip.conf file the changes will need to reloaded in the Asterisk console. To open the Asterisk console use the command:
sudo asterisk -rvvv
To reload SIP in the Asterisk console use the command:
sip reload
Within the console, the registry should be listed if it successfully connects to the SIP provider. To view registry information use the command:
sip show registry
Public IP
The Asterisk Server can be setup with a public IP address if available. This will require purchasing an address from your Internet Service Provider or installing Asterisk on a virtual server purchased from a cloud provider. These setups are beyond the scope of this course. But if a public Asterisk server is desired a good starting place would be to purchase a virtual server from a cloud provider such as DigitalOcean (Links to an external site.)Links to an external site..
An Asterisk server with a public IP address will not need to be registered. Having a public IP address allows computers from all over the world to directly communicate with it.