[SR-Users] Kamilio dispatcher not registering with asterisk

Sergio Charrua sergio.charrua at voip.pt
Mon Dec 7 18:40:44 CET 2020


allow_guest=yes is a security risk. Basically you're telling Asterisk to
allow everyone to register and call everybody to all your routes. If your
Asterisk box is open directly to the outside world, it will be perfect for
scammers to make international calls and your bill will go sky-high!

from your last mail, you're trying to accept registers from a proxy trunk.
Is that your Kamailio server? i will assume it is.
Then try this :

[proxy-trunk]
host=104.201.100.15
type=friend
nat=force_rport,comedia
insecure=port,invite
port=5060
qualify=yes
disallow=all
allow=all
context=[your context where calls coming from proxy-trunk go and get
processed]
canreinvite=no
directmedia=no

Set NAT and DIRECTMEDIA as required. Usually CANREINVITE is not supported
by proxy servers, so it is turned off in this example

Also, Kamailio does not register into Asterisk. At best, Asterisk will
recognise Kamailio and allow calls and SIP messages (like REGISTER from a
peer).
In that case, try to set your SIP peers configuration as:
host=dynamic
type=friend
insecure=invite,port

and set the NAT and DIRECTMEDIA as needed.

Hope this helps.

*Sérgio Charrua*


*www.voip.pt <http://www.voip.pt/>*
Tel.: +351  <callto:+351+91+104+12+66>21 130 71 77

Email : *sergio.charrua at voip.pt <sergio.charrua at voip.pt>*

This message and any files or documents attached are strictly confidential
or otherwise legally protected.

It is intended only for the individual or entity named. If you are not the
named addressee or have received this email in error, please inform the
sender immediately, delete it from your system and do not copy or disclose
it or its contents or use it for any purpose. Please also note that
transmission cannot be guaranteed to be secure or error-free.








On Mon, Dec 7, 2020 at 4:14 PM Mihai Cezar <cezar at mokalife.ro> wrote:

