Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
migration:kamailio-3.0-config [2009/05/14 14:27] 189.35.200.120 |
migration:kamailio-3.0-config [2009/11/27 16:27] (current) 188.27.169.22 |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Kamailio 3.0 Config ====== | ====== Kamailio 3.0 Config ====== | ||
- | This page provides guidelines to get the default config file of Kamailio 1.5.x working with SIP Router core. | ||
- | Functionalities: | + | Updated tutorial using the **kamailio_3.0** branch is available at: |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | * NAT traversal | + | |
- | * Presence server | + | |
- | [b]IMPORTANT: | + | http://www.kamailio.org/dokuwiki/doku.php/install:kamailio-3.0.x-from-git |
- | ===== 1. Install from GIT ===== | ||
- | |||
- | <hi # | ||
- | |||
- | The steps here are given for Unbuntu/ | ||
- | |||
- | ==== 1.1. Prerequisites ==== | ||
- | |||
- | To be able to follow the guidelines from this document you need **root** access. | ||
- | |||
- | The following packages are required before proceeding to the next steps. | ||
- | |||
- | * __git__ client: apt-get install git-core - it is recommended to have the latest version, which might not be part of the distribution yet, but you can get it from: http:// | ||
- | |||
- | * __gcc__ compiler: apt-get install gcc | ||
- | |||
- | * __flex__ - apt-get install flex | ||
- | |||
- | * __bison__ - apt-get install bison | ||
- | |||
- | * __libmysqlclient15-dev__ - apt-get install libmysqlclient15-dev | ||
- | |||
- | * __make__ - apt-get install make | ||
- | |||
- | ==== 1.2. Getting sources from GIT ==== | ||
- | |||
- | |||
- | First of all, you have to create a directory on the file system where the sources will be stored. | ||
- | |||
- | < | ||
- | mkdir -p / | ||
- | | ||
- | cd / | ||
- | </ | ||
- | |||
- | Download the sources from GIT using the following command. | ||
- | |||
- | < | ||
- | git clone --depth 1 git:// | ||
- | </ | ||
- | |||
- | |||
- | ==== 1.3.Tuning Makefiles ==== | ||
- | |||
- | Next step is to edit Makefile files to include the MySQL module. | ||
- | < | ||
- | cd sip-router | ||
- | | ||
- | vim Makefile | ||
- | </ | ||
- | |||
- | Remove **db_mysql** from **exclude_modules** variable. | ||
- | |||
- | Note: if you need PCRE-dependent modules (e.g., lcr, dialplan, regexp), instal the PCRE devel library and uncomment | ||
- | |||
- | |||
- | ==== 1.4. Compile SIP Router ==== | ||
- | |||
- | Once the mysql module was removed from excluded modules list, you can compile: | ||
- | |||
- | < | ||
- | make all | ||
- | </ | ||
- | |||
- | |||
- | ==== 1.5. Install SIP Router ==== | ||
- | |||
- | When the compilation is ready, install with the following command: | ||
- | |||
- | make install | ||
- | |||
- | ==== 1.6. What and where was installed ==== | ||
- | |||
- | The binaries and executable scripts were installed in: | ||
- | |||
- | < | ||
- | / | ||
- | </ | ||
- | |||
- | These are: | ||
- | |||
- | * __ser__ - SIP Router binary | ||
- | |||
- | |||
- | To be able to use the binaries from command line, make sure that '/ | ||
- | |||
- | PATH=$PATH:/ | ||
- | export PATH | ||
- | |||
- | SIP Router modules are installed in: | ||
- | |||
- | / | ||
- | |||
- | The documentation and readme files are installed in: | ||
- | |||
- | / | ||
- | |||
- | The man pages are installed in: | ||
- | |||
- | / | ||
- | / | ||
- | |||
- | The configuration file was installed in: | ||
- | |||
- | / | ||
- | |||
- | However, this configuration file is not the one used by Kamailio (OpenSER) 1.5.x. Section 2 includes it. | ||
- | |||
- | |||
- | ===== 2. Kamailio Config File ===== | ||
- | |||
- | * this is the configuration file from Kamailio (OpenSER) 1.5.x adapted for the development version based on SIP-Router.org project | ||
- | * it has turned on most of the features that are by default commented (authentication, | ||
- | * copy it and paste into **/ | ||
- | |||
- | **Remarks**: | ||
- | * it runs in debug mode, level 5 | ||
- | * only udp, tcp is disabled | ||
- | * one child | ||
- | |||
- | < | ||
- | # | ||
- | # $Id: kamailio.cfg 5679 2009-03-10 09:22:27Z ibc_sf $ | ||
- | # | ||
- | # Kamailio (OpenSER) SIP Server - basic configuration script | ||
- | # - web: http:// | ||
- | # - svn: http:// | ||
- | # | ||
- | # Direct your questions about this file to: < | ||
- | # | ||
- | # Refer to the Core CookBook at http:// | ||
- | # for an explanation of possible statements, functions and parameters. | ||
- | # | ||
- | # There are comments showing how to enable different features in th econfig | ||
- | # file. Such commented code starts with #X# where X is a letter to identify | ||
- | # a feature. Delete entire #X# if you want to enable that feature. Next are | ||
- | # sed commands that help you enable such features. | ||
- | # | ||
- | # *** To enable mysql execute: | ||
- | # sed -i ' | ||
- | # | ||
- | # *** To enable authentication execute: | ||
- | # - enable mysql | ||
- | # sed -i ' | ||
- | # - add users using ' | ||
- | # | ||
- | # *** To enable persistent user location execute: | ||
- | # - enable mysql | ||
- | # sed -i ' | ||
- | # | ||
- | # *** To enable presence server execute: | ||
- | # - enable mysql | ||
- | # sed -i ' | ||
- | # | ||
- | # *** To enable nat traversal execute: | ||
- | # sed -i ' | ||
- | # - install RTPProxy: http:// | ||
- | # - start RTPProxy: | ||
- | # rtpproxy -l _your_public_ip_ -s udp: | ||
- | # | ||
- | # *** To enhance accounting execute: | ||
- | # - enable mysql | ||
- | # sed -i ' | ||
- | # - add following columns to database | ||
- | # ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE missed_call ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT ''; | ||
- | # ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT ''; | ||
- | # | ||
- | |||
- | |||
- | ####### Global Parameters ######### | ||
- | |||
- | debug=4 | ||
- | memdbg=5 | ||
- | memlog=5 | ||
- | log_stderror=yes | ||
- | log_facility=LOG_LOCAL0 | ||
- | |||
- | fork=yes | ||
- | children=1 | ||
- | |||
- | /* uncomment the following lines to enable debugging */ | ||
- | #debug=6 | ||
- | #fork=no | ||
- | # | ||
- | |||
- | /* uncomment the next line to disable TCP (default on) */ | ||
- | disable_tcp=yes | ||
- | |||
- | /* uncomment the next line to enable the auto temporary blacklisting of | ||
- | not available destinations (default disabled) */ | ||
- | # | ||
- | |||
- | /* uncomment the next line to enable IPv6 lookup after IPv4 dns | ||
- | | ||
- | # | ||
- | |||
- | /* uncomment the next line to disable the auto discovery of local aliases | ||
- | based on revers DNS on IPs (default on) */ | ||
- | auto_aliases=no | ||
- | |||
- | /* uncomment the following lines to enable TLS support | ||
- | # | ||
- | #listen = tls: | ||
- | # | ||
- | # | ||
- | # | ||
- | #tls_method = TLSv1 | ||
- | # | ||
- | # | ||
- | # | ||
- | |||
- | |||
- | listen=udp: | ||
- | |||
- | /* uncomment and configure the following line if you want Kamailio to | ||
- | bind on a specific interface/ | ||
- | # | ||
- | |||
- | |||
- | ####### Modules Section ######## | ||
- | |||
- | #set module path | ||
- | loadpath " | ||
- | |||
- | /* uncomment next line for MySQL DB support */ | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | /* uncomment next lines for MySQL based authentication support | ||
- | NOTE: a DB (like db_mysql) module must be also loaded */ | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | /* uncomment next line for aliases support | ||
- | NOTE: a DB (like db_mysql) module must be also loaded */ | ||
- | #loadmodule " | ||
- | /* uncomment next line for multi-domain support | ||
- | NOTE: a DB (like db_mysql) module must be also loaded | ||
- | NOTE: be sure and enable multi-domain support in all used modules | ||
- | (see " | ||
- | #loadmodule " | ||
- | /* uncomment the next two lines for presence server support | ||
- | NOTE: a DB (like db_mysql) module must be also loaded */ | ||
- | loadmodule " | ||
- | loadmodule " | ||
- | |||
- | loadmodule " | ||
- | |||
- | # ----------------- setting module-specific parameters --------------- | ||
- | |||
- | |||
- | # ----- mi_fifo params ----- | ||
- | modparam(" | ||
- | |||
- | |||
- | # ----- mi_datagram params ----- | ||
- | modparam(" | ||
- | |||
- | |||
- | # ----- rr params ----- | ||
- | # add value to ;lr param to cope with most of the UAs | ||
- | modparam(" | ||
- | # do not append from tag to the RR (no need for this script) | ||
- | modparam(" | ||
- | |||
- | |||
- | # ----- rr params ----- | ||
- | modparam(" | ||
- | /* uncomment the next line to disable parallel forking via location */ | ||
- | # modparam(" | ||
- | /* uncomment the next line not to allow more than 10 contacts per AOR */ | ||
- | # | ||
- | |||
- | |||
- | # ----- uri_db params ----- | ||
- | /* by default we disable the DB support in the module as we do not need it | ||
- | in this configuration */ | ||
- | modparam(" | ||
- | modparam(" | ||
- | |||
- | |||
- | # ----- acc params ----- | ||
- | /* what sepcial events should be accounted ? */ | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | /* by default ww do not adjust the direct of the sequential requests. | ||
- | if you enable this parameter, be sure the enable " | ||
- | in " | ||
- | modparam(" | ||
- | /* account triggers (flags) */ | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | " | ||
- | /* uncomment the following lines to enable DB accounting also */ | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | " | ||
- | modparam(" | ||
- | " | ||
- | |||
- | |||
- | # ----- usrloc params ----- | ||
- | /* uncomment the following lines if you want to enable DB persistency | ||
- | for location entries */ | ||
- | modparam(" | ||
- | modparam(" | ||
- | " | ||
- | |||
- | # ----- auth_db params ----- | ||
- | /* uncomment the following lines if you want to enable the DB based | ||
- | | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | " | ||
- | modparam(" | ||
- | |||
- | |||
- | # ----- alias_db params ----- | ||
- | /* uncomment the following lines if you want to enable the DB based | ||
- | | ||
- | # | ||
- | # | ||
- | |||
- | |||
- | # ----- domain params ----- | ||
- | /* uncomment the following lines to enable multi-domain detection | ||
- | | ||
- | # | ||
- | # | ||
- | # | ||
- | |||
- | |||
- | # ----- multi-module params ----- | ||
- | /* uncomment the following line if you want to enable multi-domain support | ||
- | in the modules (dafault off) */ | ||
- | # | ||
- | |||
- | |||
- | # ----- presence params ----- | ||
- | /* uncomment the following lines if you want to enable presence */ | ||
- | modparam(" | ||
- | " | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | |||
- | # -- nathelper | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | modparam(" | ||
- | |||
- | #extra testing | ||
- | modparam(" | ||
- | |||
- | ####### Routing Logic ######## | ||
- | |||
- | |||
- | # main request routing logic | ||
- | |||
- | route{ | ||
- | |||
- | if (!mf_process_maxfwd_header(" | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | |||
- | $avp(test) = 1; | ||
- | |||
- | # NAT detection | ||
- | route(4); | ||
- | |||
- | if (has_totag()) { | ||
- | # sequential request withing a dialog should | ||
- | # take the path determined by record-routing | ||
- | if (loose_route()) { | ||
- | if (is_method(" | ||
- | setflag(1); | ||
- | setflag(3); | ||
- | } | ||
- | route(1); | ||
- | } else { | ||
- | if (is_method(" | ||
- | # in-dialog subscribe requests | ||
- | route(2); | ||
- | exit; | ||
- | } | ||
- | if ( is_method(" | ||
- | if ( t_check_trans() ) { | ||
- | # non loose-route, | ||
- | t_relay(); | ||
- | exit; | ||
- | } else { | ||
- | # ACK without matching transaction ... ignore and discard.\n" | ||
- | exit; | ||
- | } | ||
- | } | ||
- | sl_send_reply(" | ||
- | } | ||
- | exit; | ||
- | } | ||
- | |||
- | #initial requests | ||
- | |||
- | # CANCEL processing | ||
- | if (is_method(" | ||
- | { | ||
- | if (t_check_trans()) | ||
- | t_relay(); | ||
- | exit; | ||
- | } | ||
- | |||
- | t_check_trans(); | ||
- | |||
- | # authentication | ||
- | route(3); | ||
- | |||
- | # record routing for dialog forming requests (in case they are routed) | ||
- | if (is_method(" | ||
- | record_route(); | ||
- | |||
- | # account only INVITEs | ||
- | if (is_method(" | ||
- | setflag(1); | ||
- | } | ||
- | if (!uri==myself) | ||
- | /* replace with following line if multi-domain support is used */ | ||
- | ##if (!is_uri_host_local()) | ||
- | { | ||
- | append_hf(" | ||
- | # if you have some interdomain connections via TLS | ||
- | ## | ||
- | ## | ||
- | ## exit; | ||
- | ##} else if($rd==" | ||
- | ## | ||
- | ## exit; | ||
- | ##} | ||
- | route(1); | ||
- | } | ||
- | |||
- | # requests for my domain | ||
- | |||
- | if( is_method(" | ||
- | route(2); | ||
- | } | ||
- | |||
- | if (is_method(" | ||
- | { | ||
- | if (!save(" | ||
- | sl_reply_error(); | ||
- | |||
- | exit; | ||
- | } | ||
- | |||
- | if ($rU=="" | ||
- | # request with no Username in RURI | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | |||
- | # apply DB based aliases (uncomment to enable) | ||
- | ## | ||
- | |||
- | if (!lookup(" | ||
- | switch ($rc) { | ||
- | case -1: | ||
- | case -3: | ||
- | t_newtran(); | ||
- | t_reply(" | ||
- | exit; | ||
- | case -2: | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | } | ||
- | |||
- | # when routing via usrloc, log the missed calls also | ||
- | setflag(2); | ||
- | |||
- | route(1); | ||
- | } | ||
- | |||
- | |||
- | route[1] { | ||
- | if (check_route_param(" | ||
- | setbflag(" | ||
- | } | ||
- | if (isflagset(5) || isbflagset(" | ||
- | route(5); | ||
- | } | ||
- | |||
- | /* example how to enable some additional event routes */ | ||
- | if (is_method(" | ||
- | # | ||
- | t_on_reply(" | ||
- | t_on_failure(" | ||
- | } | ||
- | |||
- | if (!t_relay()) { | ||
- | sl_reply_error(); | ||
- | } | ||
- | exit; | ||
- | } | ||
- | |||
- | |||
- | # Presence route | ||
- | /* uncomment the whole following route for enabling presence server */ | ||
- | route[2] | ||
- | { | ||
- | if (!t_newtran()) | ||
- | { | ||
- | sl_reply_error(); | ||
- | exit; | ||
- | }; | ||
- | |||
- | if(is_method(" | ||
- | { | ||
- | handle_publish(); | ||
- | t_release(); | ||
- | } | ||
- | else | ||
- | if( is_method(" | ||
- | { | ||
- | handle_subscribe(); | ||
- | t_release(); | ||
- | } | ||
- | exit; | ||
- | |||
- | # if presence enabled, this part will not be executed | ||
- | if (is_method(" | ||
- | { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | return; | ||
- | } | ||
- | |||
- | # Authentication route | ||
- | /* uncomment the whole following route for enabling authentication */ | ||
- | route[3] { | ||
- | if (is_method(" | ||
- | { | ||
- | # authenticate the REGISTER requests (uncomment to enable auth) | ||
- | if (! (www_authorize("", | ||
- | { | ||
- | www_challenge("", | ||
- | exit; | ||
- | } | ||
- | |||
- | if ($au!=$tU) | ||
- | { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | } else { | ||
- | # authenticate if from local subscriber (uncomment to enable auth) | ||
- | if (from_uri==myself) | ||
- | { | ||
- | if (!proxy_authorize("", | ||
- | proxy_challenge("", | ||
- | exit; | ||
- | } | ||
- | if (is_method(" | ||
- | { | ||
- | if ($au!=$tU) { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | } else { | ||
- | if ($au!=$fU) { | ||
- | sl_send_reply(" | ||
- | exit; | ||
- | } | ||
- | } | ||
- | |||
- | consume_credentials(); | ||
- | # caller authenticated | ||
- | } | ||
- | } | ||
- | return; | ||
- | } | ||
- | |||
- | # Caller NAT detection route | ||
- | /* uncomment the whole following route for enabling Caller NAT Detection */ | ||
- | route[4]{ | ||
- | force_rport(); | ||
- | if (nat_uac_test(" | ||
- | if (method==" | ||
- | fix_nated_register(); | ||
- | } else { | ||
- | fix_nated_contact(); | ||
- | } | ||
- | setflag(5); | ||
- | } | ||
- | return; | ||
- | } | ||
- | |||
- | # RTPProxy control | ||
- | /* uncomment the whole following route for enabling RTPProxy Control */ | ||
- | route[5] { | ||
- | if (is_method(" | ||
- | unforce_rtp_proxy(); | ||
- | } else if (is_method(" | ||
- | force_rtp_proxy(); | ||
- | } | ||
- | if (!has_totag()) add_rr_param("; | ||
- | return; | ||
- | } | ||
- | |||
- | branch_route[1] { | ||
- | xdbg(" | ||
- | } | ||
- | |||
- | |||
- | onreply_route[1] { | ||
- | xdbg(" | ||
- | |||
- | if ((isflagset(5) || isbflagset(" | ||
- | force_rtp_proxy(); | ||
- | } | ||
- | if (isbflagset(" | ||
- | fix_nated_contact(); | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | failure_route[1] { | ||
- | if (is_method(" | ||
- | && | ||
- | unforce_rtp_proxy(); | ||
- | } | ||
- | |||
- | if (t_is_canceled()) { | ||
- | exit; | ||
- | } | ||
- | |||
- | # uncomment the following lines if you want to block client | ||
- | # redirect based on 3xx replies. | ||
- | ##if (t_check_status(" | ||
- | ## | ||
- | ## exit; | ||
- | ##} | ||
- | |||
- | # uncomment the following lines if you want to redirect the failed | ||
- | # calls to a different new destination | ||
- | ##if (t_check_status(" | ||
- | ## | ||
- | ## | ||
- | ## # do not set the missed call flag again | ||
- | ## | ||
- | ##} | ||
- | } | ||
- | |||
- | </ | ||
- | |||
- | ===== 3. Run it ===== | ||
- | |||
- | You must have the database used by Kamailio (OpenSER) 1.5.x created. The name of the database is **openser**. If you installed Kamailio (OpenSER) 1.5.x from SVN using the Dokuwiki guidelines (http:// | ||
- | |||
- | < | ||
- | / | ||
- | </ | ||
- | |||
- | Start SIP Router with the config above: | ||
- | |||
- | < | ||
- | / | ||
- | </ | ||
- | |||
- | ===== 4. Remarks ===== | ||
- | |||
- | <hi # | ||
- | |||
- | * load kex module for Kamailio core specific extensions | ||
- | * load tmx module for Kamailio TM specific extensions | ||
- | * avp_aliases is now a parameter of pv module | ||
- | |||
- | ===== 5. FAQ ===== | ||
- | |||
- | * **Q**: Why binary is named ser? | ||
- | * **A**: It is the default name for SIP Router binary. In the future, the packaged version will differ from what is now. However, right now, it is the short of: "**SIP E Router**" | ||
- | * Exceptional | ||
- | * Excellent | ||
- | * Exotic (as Kamailio name origins) | ||
- | * Express (the initial project name) | ||
- | * Extraordinary | ||
- | * ... | ||