SIP clients in Asterisk are specified in the sip.conf file, so open it for example in the nano text editor (Ctrl+X to exit the editor, y or n to save or discard changes):
sudo nano /etc/asterisk/sip.conf
First we specify the following parameter, forbidding anonymous calls:
allowguest=no
Now at the very end of the file, add the client:
[6000]
type=friend
secret=PASSWORD
nat=no
host=dynamic
dtmfmode=rfc2833
disallow=all
allow=ulaw
context=sip-dialout
callerid=6000
deny=0.0.0.0/0
permit=192.168.0.10/32
Briefly describe the parameters that I indicated:
type – type of client, can be user (authentication by password), peer (identification by host address), fried (either by password or by host).
secret – user password.
nat=no – indicates that the client may be behind NAT, see my article about this – Solution to the Asterisk problem – no sound when calling via NAT.
host=dynamic – there is no client binding to the host address.
dtmfmode=rfc2833 – method of transmitting dtmf dialing tones.
disallow=all – ban all codecs.
allow=ulaw – Let’s solve only the ulaw codec.
context=sip-dialout — the name of the dialplan (it is described in extensions.conf)
callerid=6000 – customer’s internal phone number.
deny=0.0.0.0/0 – we forbid connection from all IP addresses.
permit=192.168.0.10/32 – we only allow connection from the specified IP address.
After adding the client, we will connect to Asterisk and update the sip configuration:
sudo asterisk -rvv
sip reload
To see the list of clients you can use the command:
sip show users
sip show peers
To exit the Asterisk console, type:
quit
Now it is already possible to connect the added client to the Asterisk server using for example the X-Lite, Zoiper or VoIP phone program, but there is nowhere to call, so we will add the second client to sip.conf for the test:
[6001]
type=friend
secret=PASSWORD
nat=no
host=dynamic
dtmfmode=rfc2833
disallow=all
allow=ulaw
context=sip-dialout
callerid=6001
deny=0.0.0.0/0
permit=192.168.0.10/32
Open the extensions.conf file in the editor:
sudo nano /etc/asterisk/extensions.conf
And we will indicate the following lines at the end of it, so that users can call each other:
[sip-dialout]
exten => 6000,1,Dial(SIP/6000)
exten => 6001,1,Dial(SIP/6001)
Restart Asterisk to apply the changes:
sudo service asterisk restart
Or we’ll update the configuration if we don’t want to restart:
sudo asterisk -rvv
dialplan reload
quit
Done, we added two users and they can call each other.
If you want to use the SIP client on iPhone, then after installing and configuring the application for calls, it is necessary to activate the “Update content” function for “Wi-Fi and cellular data”, which is located in “Settings” – “Basic” – “Update content ” Since after locking the iPhone screen, after a few seconds Wi-Fi is turned off, as well as applications not specified in the “Content Update” function are not actively used to save system resources. Also, in the settings of the SIP client on asterisk we do not restrict access to it by IP address since the iPhone in a locked state will connect via cellular.
See also my article:
Adding a SIP client to FreePBX