http://www.cnblogs.com/bjzhanghao/archive/2013/02/13/2910903.html
In this paper, the operating system is CentOS, used Opensips version 1.8.2.
Update2013 / 6/27: Version 1.9.1 has been validated, download address for http://opensips.org/pub/opensips/latest/src/opensips-1.9.1_src.tar.gz
(If there is such environments can skip this step)
1, the installation of virtual machines, VMWare Server 2.0 has encountered a problem can not display console (Chrome li), for the Virtualbox 4.2 for normal use;
2, install CentOS 6.3 in a virtual machine, select the type of standard server installation.
This pure command line interface for a virtual machine, you can use telnet direct access, what's more convenient operation clipboard;
If the virtual machine does not start automatically mapped network card, start with ifup eth0 command.
If (Virtualbox's) virtual machine is copied, you may need to remove /etc/udev/rules.d/70-persistent-net.rules, then modify the / etc / sysconfig / network-scripts / ifcfg-eth0 in the HWAddr address.
If you need to configure the network card ip address, the first device ifconfig -a view card number and MAC address, and then edit the / etc / sysconfig / network-scripts / ifcfg-eth0 file, the following examples:
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.120 NETMASK = 255.255.255.0 GATEWAY = 192.168.1.1
Dns designated for installation packages in /etc/resolv.conf (CentOS6 dns can be specified in the ifg-eth0 after a)
nameserver 202.181.202.140 nameserver 208.67.220.220
opensips provides a video tutorial ( this page has a download link, 90M), recommend using menuconfig way, more convenient and not prone to error. The following is a summary of steps:
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 (tick db_mysql, others do not move)
Menu, choose "Compile And Install Opensips"
Exit menuconfig
vi / usr / etc / opensips / opensipsctlrc, comments relating to the mysql remove (DB_PATH and USERCOL reserved comments)
service mysqld start
opensipsdbctl create (two issues have prompted the election no)
osipsconfig (select ENABLE_TCP, USE_AUTH, USE_DBACC, USE_DBUSERLOC, USE_DIALOG, then generate residential script)
By replacing the original opensips.cfg generated opensips_residential_xxx.cfg
vi /usr/etc/opensips/opensips.cfg (change the listen address and mpath, which is usually / usr / lib / opensips / modules)
opensipsctl start (netstat -anp check port)
service iptables stop (turn off the firewall)
If an error when starting opensips, check / var / log / messages (if opensips.cfg set log_stderror = no in the logs have entered this file, link ), is generally caused by the module parameters are not set. Such as those found in the log in "ERROR: uri: db_checks_fixup1: configuration error - no database URL is configured!", In opensips.cfg where "loadmodule" uri.so "" After adding modparam ("uri", "db_url", "mysql: // opensips: opensipsrw @ localhost / opensips") can be.
Create a test user:
opensipsctl add 101 101
If you are prompted to create a user "ERROR: domain unknown: use usernames with domain or set default domain in SIP_DOMAIN", you can modify opensipsctlrc file SIP_DOMAIN set the machine name or IP address.
Set the log output
In opensips.cfg there are several parameters to control the log output:
debug = 3 # This value controls the log output level of detail, three ordinary, 4 for details (will generate a lot of logs).
log_stderror = no # set to no, said the log output to a file, otherwise the output to the console (foreground should be based only way to start opensips service useful).
log_facility = LOG_LOCAL0 # should be used in the configuration file syslog services produced in distinguishing log opensips (see below "Use a separate log file").
fork = yes # set to yes indicates start opensips service in the background, is set to start at the front desk said no.
Use a separate log file
opensips using the syslog service, so by default logs into the / var / log / message file, if you want to use a separate log file, it can be set up:
touch /var/log/opensips.log
vi /etc/rsyslog.conf -> add a line: local0 * /var/log/opensips.log.
/etc/init.d/rsyslog restart
Configuring STUN module
opensips comes with a stun module can achieve stun server functionality (requires dual-NIC). Configuration method is very simple ( official documents ), add the following in opensips.cfg in:
#### STUN module
loadmodule "stun.so"
modparam ("stun", "primary_ip", "11.22.33.44") ip address #opensips server
modparam ("stun", "primary_port", "5060") # must opensips the same udp port (usually 5060)
modparam ("stun", "alternate_ip", "55.66.77.88") # ip address to another NIC
modparam ("stun", "alternate_port", "3479") # another port number
After configured stun, you can use the stun-client to test to the windows, for example, to test the command is:
stun-client-0-96.exe 11.22.33.44:5060 -v
Installation and Configuration RTPProxy module
rtpproxy module is typically used with nathelper module. First, make sure that the server has been installed rtpproxy, start rtpproxy:
rtpproxy -F
Then do the following configuration in opensips.cfg file:
loadmodule "rtpproxy.so"
modparam ("rtpproxy", "rtpproxy_sock", "unix: /var/run/rtpproxy.sock") # CUSTOMIZE ME
Installation and Configuration MediaProxy module
MediaProxy official documentation links
An installation MediaProxy2.5.2 in CentOS6 reference links .
Download mediaproxy source code (and various dependencies needed), and install (process omitted). After the installation is complete:
Copy the config.ini.sample to /etc/mediaproxy/config.ini, the tls directory is also copied.
echo 1> / proc / sys / net / ipv4 / ip_forward
media-dispatcher restart
media-relay restart
Configuring mediaproxy module opensips.cfg years, 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 prompt "No suitable relay found", may be the problem certification aspects. Reference Links
(Unfinished)
Crawl SIP package
Use tcpdump on Opensips where the server can grab SIP package to analyze a problem (note to crawl card is eth0 or eth1):
tcpdump -nqt -s 0 -A -i eth0 port 5060 -w /home/capture_file_name.pcap
Reference: http://jonathanmanning.com/2009/10/26/how-to-voip-sip-Capture-with-tcpdump-on-linux/
Grasp the package on the phone a little more complicated, first root the phone, and then copy to your phone using tcpdump:
adb shell
su
tcpdump -nqt -s 0 -w /sdcard/packets_xx.pcap
adb pull /sdcard/packets_xx.pcap
For details, please refer to this article .
Compressed package from the sourceforge download opensips-cp source code, which accompanied the document named INSTALL recommended for installation in accordance with this document, some information can be found online is often outdated or inaccurate.
yum install httpd php php-mysql php-xmlrpc php-pear
pear install MDB2
pear install MDB2 # mysql
pear install MDB2 # mysqli
pear install log
In /etc/php.ini in:
The short_open_tag set to On
The / usr / share / pear added inculde_path variable (some tutorials written plus / usr / share / php, the actual inspection to 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
The file unzipped folder (the name is generally "5.0") copied to the / var / www directory and renamed 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 other versions of linux, user name may be www-data, or other)
(With source code included with the installation documentation INSTALL little read, postgresql and mysql should be a second election.)
Install the necessary admin:
cd / var / www / opensips-cp / config / tools / admin / add_admin /
mysql -Dopensips -p <ocp_admin_privileges.mysql
mysql -uroot opensips into the mysql command line, execute the following command to add an administrator user:
INSERT INTO ocp_admin_privileges (username, password, ha1, available_tools, permissions) values ('admin', 'admin', md5 ('admin: admin'), 'all', 'all');
Installation 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 your database connection information)
Note, generate-cdrs_mysql.sh in this file "call opensips_cdrs_1_6 ()" may have to be changed to "call opensips_cdrs ()", the name must be consistent with the opensips_cdrs.mysql in the definition.
vi / etc / crontab (add timing tasks, such as once every third of the clock: * / 3 * * * * root /var/www/opensips-cp/cron_job/generate-cdrs_mysql.sh)
Installation smonitor:
cd / var / www / opensips-cp / config / tools / system / smonitor / (INSTALL document has a typo here, here has been corrected)
mysql -Dopensips -p <tables.mysql
vi / etc / crontab (add timing tasks, such as once per minute: * * * * * root php /var/www/opensips-cp/cron_job/get_opensips_stats.php> / dev / null)
Installation add_user:
(Front has been installed over the ocp_admin_privileges.mysql, there should be no need to do it again, a lot of small problems INSTALL document)
Start opensips-cp:
service mysqld start
service httpd start
Open a browser to access http://xxx.xxx.xxx.xxx/cp/ should see the login screen, admin user logs in with a previously created.
To be continued ..
Best practices for SIP NAT traversal
Stay connected to the server: Use nat_traversal or nathelper module (based on discussion groups where some posts, features two modules are almost identical), so opensips each period of time to send a packet to the client, making the port mapping on the router will remain (ie, the hole remains open). When the client should be able to see these sip capture packets from the server, usually the name of OPTIONS.
After the client receives no INVITE command RING: very strange question, but I am here from time to time occur, the client program for Boghe v2.0.153.836, yet did not find the causes and solutions.
Routers modify SIP package: use Volans VE602W as a router, REGISTER bag sent from the client Via field will be adapted to the public network address, resulting in opensips server determines whether from within the network (nat_traversal module nat_client_test method) fails, the other three routers (TPLink, Mercury and Buffalo does not happen). No find a solution. Here there is a similar problem.
Client receives duplicate OPTIONS message: due to repeated login to opensips (through different routers), Opensips sometimes send multiple OPTIONS contracted clients until the server assumes that the client has dropped. If the client Contact field REGISTER message to add the expires = xxx, the server will record the client time to failure in location table, if this time is very long, the server will always try to connect to the client.
Sometimes there is no video screen after turning: encountered such a problem: call ten times, every time is turned on, but sometimes there is no screen. Later found to be a server firewall banned some ports (with iptables --list INPUT inquiry found that the server allows only udp 35000 ~ 50000 to enter). The workaround is to specify the port range starts rtpproxy, for example rtpproxy -m 40000 -M 50000 -F.
Contact URI field is not changed public IP: by increasing the debug information found that although fix_nated_contact () method has been called, but the server sends back a sip bag Contact URI in the internal network address and has not been replaced with a public address. The company does not have this problem at home have this problem (replacement router is invalid), temporarily did not find the reason. (Correction: The question itself is wrong, it should be observed 200OK messages returned from the server, rather than the server receives the original message)
One-way voice / video or audio only able to dial: SIP packet length may be beyond the MTU value of network equipment under the UDP protocol, if the client can not handle long SIP package (generally those with the SDP SIP message, the SIP message and generate a video request to be larger than the audio request), the excess portion may be discarded, causing the server to transmit / receive a SIP packet failure. Solution: 1) switch to the TCP protocol; 2) streamlining the SIP packet size, some clients generated SIP package with unnecessary fields can be deleted (if we can custom develop it), there is an additional reference links ; 3 ) supports long UDP packet is relatively small package or SIP client (I use the boghe based doubango do this part is not very good , for use after x-lite find many small same request SIP packet length: 18xx vs 10xx ).
Clear Online users: Use opensipsctl ul rm id can delete an online user, will cause duplicate records within a user when multiple logins period of time, then may need to clear out the online status of the user.