Install and configure opensips process records

Source: Internet
Author: User
Tags pear nameserver rsyslog vmware server

The operating system in this article is centos and the opensips version is 1.8.2.

Update2013/6/27: version 1.9.1 is also verified as a http://opensips.org/pub/opensips/latest/src/opensips-1.9.1_src.tar.gz

Install centos

(Skip this step if you already have an environment)

1. When a VM is installed, the console (in chrome) cannot be displayed when there is a problem with VMware Server 2.0. It can be used normally after being changed to virtualbox 4.2;

2. Install centos 6.3 on the VM and select standard server.

For such virtual machines on the command line interface, you can use Telnet to directly access the clipboard;

If the NIC mapped to the VM does not start automatically, run the IFUP eth0 command to start the VM.

If the (virtualbox) Virtual Machine is copied, you may need to delete/etc/udev/rules first. d/70-persistent-net.rules, and then modify the hwaddr address in/etc/sysconfig/network-scripts/ifcfg-eth0.

If you need to configure the nic ip address, first ifconfig-a to view the NIC device number and MAC address, then edit the/etc/sysconfig/network-scripts/ifcfg-eth0 file, as shown in the following example:

Device = "eth0"Bootproto= "NONE"Hwaddr= "08: 00: 27: 81: 30: F4"Nm_controlled= "Yes"Onboot= "Yes"Type= "Ethernet"UUID= "Dcd43c45-adf4-480b-b461-179ee8d2e8d6"Ipaddr= 192.168.1.120Netmask= 255.255.255.0Gateway= 192.168.1.1

Specify DNS in/etc/resolv. conf to install the software package (after centos6, you can specify DNS in ifg-eth0)

 
Nameserver 202.181.202.140Nameserver208.67.220.220
Install opensips (based on the official tutorial video tutorial)

Opensips provides a video tutorial (This page has a download link, 90 MB). We recommend that you use the menuconfig method, which is more convenient and error-prone. The following is a summary:

Yum install GCC make
Yum install flex bison ncurses libncurses-dev ncurses-devel
Yum install MySQL mysql-server mysql-libs mysql-devel

Wget http://opensips.org/pub/opensips/1.8.2/src/opensips-1.8.2_src.tar.gz
Tar zxvf opensips-1.8.2_src.tar.gz
CD opensips-1.8.2-tls

Make menuconfig (check db_mysql. Do not change any other parameters)
Select "compile and install opensips" from the menu"
Exit menuconfig

VI/usr/etc/opensips/opensipsctlrc: Remove mysql-related comments (db_path and usercol keep comments)
Service mysqld start
Opensipsdbctl create (no is selected for both issues)
Osipsconfig (select enable_tcp, use_auth, use_dbacc, use_dbuserloc, use_dialog, and generate residential script)
Use the generated opensips_residential_xxx.cfg to replace the original opensips. cfg

VI/usr/etc/opensips. cfg (change the listen address and mpath. The latter is usually/usr/lib/opensips/modules)
Opensipsctl start (netstat-ANP Port Check)
Service iptables stop (disable firewall)

If an error is prompted when opensips is started, check/var/log/messages (if opensips. if log_stderror = No is set in CFG, logs are connected to this file.) This is generally caused by the absence of module parameters. For example, "error: URI: db_checks_fixup1: configuration error-no database URL is configured!" is found in the log !", In opensips. "loadmodule" URI in CFG. then add modparam ("Uri", "db_url", "MYSQL: // opensips: opensipsrw @ localhost/opensips.

Create a test user:

Opensipsctl add 101 101

If the system prompts "error: domain unknown: use usernames with domain or set default domain in sip_domain" when creating a user, you can modify the opensipsctlrc file to set sip_domain to the local domain name or IP address.

Configure opensips

Set log output mode

There are several parameter control logs output in opensips. cfg:

DEBUG = 3 # This value controls the log output details. 3 is normal, and 4 is detailed (many logs will be generated ).
Log_stderror = No # if it is set to no, the log is output to the file. Otherwise, the log is output to the console (it should be useful when the opensips service is started in the foreground mode ).
Log_facility = log_local0 # It should be used to distinguish logs generated by opensips in the configuration file of the syslog service (see "using independent Log Files" below ").
Fork = yes # if it is set to yes, the opensips service is started in the background. If it is set to no, the service is started in the foreground.

Use independent log files

Opensips uses the syslog service, so by default, logs will enter the/var/log/message file. If you want to use an independent log file, you can set it as follows:

Touch/var/log/opensips. Log
VI/etc/rsyslog. conf --> Add a line: local0. */var/log/opensips. Log
/Etc/init. d/rsyslog restart

Configure stun Module

Opensips comes with a stun module to implement the functions of the stun server (dual Nic required ). The configuration method is also very simple (official documentation). Add the following content to opensips. cfg:

#### Stun Module
Loadmodule "stun. So"
Modparam ("stun", "primary_ip", "11.22.33.44") # IP address of the opensips Server
Modparam ("stun", "primary_port", "5060") # It must be the same as the UDP port of opensips (generally 5060)
Modparam ("stun", "alternate_ip", "55.66.77.88") # IP address of another ENI
Modparam ("stun", "alternate_port", "3479") # Another port number

After configuring stun, you can use stun-client for testing. In Windows, for example, the test command is:

Stun-client-0-96.exe 11.22.33.44: 5060-V

Install and configure the rtpproxy Module

The rtpproxy module is usually used with the nathelper module. First, make sure that the rtpproxy has been installed on the server and start rtpproxy:

Rtpproxy-F

Then make the following configuration in the opensips. cfg file:

Loadmodule "rtpproxy. So"
Modparam ("rtpproxy", "rtpproxy_sock ","UNIX:/var/run/rtpproxy. Sock") # Customize me

Install and configure the mediaproxy Module

Mediaproxy official documentation link

A reference link for installing mediaproxy2.5.2 on centos6.

Download the mediaproxy source code (and various dependent packages required) and install it (Procedure omitted ). After installation:

Copy config. ini. Sample to/etc/mediaproxy/config. ini and copy the TLS directory.

Echo 1>/proc/sys/NET/IPv4/ip_forward

Media-DISPATCHER restart

Media-relay restart

Configure the mediaproxy module in opensips. cfg as follows:

#### Mediaproxy Module
Loadmodule "mediaproxy. So"
Modparam ("mediaproxy", "Disable", 0)
# Modparam ("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy/dispatcher. Sock ")
Modparam ("mediaproxy"," mediaproxy_timeout ", 500)
Modparam ("mediaproxy", "signaling_ip_avp", "$ AVP (nat_ip )")
Modparam ("mediaproxy", "media_relay_avp", "$ AVP (media_relay )")

If mediaproxy prompts "no suitable relay found", it may be a certification issue. Reference

(Unfinished)

Capture sip packets

Use tcpdump on the server where opensips is located to capture the SIP package for analysis (note that the NIC to be crawled is eth0 or eth1 ):

Tcpdump-NQT-S 0-a-I eth0 port 5060-W/home/capture_file_name.pcap

Refer:Http://jonathanmanning.com/2009/10/26/how-to-voip-sip-capture-with-tcpdump-on-linux/

To capture the package on a mobile phone, you need to first use the root phone, and then copy tcpdump to the mobile phone for use:

ADB Shell
Su
Tcpdump-NQT-S 0-W/sdcard/packets_xx.pcap
ADB pull/sdcard/packets_xx.pcap

For details, refer to this article.

Install opensips-CP

After downloading the opensips-CP source code package from SourceForge, the file named install is included. We recommend that you install the package based on this file. Some information that can be found online is often outdated or inaccurate.

Yum install httpd PHP-mysql PHP-xmlrpc php-Pear

Pear install mdb2
Pear install mdb2 # MySQL
Pear install mdb2 # mysqli
Pear install log

In/etc/PHP. ini:
Set short_open_tag to on
Add/usr/share/pearIn the inculde_path variable (for some tutorials, add/usr/share/PHP. For actual tests, add/usr/share/pear)

Wget http://sourceforge.net/projects/opensips-cp/files/opensips-cp/5.0/opensips-cp_5.0.tgz/download

Tar-zxvf opensips-cp_5.0.tgz

Copy the decompressed folder (generally named "5.0") to the/var/WWW directory and change it to opensips-CP.

VI/etc/httpd/CONF/httpd. conf, add the following line:

Alias/CP "/var/www/opensips-CP/Web"

Chown Apache: Apache/var/www/opensips-CP/config/access. Log (if it is another version of Linux, the user name may be www-data or other)

(Install, which comes with the source code, cannot be understood. PostgreSQL should be the same as MySQL .)

Admin required for installation:

CD/var/www/opensips-CP/config/tools/admin/add_admin/

Mysql-dopensips-P <ocp_admin_privileges.mysql

Mysql-uroot opensips: Enter the MySQL command line and run the following command to add an administrator:

