Advertisement
Guest User

kamailio config

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