Advertisement
Guest User

kamailio config

a guest
Nov 11th, 2014
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.17 KB | None | 0 0
  1. 200 OK response
  2. .........................................
  3.  
  4.  
  5. SIP/2.0 200 OK
  6. To: <sip:[email protected]>;tag=52642973_6772d868_f5ff7ec8-2860-4963-894d-4686de291299
  7. Via: SIP/2.0/UDP 54.69.159.69:5060;branch=z9hG4bKcdde.3a10daa4c4dfb45218165e7003bc1925.0
  8. Via: SIP/2.0/UDP 64.2.142.90;branch=z9hG4bKcdde.0da1e6a5.0
  9. Via: SIP/2.0/UDP 64.2.142.153:5060;received=64.2.142.153;branch=z9hG4bK0c18e9b5;rport=5060
  10. Record-Route: <sip:107.21.211.20:5060;lr;ftag=as0b111d7b>
  11. Record-Route: <sip:54.69.159.69:5060;lr=on>
  12. Record-Route: <sip:64.2.142.90;lr=on>
  13. CSeq: 102 INVITE
  14. From: "+14088271419" <sip:[email protected]>;tag=as0b111d7b
  15. Contact: <sip:10.108.170.11:5060>
  16. Content-Type: application/sdp
  17. X-Twilio-CallSid: CA2d519006d553f3acf89f1dd2fef77cc3
  18. Content-Length: 247
  19.  
  20. v=0
  21. o=- 1132985615 1132985615 IN IP4 54.82.64.195
  22. s=session
  23. c=IN IP4 54.82.64.195
  24. t=0 0
  25. m=audio 13800 RTP/AVP 0 101
  26. a=rtpmap:0 PCMU/8000
  27. a=rtpmap:101 telephone-event/8000
  28. a=fmtp:101 0-16
  29. a=silenceSupp:off - - - -
  30. a=ptime:20
  31. a=sendrecv
  32.  
  33.  
  34. ACK forwarded to twilio
  35. ................................
  36.  
  37.  
  38. E@d
  39. kCACK sip:107.21.211.20:5060;lr;ftag=as0b111d7b SIP/2.0
  40. Via: SIP/2.0/UDP 54.69.159.69:5060;branch=z9hG4bKcdde.95210bf832aa38aeeccc727ba583b66f.0
  41. Via: SIP/2.0/UDP 54.69.159.69:5060;branch=z9hG4bKcdde.0a606545da03734a8b332edc9b21079f.0
  42. Via: SIP/2.0/UDP 64.2.142.90;branch=z9hG4bKcdde.0da1e6a5.2
  43. Via: SIP/2.0/UDP 64.2.142.153:5060;received=64.2.142.153;branch=z9hG4bK32a73a53;rport=5060
  44. From: "+14088271419" <sip:[email protected]>;tag=as0b111d7b
  45. To: <sip:[email protected]:5060>;tag=52642973_6772d868_f5ff7ec8-2860-4963-894d-4686de291299
  46. Contact: <sip:[email protected]>
  47. CSeq: 102 ACK
  48. User-Agent: packetrino
  49. Max-Forwards: 67
  50. Content-Length: 0
  51.  
  52.  
  53. this is my config file.(ip and account names are changed)
  54. .............................................................
  55.  
  56.  
  57.  
  58. #!KAMAILIO
  59. #
  60. # sample config file for dispatcher module
  61. # - load balancing of VoIP calls with round robin
  62. # - no TPC listening
  63. # - don't dispatch REGISTER and presence requests
  64. # Direct your questions about this file to: [email protected]
  65. #
  66. #
  67. # *** To run in debug mode:
  68. # - define WITH_DEBUG
  69. #
  70.  
  71. #!ifndef DBURL
  72. #!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
  73. #!endif
  74.  
  75. ####### Global Parameters #########
  76.  
  77. #!ifdef WITH_DEBUG
  78. debug=4
  79. log_stderror=yes
  80. #!else
  81. debug=2
  82. log_stderror=no
  83. #!endif
  84.  
  85. memdbg=5
  86. memlog=5
  87.  
  88. log_facility=LOG_LOCAL0
  89.  
  90. fork=yes
  91. children=4
  92.  
  93. /* comment the next line to enable TCP */
  94. disable_tcp=yes
  95.  
  96. /* uncomment the next line to disable the auto discovery of local aliases
  97. based on revers DNS on IPs (default on) */
  98. auto_aliases=no
  99.  
  100. /* add local domain aliases */
  101.  
  102. alias="54.69.159.69"
  103.  
  104. port=5060
  105.  
  106. /* uncomment and configure the following line if you want Kamailio to
  107. bind on a specific interface/port/proto (default bind on all available) */
  108. listen=udp:172.31.22.10:5060 advertise 54.69.159.69:5060
  109. #advertised_address="54.69.159.69"
  110. #advertised_port=5060
  111. sip_warning=no
  112.  
  113. ####### Modules Section ########
  114.  
  115. #set module path
  116. mpath="/usr/local/lib64/kamailio/modules_k/:/usr/local/lib64/kamailio/modules/"
  117.  
  118. loadmodule "db_mysql.so"
  119. loadmodule "mi_fifo.so"
  120. loadmodule "kex.so"
  121. loadmodule "tm.so"
  122. loadmodule "tmx.so"
  123. loadmodule "sl.so"
  124. loadmodule "rr.so"
  125. loadmodule "pv.so"
  126. loadmodule "maxfwd.so"
  127. loadmodule "textops.so"
  128. loadmodule "siputils.so"
  129. loadmodule "xlog.so"
  130. loadmodule "sanity.so"
  131. loadmodule "ctl.so"
  132. loadmodule "mi_rpc.so"
  133. loadmodule "acc.so"
  134. loadmodule "dispatcher.so"
  135. loadmodule "pdt.so"
  136. loadmodule "nathelper.so"
  137. loadmodule "avpops.so"
  138. loadmodule "htable.so"
  139.  
  140. # ----------------- setting module-specific parameters ---------------
  141.  
  142.  
  143. # ----- mi_fifo params -----
  144. modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
  145.  
  146.  
  147. # ----- rr params -----
  148. # add value to ;lr param to cope with most of the UAs
  149. modparam("rr", "enable_full_lr", 1)
  150. # do not append from tag to the RR (no need for this script)
  151. modparam("rr", "append_fromtag", 0)
  152.  
  153.  
  154. # ----- acc params -----
  155. modparam("acc", "log_flag", 1)
  156. modparam("acc", "failed_transaction_flag", 3)
  157. modparam("acc", "log_extra",
  158. "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")
  159.  
  160. # ----- tm params -----
  161. modparam("tm", "fr_timer", 2000)
  162. modparam("tm", "fr_inv_timer", 40000)
  163.  
  164. # ----- dispatcher params -----
  165. modparam("dispatcher", "db_url", DBURL)
  166. modparam("dispatcher", "table_name", "dispatcher")
  167. modparam("dispatcher", "flags_col", "flags")
  168. modparam("dispatcher", "priority_col", "priority")
  169. modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
  170. modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
  171. modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
  172.  
  173. modparam("dispatcher", "force_dst", 1)
  174.  
  175.  
  176. #-------pdt--------------
  177. modparam("pdt", "db_table", "pdt")
  178. modparam("pdt", "domain_column", "sdomain")
  179. modparam("pdt", "prefix_column", "prefix")
  180. modparam("pdt", "domain_column", "domain")
  181.  
  182.  
  183. #-----------------nat-----------
  184. modparam("nathelper", "natping_interval", 0)
  185. modparam("nathelper", "ping_nated_only", 0)
  186. #modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
  187. modparam("nathelper", "sipping_from", "sip:172.31.22.10:5060")
  188.  
  189. #-----------acc------------
  190. modparam("acc", "report_ack", 1)
  191.  
  192.  
  193.  
  194.  
  195. ####### Routing Logic ########
  196.  
  197.  
  198. # main request routing logic
  199.  
  200. route {
  201.  
  202.  
  203. # per request initial checks
  204. route(REQINIT);
  205.  
  206. # handle requests within SIP dialogs
  207. route(WITHINDLG);
  208.  
  209. ### only initial requests (no To tag)
  210.  
  211. # CANCEL processing
  212. if (is_method("CANCEL"))
  213. {
  214. if (t_check_trans())
  215. t_relay();
  216. exit;
  217. }
  218.  
  219. t_check_trans();
  220.  
  221. # record routing for dialog forming requests (in case they are routed)
  222. # - remove preloaded route headers
  223. remove_hf("Route");
  224. if (is_method("INVITE|SUBSCRIBE"))
  225.  
  226. #add_rr_param(";nat=yes");
  227. record_route_advertised_address("54.69.159.69:5060");
  228. #record_route();
  229.  
  230. # account only INVITEs
  231. if (is_method("INVITE"))
  232. {
  233. setflag(1); # do accounting
  234. }
  235.  
  236.  
  237. # handle presence related requests
  238. route(PRESENCE);
  239.  
  240. # handle registrations
  241. route(REGISTRAR);
  242.  
  243. if ($rU==$null)
  244. {
  245. # request with no Username in RURI
  246. sl_send_reply("484","Address Incomplete");
  247. exit;
  248. }
  249.  
  250. # dispatch destinations
  251. route(DISPATCH);
  252. }
  253.  
  254.  
  255. route[RELAY] {
  256. if (!t_relay()) {
  257. sl_reply_error();
  258. }
  259. exit;
  260. }
  261.  
  262. # Per SIP request initial checks
  263. route[REQINIT] {
  264. if (!mf_process_maxfwd_header("10")) {
  265. sl_send_reply("483","Too Many Hops");
  266. exit;
  267. }
  268.  
  269. if(!sanity_check("1511", "7"))
  270. {
  271. xlog("Malformed SIP message from $si:$sp\n");
  272. exit;
  273. }
  274. }
  275.  
  276. # Handle requests within SIP dialogs
  277. route[WITHINDLG] {
  278. t_check_trans();
  279. if (has_totag()) {
  280. # sequential request withing a dialog should
  281. # take the path determined by record-routing
  282. if (loose_route()) {
  283. if (is_method("BYE")) {
  284. setflag(1); # do accounting ...
  285. setflag(3); # ... even if the transaction fails
  286. }
  287. route(RELAY);
  288. } else {
  289. if (is_method("SUBSCRIBE") && uri == myself) {
  290. # in-dialog subscribe requests
  291. route(PRESENCE);
  292. exit;
  293. }
  294.  
  295. if ( is_method("ACK") ) {
  296. if ( t_check_trans() ) {
  297. # non loose-route, but stateful ACK;
  298. # must be ACK after a 487 or e.g. 404 from upstream server
  299. t_relay();
  300. exit;
  301. } else {
  302. # ACK without matching transaction ... ignore and discard.
  303. exit;
  304. }
  305. }
  306. sl_send_reply("404","Not here");
  307. }
  308. exit;
  309. }
  310. }
  311.  
  312. # Handle SIP registrations
  313. route[REGISTRAR] {
  314. if(!is_method("REGISTER"))
  315. return;
  316. sl_send_reply("404", "No registrar");
  317. exit;
  318. }
  319.  
  320. # Presence server route
  321. route[PRESENCE] {
  322. if(!is_method("PUBLISH|SUBSCRIBE"))
  323. return;
  324.  
  325. sl_send_reply("404", "Not here");
  326. exit;
  327. }
  328.  
  329. # Dispatch requests
  330. route[DISPATCH] {
  331.  
  332. if(prefix2domain("2", "0")) {
  333. $ru = "sip:" + $rU + "@" + $rd;
  334. t_relay();
  335. exit;
  336.  
  337. }
  338.  
  339. # round robin dispatching on gateways group '1'
  340. if(!ds_select_dst("1", "4"))
  341. {
  342. send_reply("404", "No destination");
  343. exit;
  344. }
  345. xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
  346. t_on_failure("RTF_DISPATCH");
  347. route(RELAY);
  348. exit;
  349. }
  350.  
  351. # Sample failure route
  352. failure_route[RTF_DISPATCH] {
  353. if (t_is_canceled()) {
  354. exit;
  355. }
  356. # next DST - only for 500 or local timeout
  357. if (t_check_status("500")
  358. or (t_branch_timeout() and !t_branch_replied()))
  359. {
  360. if(ds_next_dst())
  361. {
  362. t_on_failure("RTF_DISPATCH");
  363. route(RELAY);
  364. exit;
  365. }
  366. }
  367. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement