Adding SIP clients to Asterisk

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 -r
sip reload

To see the list of clients you can use the command:

sip show users

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

Done, we added two users and they can call each other.

See also:
Adding a SIP client to FreePBX

Adding a SIP client to FreePBX

To add a SIP client to FreePBX, open the menu “Applications” – “Extensions“, choose for example “Generic CHAN SIP Device” and we indicate the main parameters:

User Extension: 6000 (SIP number)
Display Name: Operator (any name to display)
Secret: PASSWORD
and click “Submit“.

Done, SIP is added, it can already be registered at the specified number and password.

How to add SIP in the configuration file I described in this article – Adding SIP clients to Asterisk

Solving the error “insserv: warning: script ‘script’ missing LSB tags and overrides”

I noticed once the following error:

insserv: warning: script ‘MyScript.sh’ missing LSB tags and overrides

It appears because someone wrote the /etc/init.d/MyScript.sh script before writing the LSB tags first.

To fix this, I opened the script code in a text editor (in the editor nano Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/init.d/MyScript.sh

And added in the beginning:

### BEGIN INIT INFO
# Provides:          MyScript
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      1 0 6
# Short-Description: ...
# Description: ...
### END INIT INFO

See also:
Run application at startup in Ubuntu

Configuring email notifications in Zabbix via iRedMail

On the test I will use Zabbix 3.0.3 and iRedMail 0.9.4 installed in Ubuntu Server 14.04.4 LTS.

First, in the Zabbix panel, activate the action by opening the tab “Configuration” – “Actions” and activate “Report problems to Zabbix administrators“. In it I also, to see the names of the hosts, changed both topics of the letter with:

{TRIGGER.STATUS}: {TRIGGER.NAME}

on

{TRIGGER.STATUS}: {HOST.NAME1} {TRIGGER.NAME}

In Zabbix, the email notification method was initially added, but depending on the settings of the mail server it can work or not work. You can find it by going to Zabbix under the administrator and opening the tab “Administration” – “Media types” – “Email“.

When configuring with iRedMail, I specified the following parameters:

Name: Email
Type: Email
SMTP server: mail.example.com
SMTP server port: 25
SMTP helo: example.com
SMTP email: user@example.com
Connection security: STARTTLS
Checkboxes for “SSL verify peer” and “SSL verify host” did not put
Authentication: Username and password
Username: user@example.com
Password: PASSWORD
check for “Enabled”

If the mail server is in the same system as the Zabbix server, you can try to configure both the above, but where “Connection security” and “Authentication” select “None”.

Also in the user profile, in the tab “Media” need to add:

Type: Email
Send to: mail for notifications
When active: time when it is allowed to be alerted
Use if severity: what importance of notification to send
check for “Enabled”

Done.

SNMP MIBs and OIDs for MikroTik

Today I made Zabbix templates, I started doing first under MikroTik RouterBOARD SXT-Lite2 (2nDr2).

Some OIDs can be found by running the following commands on the device:

system resource print oid
system resource cpu print oid
system health print oid
interface print oid

SNMP should be enabled on the device, in IPSNMPCommunities added community and should check IPSNMP to Enable.

From Linux, you can check the OID command:

snmpwalk -v 2c -c public 192.168.1.1 .1

I will describe below a few OIDs that I used.
SSID:

SNMPv2-SMI::enterprises.14988.1.1.1.3.1.4.2

Signal:

.1.3.6.1.4.1.14988.1.1.1.2.1.3

Uptime:

.1.3.6.1.2.1.1.3.0

CPU load:

.1.3.6.1.2.1.25.3.3.1.2.1

Define the index of interfaces by looking at their description:

.1.3.6.1.2.1.2.2.1.2
ifDescr

LAN traffic (I have an index of 1):

ifInOctets.1
ifOutOctets.1
1.3.6.1.2.1.2.2.1.10.1
1.3.6.1.2.1.2.2.1.16.1

WLAN traffic (I have an index of 2):

ifInOctets.2
ifOutOctets.2
1.3.6.1.2.1.2.2.1.10.2
1.3.6.1.2.1.2.2.1.16.2

Total memory and how many are used:

.1.3.6.1.2.1.25.2.3.1.5.65536
.1.3.6.1.2.1.25.2.3.1.6.65536

CPU frequency:

.1.3.6.1.4.1.14988.1.1.3.14.0

mac addresses of LAN and WLAN:

.1.3.6.1.2.1.2.2.1.6.1
.1.3.6.1.2.1.2.2.1.6.2

Packages with errors in/out on the WLAN interface (I have WLAN under index 2):

.1.3.6.1.2.1.2.2.1.14.2
.1.3.6.1.2.1.2.2.1.20.2

See also:
SNMP OID and MIB for interfaces

Installing the Digium Asterisk GUI

Digium Asterisk GUI – web-management interface Asterisk.

Today I’ll sculpt it to Asterisk 11 on Ubuntu Server 14.04 LTS.
Switch directly to the root user:

sudo -i

Download it:

apt-get install subversion
mkdir -p ~/asterisk-gui
cd ~/asterisk-gui
svn checkout http://svn.digium.com/svn/asterisk-gui/branches/2.0/

We compile and install:

cd 2.0
./configure
make
make install

Just in case, we’ll make a copy of the Asterisk configuration files:

cp -r /etc/asterisk /etc/asterisk.original

Open the configuration file manager.conf for example in the editor nano (Ctrl+X to exit the editor, y/n to save or cancel changes):

nano /etc/asterisk/manager.conf

The main parameters that must be configured in the manager.conf configuration file are:

[general]
enabled = yes
webenabled = yes
bindaddr = 0.0.0.0
[USERNAME]
secret = PASSWORD
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config

At the very end of the file, replace the symbol # with; otherwise you can not enter under the login and password specified above.

Now edit http.conf:

nano /etc/asterisk/http.conf

In it we will specify the following parameters of the web server:

enabled=yes
enablestatic=yes
bindaddr=0.0.0.0
prefix=asterisk

Let’s check the settings:

make checkconfig

Delete the empty folder and specify a link to the real one with the files of the web server:

rmdir /usr/share/asterisk/static-http/
ln -s /var/lib/asterisk/static-http/ /usr/share/asterisk/

Restarting Asterisk:

/etc/init.d/asterisk restart

Now Digium Asterisk GUI should open by link http://192.168.56.102:8088/asterisk/static/config/index.html, where 192.168.56.102 this is the IP or Server domain with Asterisk.

To log in, we’ll specify the username and password you wrote earlier in the manager.conf file

Done.

Solution to the Asterisk problem – no sound when calling via NAT

I noticed recently that there is no sound when calling from IP-phone to another IP-phone which were both behind the same NAT (router).

Therefore, in the sip.conf configuration for these accounts, you need to specify that they are behind NAT, specifying the parameter:

nat=force_rport,comedia

I want to note that the value of “yes” for nat is already obsolete since version Asterisk 11, so it will be correct as mentioned above.

And also point at no to the directmedia parameter, so that Asterisk does not send packets to the same port from which it was received (which in my case happened, both phones connected to Asterisk from the same IP, with the same ports):

directmedia=no

Done.

Zabbix installation on Ubuntu from distribution packages

On the test, I installed Zabbix 3.4 in Ubuntu 14.04 LTS, Ubuntu 16.04 LTS, Ubuntu 18.04 LTS.
Links to other versions of Zabbix can be found on the official website www.zabbix.com or http://repo.zabbix.com/zabbix/.
For example, Zabbix 3.4 for Ubuntu is located here http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/.

After installing Zabbix, transferred the data from the old Zabbix 2.2 server to it, simply exporting the templates first, then network nodes, set cards and complex screens.

Let’s proceed to installation, add the official source of packages to the system (example for Ubuntu 14.04 LTS (trusty)):

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+trusty_all.deb
sudo dpkg -i zabbix-release_3.4-1+trusty_all.deb
sudo apt update

For Ubuntu 16.04 LTS (xenial):

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+xenial_all.deb
sudo dpkg -i zabbix-release_3.4-1+xenial_all.deb
sudo apt update

For Ubuntu 18.04 (Bionic Beaver):

wget http://repo.zabbix.com/zabbix/3.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_3.4-1+bionic_all.deb
sudo dpkg -i zabbix-release_3.4-1+bionic_all.deb
sudo apt-get update

Perform the installation of Zabbix:

sudo apt-get install zabbix-server-mysql zabbix-frontend-php zabbix-agent

Connect to the MySQL server and create a database:

mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'ПАРОЛЬ';
quit;

We import the standard data into the created database:

cd /usr/share/doc/zabbix-server-mysql
zcat create.sql.gz | mysql -uroot -p zabbix

For example, open the Zabbix server configuration file in the nano text editor (in nano, press Ctrl+X to exit, y/n to save or cancel changes):

sudo nano /etc/zabbix/zabbix_server.conf

Specify the MySQL database name, user name and password:

DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=PASSWORD

Run the Zabbix server process:

sudo service zabbix-server start

You need to fix the PHP configuration for Zabbix. The Apache configuration file for the Zabbix web interface is located in /etc/apache2/conf.d/zabbix or /etc/apache2/conf-enabled/zabbix.conf. Some minimal PHP configuration parameters have already been set there:

php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Europe/Kiev

Restart the web server to apply the changes:

sudo service apache2 restart
sudo service zabbix-server restart

Make sure that the Zabbix agent and the Zabbix server are started at system startup and, if necessary, enable:

sudo systemctl is-enabled zabbix-agent.service
sudo systemctl is-enabled zabbix-server.service
sudo systemctl enable zabbix-agent.service
sudo systemctl enable zabbix-server.service

The Zabbix web interface is available through a browser at http://HOST/zabbix.
By default, the user name for logging in through the web interface is admin or Admin, the password is zabbix.

See also:
Installing and Configuring Zabbix Agent in Ubuntu