5.cfg 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. #
  2. # $Id$
  3. #
  4. # Kamailio basic configuration script
  5. # by Anca Vamanu <[email protected]>
  6. #
  7. # Please refer to the Core CookBook at https://www.kamailio.org/wikidocs/cookbooks/devel/core/
  8. # for an explanation of possible statements, functions and parameters.
  9. #
  10. ####### Global Parameters #########
  11. debug=3
  12. log_stderror=no
  13. log_facility=LOG_LOCAL0
  14. fork=yes
  15. children=4
  16. /* uncomment the following lines to enable debugging */
  17. #debug=6
  18. #fork=no
  19. #log_stderror=yes
  20. /* uncomment the next line to disable TCP (default on) */
  21. #disable_tcp=yes
  22. /* uncomment the next line to enable the auto temporary blocklisting of
  23. not available destinations (default disabled) */
  24. #disable_dns_blocklist=no
  25. /* uncomment the next line to enable IPv6 lookup after IPv4 dns
  26. lookup failures (default disabled) */
  27. #dns_try_ipv6=yes
  28. /* uncomment the next line to disable the auto discovery of local aliases
  29. based on revers DNS on IPs (default on) */
  30. #auto_aliases=no
  31. /* uncomment the following lines to enable TLS support (default off) */
  32. #disable_tls = no
  33. #listen = tls:your_IP:5061
  34. #tls_verify_server = 1
  35. #tls_verify_client = 1
  36. #tls_require_client_certificate = 0
  37. #tls_method = TLSv1
  38. #tls_certificate = "/usr/local/etc/kamailio/tls/user/user-cert.pem"
  39. #tls_private_key = "/usr/local/etc/kamailio/tls/user/user-privkey.pem"
  40. #tls_ca_list = "/usr/local/etc/kamailio/tls/user/user-calist.pem"
  41. port=5060
  42. /* uncomment and configure the following line if you want kamailio to
  43. bind on a specific interface/port/proto (default bind on all available) */
  44. #listen=udp:192.168.1.2:5060
  45. ####### Modules Section ########
  46. /* uncomment next line for MySQL DB support */
  47. #loadmodule "db_mysql.so"
  48. loadmodule "tm/tm.so"
  49. loadmodule "sl/sl.so"
  50. loadmodule "rr/rr.so"
  51. loadmodule "pv/pv.so"
  52. loadmodule "maxfwd/maxfwd.so"
  53. loadmodule "usrloc/usrloc.so"
  54. loadmodule "registrar/registrar.so"
  55. loadmodule "textops/textops.so"
  56. loadmodule "mi_fifo/mi_fifo.so"
  57. loadmodule "uri_db/uri_db.so"
  58. loadmodule "siputils/siputils.so"
  59. loadmodule "xlog/xlog.so"
  60. loadmodule "acc/acc.so"
  61. /* uncomment next lines for MySQL based authentication support
  62. NOTE: a DB (like db_mysql) module must be also loaded */
  63. #loadmodule "auth.so"
  64. #loadmodule "auth_db.so"
  65. /* uncomment next line for aliases support
  66. NOTE: a DB (like db_mysql) module must be also loaded */
  67. #loadmodule "alias_db.so"
  68. /* uncomment next line for multi-domain support
  69. NOTE: a DB (like db_mysql) module must be also loaded
  70. NOTE: be sure and enable multi-domain support in all used modules
  71. (see "multi-module params" section ) */
  72. #loadmodule "domain.so"
  73. /* uncomment the next two lines for presence server support
  74. NOTE: a DB (like db_mysql) module must be also loaded */
  75. #loadmodule "presence.so"
  76. #loadmodule "presence_xml.so"
  77. # ----------------- setting module-specific parameters ---------------
  78. # ----- mi_fifo params -----
  79. modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
  80. # ----- rr params -----
  81. # add value to ;lr param to cope with most of the UAs
  82. modparam("rr", "enable_full_lr", 1)
  83. # do not append from tag to the RR (no need for this script)
  84. modparam("rr", "append_fromtag", 0)
  85. # ----- rr params -----
  86. modparam("registrar", "method_filtering", 1)
  87. /* uncomment the next line to disable parallel forking via location */
  88. # modparam("registrar", "append_branches", 0)
  89. /* uncomment the next line not to allow more than 10 contacts per AOR */
  90. #modparam("registrar", "max_contacts", 10)
  91. # ----- uri_db params -----
  92. /* by default we disable the DB support in the module as we do not need it
  93. in this configuration */
  94. modparam("uri_db", "use_uri_table", 0)
  95. modparam("uri_db", "db_url", "")
  96. # ----- acc params -----
  97. /* what sepcial events should be accounted ? */
  98. modparam("acc", "early_media", 1)
  99. modparam("acc", "report_ack", 1)
  100. modparam("acc", "report_cancels", 1)
  101. /* by default we do not adjust the direct of the sequential requests.
  102. if you enable this parameter, be sure the enable "append_fromtag"
  103. in "rr" module */
  104. modparam("acc", "detect_direction", 0)
  105. /* account triggers (flags) */
  106. modparam("acc", "failed_transaction_flag", 3)
  107. modparam("acc", "log_flag", 1)
  108. modparam("acc", "log_missed_flag", 2)
  109. /* uncomment the following lines to enable DB accounting also */
  110. modparam("acc", "db_flag", 1)
  111. modparam("acc", "db_missed_flag", 2)
  112. # ----- usrloc params -----
  113. modparam("usrloc", "db_mode", 0)
  114. /* uncomment the following lines if you want to enable DB persistency
  115. for location entries */
  116. #modparam("usrloc", "db_mode", 2)
  117. #modparam("usrloc", "db_url",
  118. # "mysql://kamailio:[email protected]/kamailio_1_3")
  119. # ----- auth_db params -----
  120. /* uncomment the following lines if you want to enable the DB based
  121. authentication */
  122. #modparam("auth_db", "calculate_ha1", yes)
  123. #modparam("auth_db", "password_column", "password")
  124. #modparam("auth_db", "db_url",
  125. # "mysql://kamailio:[email protected]/kamailio_1_3")
  126. #modparam("auth_db", "load_credentials", "")
  127. # ----- alias_db params -----
  128. /* uncomment the following lines if you want to enable the DB based
  129. aliases */
  130. #modparam("alias_db", "db_url",
  131. # "mysql://kamailio:[email protected]/kamailio_1_3")
  132. # ----- domain params -----
  133. /* uncomment the following lines to enable multi-domain detection
  134. support */
  135. #modparam("domain", "db_url",
  136. # "mysql://kamailio:[email protected]/kamailio_1_3")
  137. #modparam("domain", "db_mode", 1) # Use caching
  138. # ----- multi-module params -----
  139. /* uncomment the following line if you want to enable multi-domain support
  140. in the modules (dafault off) */
  141. #modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)
  142. # ----- presence params -----
  143. /* uncomment the following lines if you want to enable presence */
  144. #modparam("presence|presence_xml", "db_url",
  145. # "mysql://kamailio:[email protected]/kamailio_1_3")
  146. #modparam("presence_xml", "force_active", 1)
  147. #modparam("presence", "server_address", "sip:192.168.1.2:5060")
  148. ####### Routing Logic ########
  149. # main request routing logic
  150. route{
  151. if (!mf_process_maxfwd_header("10")) {
  152. sl_send_reply("483", "Too Many Hops");
  153. exit;
  154. }
  155. if (has_totag()) {
  156. # sequential request within a dialog should
  157. # take the path determined by record-routing
  158. if (loose_route()) {
  159. if (is_method("BYE")) {
  160. setflag(1); # do accounting ...
  161. setflag(3); # ... even if the transaction fails
  162. }
  163. route(1);
  164. } else {
  165. /* uncomment the following lines if you want to enable presence */
  166. ##if (is_method("SUBSCRIBE") && $rd == "your.server.ip.address") {
  167. ## # in-dialog subscribe requests
  168. ## route(2);
  169. ## exit;
  170. ##}
  171. if ( is_method("ACK") ) {
  172. if ( t_check_trans() ) {
  173. # non loose-route, but stateful ACK; must be an ACK after a 487 or e.g. 404 from upstream server
  174. t_relay();
  175. exit;
  176. } else {
  177. # ACK without matching transaction ... ignore and discard.\n");
  178. exit;
  179. }
  180. }
  181. sl_send_reply("404", "Not here");
  182. }
  183. exit;
  184. }
  185. #initial requests
  186. # CANCEL processing
  187. if (is_method("CANCEL"))
  188. {
  189. if (t_check_trans())
  190. t_relay();
  191. exit;
  192. }
  193. t_check_trans();
  194. # authenticate if from local subscriber (uncomment to enable auth)
  195. ##if (!(method=="REGISTER") && from_uri==myself)
  196. ##{
  197. ## if (!proxy_authorize("", "subscriber")) {
  198. ## proxy_challenge("", "0");
  199. ## exit;
  200. ## }
  201. ## if (!check_from()) {
  202. ## sl_send_reply("403", "Forbidden auth ID");
  203. ## exit;
  204. ## }
  205. ##
  206. ## consume_credentials();
  207. ## # caller authenticated
  208. ##}
  209. # record routing
  210. if (!is_method("REGISTER|MESSAGE"))
  211. record_route();
  212. # account only INVITEs
  213. if (is_method("INVITE")) {
  214. setflag(1); # do accounting
  215. }
  216. if (!uri==myself)
  217. /* replace with following line if multi-domain support is used */
  218. ##if (!is_uri_host_local())
  219. {
  220. append_hf("P-hint: outbound\r\n");
  221. # if you have some interdomain connections via TLS
  222. ##if($rd=="tls_domain1.net") {
  223. ## t_relay("tls:domain1.net");
  224. ## exit;
  225. ##} else if($rd=="tls_domain2.net") {
  226. ## t_relay("tls:domain2.net");
  227. ## exit;
  228. ##}
  229. route(1);
  230. }
  231. # requests for my domain
  232. /* uncomment this if you want to enable presence server
  233. and comment the next 'if' block
  234. NOTE: uncomment also the definition of route[2] from below */
  235. ##if( is_method("PUBLISH|SUBSCRIBE"))
  236. ## route(2);
  237. if (is_method("PUBLISH"))
  238. {
  239. sl_send_reply("503", "Service Unavailable");
  240. exit;
  241. }
  242. if (is_method("REGISTER"))
  243. {
  244. # authenticate the REGISTER requests (uncomment to enable auth)
  245. ##if (!www_authorize("", "subscriber"))
  246. ##{
  247. ## www_challenge("", "0");
  248. ## exit;
  249. ##}
  250. ##
  251. ##if (!check_to())
  252. ##{
  253. ## sl_send_reply("403", "Forbidden auth ID");
  254. ## exit;
  255. ##}
  256. if (!save("location"))
  257. sl_reply_error();
  258. exit;
  259. }
  260. if ($rU==NULL) {
  261. # request with no Username in RURI
  262. sl_send_reply("484", "Address Incomplete");
  263. exit;
  264. }
  265. # apply DB based aliases (uncomment to enable)
  266. ##alias_db_lookup("dbaliases");
  267. if (!lookup("location")) {
  268. switch ($retcode) {
  269. case -1:
  270. case -3:
  271. t_newtran();
  272. t_reply("404", "Not Found");
  273. exit;
  274. case -2:
  275. sl_send_reply("405", "Method Not Allowed");
  276. exit;
  277. }
  278. }
  279. # when routing via usrloc, log the missed calls also
  280. setflag(2);
  281. route(1);
  282. }
  283. route[1] {
  284. # for INVITEs enable some additional helper routes
  285. if (is_method("INVITE")) {
  286. t_on_branch("2");
  287. t_on_reply("2");
  288. t_on_failure("1");
  289. }
  290. if (!t_relay()) {
  291. sl_reply_error();
  292. };
  293. exit;
  294. }
  295. # Presence route
  296. /* uncomment the whole following route for enabling presence
  297. NOTE: do not forget to enable the call of this route from the main
  298. route */
  299. ##route[2]
  300. ##{
  301. ## if (!t_newtran())
  302. ## {
  303. ## sl_reply_error();
  304. ## exit;
  305. ## };
  306. ##
  307. ## if(is_method("PUBLISH"))
  308. ## {
  309. ## handle_publish();
  310. ## t_release();
  311. ## }
  312. ## else
  313. ## if( is_method("SUBSCRIBE"))
  314. ## {
  315. ## handle_subscribe();
  316. ## t_release();
  317. ## }
  318. ##
  319. ## exit;
  320. ##}
  321. branch_route[2] {
  322. xlog("new branch at $ru\n");
  323. }
  324. onreply_route[2] {
  325. xlog("incoming reply\n");
  326. }
  327. failure_route[1] {
  328. if (t_was_cancelled()) {
  329. exit;
  330. }
  331. # uncomment the following lines if you want to block client
  332. # redirect based on 3xx replies.
  333. ##if (t_check_status("3[0-9][0-9]")) {
  334. ##t_reply("404", "Not found");
  335. ## exit;
  336. ##}
  337. # uncomment the following lines if you want to redirect the failed
  338. # calls to a different new destination
  339. ##if (t_check_status("486|408")) {
  340. ## sethostport("192.168.2.100:5060");
  341. ## append_branch();
  342. ## # do not set the missed call flag again
  343. ## t_relay();
  344. ##}
  345. }