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:
Now at the very end of the file, add the client:
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 -r
To see the list of clients you can use the command:
sip show users
To exit the Asterisk console, type:
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:
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:
exten => 6000,1,Dial(SIP/6000)
exten => 6001,1,Dial(SIP/6001)
Restart Asterisk to apply the changes:
sudo service asterisk restart
Done, we added two users and they can call each other.
Adding a SIP client to FreePBX