Insert into ocp_admin_privileges (username, password, HA1, available_tools, permissions) values ('admin', 'admin', MD5 ('admin: admin'), 'all ', 'all ');

Install cdrviewer:

CD/var/www/opensips-CP/config/tools/system/cdrviewer/

Mysql-dopensips-P <CDRS. MySQL

Mysql-dopensips-P <opensips_cdrs.mysql

CD/var/www/opensips-CP/cron_job

VI generate-cdrs_mysql.sh (fill in database connection information)

Note that the "Call opensips_cdrs_limit 6 ()" in the generate-cdrs_mysql.sh file may be changed to "Call opensips_cdrs ()", which must be the same name as the one defined in opensips_cdrs.mysql.

VI/etc/crontab (add scheduled tasks, for example, generated every three minutes: */3 * root/var/www/opensips-CP/cron_job/generate-cdrs_mysql.sh)

Install smonitor:

CD/var/www/opensips-CP/config/tools/system/smonitor)

Mysql-dopensips-P <tables. MySQL

VI/etc/crontab (add a scheduled task, for example, once every minute: ***** root PHP/var/www/opensips-CP/cron_job/get_opensips_stats.php>/dev/null)

Install add_user:

(Ocp_admin_privileges.mysql has been installed at the beginning. You do not need to do it again here. There are many minor issues in the install document)

Start opensips-CP:

Service mysqld start

Service httpd start

Open the browser to access the http://xxx.xxx.xxx.xxx/cp/ should be able to see the login interface, login with the admin user created previously.

Not complete to be continued ..

Other useful links

Opensips official forum

About the clients of SIP and sip

Best practices for sip nat traversal

Some Problems and Solutions

The server maintains the connection:Use the nat_traversal or nathelper module (based on some posts in the discussion group, the functions of these two modules are almost the same), so that opensips can send a package to the client each time, the port ing on the vro is maintained (that is, the hole is always open ). When the client captures packets, you can see these sip packets from the server, generally named options.

After the client receives the invite command, there is no ring:This is a strange problem, but it occurs from time to time on the client.ProgramBoghe v2.0.153.836. No reason or solution is found yet.

Modify the SIP package on the vro:Using volans ve602w as the vro, The via field in the register package sent from the client will be changed to a public IP address, causing the opensips server to determine whether it is from the Intranet (nat_client_test method in the nat_traversal module) to fail, the other three routers (tplink, mercury, and buffalo do not have this situation ). No solution is found. There is a similar problem here.

The client receives the repeated options message:Because you have logged on to opensips repeatedly (using different routers), opensips sometimes sends multiple options packages to the client until the server considers the client to be offline. If the client adds expires = xxx to the contact field of the register message, the server records the time when the client fails in the location table. If this time is too long, the server keeps trying to connect to the client.

Sometimes there is no video screen after the connection:You have encountered this problem: You can call the video ten times, but sometimes there is no picture. Later it was found that some ports were disabled by the server firewall (using iptables -- list input to query and found that the server only allowed UDP 35000 ~ 50000 ). The solution is to specify the port range when starting rtpproxy, for example, rtpproxy-M 40000-M 50000-f.

The contact URI field is not changed to a public IP Address:By adding debugging information, it is found that although the fix_nated_contact () method has been called, the Intranet address in the contact URI in the SIP Packet sent back by the server is not replaced with the Internet address. This problem is not found at the company. The problem occurs at home (the router replacement is invalid) and the cause is not found for the time being.(Correct: the problem itself is incorrect. Observe the 200ok message returned from the server, rather than the original message received by the server)

One-way voice/video or audio-only dial-through: It may be that the length of the SIP package exceeds the MTU value of the network device. In UDP protocol, if the client cannot process too long sip packets (generally those SIP messages with SDP, in addition, video requests are larger than the SIP messages generated by audio requests. More video requests may be discarded, resulting in invalid sip packets sent/received by the server. Solution: 1) switch to the TCP protocol; 2) reduce the size of the SIP package. Some clients can delete unnecessary fields in the SIP package (if custom development is supported ), in addition, there is a reference link here; 3) using clients that support ultra-long UDP packets or small sip packets (I am not doing well with the doubango-based boghe part, after switching to X-lite, we found that the length of the same request sip package is much smaller: 18xx vs 10xx ).

Clear online users:You can use opensipsctl ul rm id to delete an online user. Repeated Records may occur when a user logs on multiple times within a certain period of time. In this case, you may need to clear the online status of the user.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.