> I've added this to asterisk - sip.conf, with no luck
>
>
> [proxy-trunk]
> fromdomain=oro.sips.nl
> host=104.201.100.15
> type=friend
> insecure=invite,port
>
>
>
>
>
> On Mon, Dec 7, 2020 at 5:22 PM Mihai Cezar <cezar at mokalife.ro> wrote:
>
>> HI sergio,
>>
>> I just set allow_guest = yes. I don't know what to set on the asterisk,
>> if you can guide a little bit ...
>>
>> On Mon, Dec 7, 2020 at 5:17 PM Sergio Charrua <sergio.charrua at voip.pt>
>> wrote:
>>
>>> Hi !
>>>
>>> what is the "type" of your SIP Peer, on Asterisk? Friend, Peer or User?
>>> and what about the "insecure" setting?
>>>
>>> *Sérgio Charrua*
>>>
>>>
>>> *www.voip.pt <http://www.voip.pt/>*
>>> Tel.: +351  <callto:+351+91+104+12+66>21 130 71 77
>>>
>>> Email : *sergio.charrua at voip.pt <sergio.charrua at voip.pt>*
>>>
>>> This message and any files or documents attached are strictly
>>> confidential or otherwise legally protected.
>>>
>>> It is intended only for the individual or entity named. If you are not
>>> the named addressee or have received this email in error, please inform the
>>> sender immediately, delete it from your system and do not copy or disclose
>>> it or its contents or use it for any purpose. Please also note that
>>> transmission cannot be guaranteed to be secure or error-free.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Mon, Dec 7, 2020 at 3:09 PM Mihai <m at mokalife.ro> wrote:
>>>
>>>> Hi all,
>>>>
>>>> i have a problem with kamailio 5.3.x and asterisk 13, i basically
>>>> forward everything, but i cant manage to make it register.
>>>>
>>>> The register arrives on asterisk see the capture bellow:
>>>> Any help is much appreciated!
>>>> ----------------
>>>> REGISTER sip:oro.sips.nl;transport=UDP SIP/2.0
>>>> Via: SIP/2.0/UDP
>>>> 104.201.100.15;branch=z9hG4bK4d5e.997621d931a2ad9f6423e2ac7782a319.1
>>>> Via: SIP/2.0/UDP 34.12.55.102:34626
>>>> ;received=34.12.55.102;branch=z9hG4bK-524287-1---0a0bffd64bbd9941;rport=34626
>>>> Max-Forwards: 69
>>>> Contact: <sip:test-user1 at 34.12.55.102:34626
>>>> ;transport=UDP;rinstance=85c33e976be3dad1>
>>>> To: <sip:test-user1 at oro.sips.nl;transport=UDP>
>>>> From: <sip:test-user1 at oro.sips.nl;transport=UDP>;tag=6d8fd914
>>>> Call-ID: h6lkViFgxurpVRkw4Ly-GQ..
>>>> CSeq: 1 REGISTER
>>>> Expires: 60
>>>> Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO,
>>>> SUBSCRIBE
>>>> User-Agent: Z 5.4.9 rv2.10.11.7
>>>> Allow-Events: presence, kpml, talk
>>>> Content-Length: 0
>>>> Path: <sip:104.201.100.15;lr;received=sip:34.12.55.102:34626>
>>>>
>>>> -------------------the config -------
>>>> # - flags
>>>> #   FLT_ - per transaction (message) flags
>>>> # FLB_ - per branch flags
>>>> #!define FLT_ACC 1
>>>> #!define FLT_ACCMISSED 2
>>>> #!define FLT_ACCFAILED 3
>>>>
>>>> #!define FLT_FS 10
>>>>
>>>> ####### Global Parameters #########
>>>>
>>>> debug=4
>>>> log_stderror=yes
>>>>
>>>> memdbg=5
>>>> memlog=5
>>>>
>>>> log_facility=LOG_LOCAL0
>>>>
>>>> fork=yes
>>>> children=4
>>>>
>>>> /* comment the next line to enable TCP */
>>>> disable_tcp=yes
>>>>
>>>> /* uncomment the next line to disable the auto discovery of local
>>>> aliases
>>>>    based on revers DNS on IPs (default on) */
>>>> auto_aliases=no
>>>>
>>>> /* add local domain aliases */
>>>> # alias="mysipserver.com"
>>>>
>>>> port=5060
>>>>
>>>> /* uncomment and configure the following line if you want Kamailio to
>>>>    bind on a specific interface/port/proto (default bind on all
>>>> available) */
>>>> # listen=udp:127.0.0.1:5060
>>>>
>>>> sip_warning=no
>>>>
>>>> ####### Modules Section ########
>>>>
>>>> # set module path
>>>> #mpath="/usr/local/lib/kamailio/modules/"
>>>>
>>>> #loadmodule "db_mysql.so"
>>>> loadmodule "jsonrpcs.so"
>>>> loadmodule "kex.so"
>>>> loadmodule "corex.so"
>>>> loadmodule "tm.so"
>>>> loadmodule "tmx.so"
>>>> loadmodule "sl.so"
>>>> loadmodule "rr.so"
>>>> loadmodule "pv.so"
>>>> loadmodule "maxfwd.so"
>>>> loadmodule "textops.so"
>>>> loadmodule "siputils.so"
>>>> loadmodule "xlog.so"
>>>> loadmodule "sanity.so"
>>>> loadmodule "ctl.so"
>>>> loadmodule "acc.so"
>>>> loadmodule "dispatcher.so"
>>>> loadmodule "path.so"
>>>>
>>>> # ----------------- setting module-specific parameters ---------------
>>>>
>>>>
>>>> # ----- jsonrpcs params -----
>>>> modparam("jsonrpcs", "pretty_format", 1)
>>>>
>>>>
>>>> # ----- rr params -----
>>>> # add value to ;lr param to cope with most of the UAs
>>>> modparam("rr", "enable_full_lr", 1)
>>>> # do not append from tag to the RR (no need for this script)
>>>> modparam("rr", "append_fromtag", 0)
>>>>
>>>>
>>>> # ----- acc params -----
>>>> modparam("acc", "log_flag", FLT_ACC)
>>>> modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
>>>> modparam("acc", "log_extra",
>>>> "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")
>>>>
>>>> # ----- tm params -----
>>>> modparam("tm", "fr_timer", 2000)
>>>> modparam("tm", "fr_inv_timer", 40000)
>>>>
>>>> # ----- dispatcher params -----
>>>> #modparam("dispatcher", "db_url", DBURL)
>>>> #modparam("dispatcher", "table_name", "dispatcher")
>>>> modparam("dispatcher", "list_file", "/etc/kamailio/dispatcher.list")
>>>> modparam("dispatcher", "flags", 2)
>>>> modparam("dispatcher", "xavp_dst", "_dsdst_")
>>>> modparam("dispatcher", "xavp_ctx", "_dsctx_")
>>>> modparam("dispatcher", "ds_ping_from", "sip:proxy at mykamailio")
>>>> modparam("dispatcher", "ds_ping_interval", 30)
>>>> modparam("dispatcher", "ds_probing_threshold", 10)
>>>> modparam("dispatcher", "ds_inactive_threshold", 5)
>>>> modparam("dispatcher", "ds_ping_reply_codes",
>>>> "class=2;code=403;code=488;class=3")
>>>> modparam("dispatcher", "ds_probing_mode", 1)
>>>>
>>>> modparam("path", "use_received", 1)
>>>>
>>>> ####### Routing Logic ########
>>>>
>>>>
>>>> # main request routing logic
>>>>
>>>> request_route {
>>>>
>>>> # per request initial checks
>>>> route(REQINIT);
>>>>
>>>>         if(ds_is_from_list()) {
>>>>        setflag(FLT_FS);
>>>>         }
>>>>
>>>> # CANCEL processing
>>>> if (is_method("CANCEL")) {
>>>> if (t_check_trans()) {
>>>> route(RELAY);
>>>> }
>>>> exit;
>>>> }
>>>>
>>>> # handle retransmissions
>>>> if (!is_method("ACK")) {
>>>> if(t_precheck_trans()) {
>>>> t_check_trans();
>>>> exit;
>>>> }
>>>> t_check_trans();
>>>> }
>>>>
>>>> # handle requests within SIP dialogs
>>>> route(WITHINDLG);
>>>>
>>>>         if (isflagset(FLT_FS)) {
>>>>                 route(FROM_FS);
>>>>                 exit;
>>>>         }
>>>>
>>>> ### only initial requests (no To tag)
>>>>
>>>> # record routing for dialog forming requests (in case they are routed)
>>>> # - remove preloaded route headers
>>>> remove_hf("Route");
>>>> if (is_method("INVITE|SUBSCRIBE")) {
>>>> record_route();
>>>> }
>>>>
>>>> # account only INVITEs
>>>> if (is_method("INVITE")) {
>>>> setflag(FLT_ACC); # do accounting
>>>> }
>>>>
>>>> # handle presence related requests
>>>> route(PRESENCE);
>>>>
>>>> # handle registrations
>>>> route(REGISTRAR);
>>>>
>>>> if ($rU==$null) {
>>>> # request with no Username in RURI
>>>> sl_send_reply("484","Address Incomplete");
>>>> exit;
>>>> }
>>>>
>>>> # dispatch destinations
>>>> route(DISPATCH);
>>>> }
>>>>
>>>> route[FROM_FS]
>>>> {
>>>>         record_route();
>>>>         route(RELAY);
>>>>         exit;
>>>> }
>>>>
>>>> route[RELAY] {
>>>> if (!t_relay()) {
>>>> sl_reply_error();
>>>> }
>>>> exit;
>>>> }
>>>>
>>>> # Per SIP request initial checks
>>>> route[REQINIT] {
>>>> if (!mf_process_maxfwd_header("10")) {
>>>> sl_send_reply("483","Too Many Hops");
>>>> exit;
>>>> }
>>>>
>>>> if(!sanity_check("1511", "7")) {
>>>> xlog("Malformed SIP message from $si:$sp\n");
>>>> exit;
>>>> }
>>>> }
>>>>
>>>> # Handle requests within SIP dialogs
>>>> route[WITHINDLG] {
>>>> if (has_totag()) {
>>>> # sequential request withing a dialog should
>>>> # take the path determined by record-routing
>>>> if (loose_route()) {
>>>> if (is_method("BYE")) {
>>>> setflag(FLT_ACC); # do accounting ...
>>>> setflag(FLT_ACCFAILED); # ... even if the transaction fails
>>>> }
>>>> route(RELAY);
>>>> } else {
>>>> if (is_method("SUBSCRIBE") && uri == myself) {
>>>> # in-dialog subscribe requests
>>>> route(PRESENCE);
>>>> exit;
>>>> }
>>>> if ( is_method("ACK") ) {
>>>> if ( t_check_trans() ) {
>>>> # non loose-route, but stateful ACK;
>>>> # must be ACK after a 487 or e.g. 404 from upstream server
>>>> t_relay();
>>>> exit;
>>>> } else {
>>>> # ACK without matching transaction ... ignore and discard.
>>>> exit;
>>>> }
>>>> }
>>>> sl_send_reply("404","Not here");
>>>> }
>>>> exit;
>>>> }
>>>> }
>>>>
>>>> # Handle SIP registrations
>>>> route[REGISTRAR] {
>>>> if(!is_method("REGISTER"))
>>>> return;
>>>> add_path_received();
>>>>         route(DISPATCH);
>>>> }
>>>>
>>>> # Presence server route
>>>> route[PRESENCE] {
>>>> if(!is_method("PUBLISH|SUBSCRIBE"))
>>>> return;
>>>>
>>>> sl_send_reply("404", "Not here");
>>>> exit;
>>>> }
>>>>
>>>> # Dispatch requests
>>>> route[DISPATCH] {
>>>> # round robin dispatching on gateways group '1'
>>>> switch ($fd){
>>>> case "oro.sips.nl":
>>>> send_reply(483, "Ok, Skipper!");
>>>> if (!ds_select_dst("1", "4")) {
>>>> log("ERROR: no active destinations found!\n");
>>>> send_reply(503, "Service Unavailable");
>>>> exit;
>>>> }
>>>> ds_select_dst("1", "4");
>>>> log("---- flag value is $dd -- branch $fd \n");
>>>> xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs:
>>>> $xavp(_dsdst_=>attrs))\n");
>>>> break;
>>>> case "oro2.sips.nl":
>>>> send_reply(483, "Ok, Skipper!");
>>>> if (!ds_select_dst("2", "4")) {
>>>> log("ERROR: no active destinations found!\n");
>>>> send_reply(503, "Service Unavailable");
>>>> exit;
>>>> }
>>>> ds_select_dst("2", "4");
>>>> log("---- flag value is $dd -- branch $fd \n");
>>>> xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs:
>>>> $xavp(_dsdst_=>attrs))\n");
>>>> break;
>>>> default:
>>>>    log("unknow destination?");
>>>>    send_reply(503, "No service defined");
>>>>    exit;
>>>> }
>>>>
>>>> xdbg("--- SCRIPT: going to <$ru> via <$du> (attrs:
>>>> $xavp(_dsdst_=>attrs))\n");
>>>> t_on_failure("RTF_DISPATCH");
>>>> route(RELAY);
>>>> exit;
>>>> }
>>>>
>>>> # Try next destionations in failure route
>>>> failure_route[RTF_DISPATCH] {
>>>> if (t_is_canceled()) {
>>>> exit;
>>>> }
>>>> # next DST - only for 500 or local timeout
>>>> if (t_check_status("500")
>>>> or (t_branch_timeout() and !t_branch_replied())) {
>>>> if(ds_next_dst()) {
>>>> xdbg("--- SCRIPT: retrying to <$ru> via <$du> (attrs:
>>>> $xavp(_dsdst_=>attrs))\n");
>>>> t_on_failure("RTF_DISPATCH");
>>>> route(RELAY);
>>>> exit;
>>>> }
>>>> }
>>>> }
>>>> _______________________________________________
>>>> Kamailio (SER) - Users Mailing List
>>>> sr-users at lists.kamailio.org
>>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>>
>>> _______________________________________________
>>> Kamailio (SER) - Users Mailing List
>>> sr-users at lists.kamailio.org
>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>
>> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20201207/4ce79744/attachment.htm>


More information about the sr-users mailing list