You could also use the dialplan module, using the match regexp to return the GID of the incoming ip.

Say all calls coming from 192.168.0.100 must use the IPs 192.168.100.2 and 3 for outbound.

I.e.:

Adding a record in the dialplan table which includes match_exp=“192.168.0.100”, attrs=“100”

Adding records in the dispatcher, like:

GID destination
100 192.168.100.2
100 192.168.100.3
...

Then use the inbound source_ip (192.168.0.100) to match using dialplan then getting the list of destinations from the dispatcher, something like:

    dp_match("1", "$si");
    xlog("[DISPATCH] inbound '$si' will use dispatcher GID: '$var(dispatcher_id)'\n");
    xlog("[DISPATCH] avp(dsdstid): $avp(dsdstid)\n");

    if(!ds_select_dst("$var(dispatcher_id)", "4"))
    {
        send_reply("404", "No destination");
        exit;
    } else {
        xlog("[DISPATCH] ds_select_dst was succesful'\n");
    }
    xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");
    t_on_failure("RTF_DISPATCH");
    route(RELAY);
    exit;
Hope that helps


David

On Mon, 7 Oct 2019 at 11:22, Alex Balashov <abalashov@evaristesys.com> wrote:
Hi Oleg,

What about choosing the dispatcher group based on a hash 

https://kamailio.org/docs/modules/5.2.x/modules/cfgutils.html#cfgutils.f.core_hash

over a SIP attribute that is tied to the source IP of the inbound SBC, such as $si or $fd?

https://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables#si_-_source_ip_address

https://www.kamailio.org/wiki/cookbooks/5.2.x/pseudovariables#fd_-_from_uri_domain

— Alex

Sent from mobile, with due apologies for brevity and errors.

On Oct 7, 2019, at 5:43 AM, Oleg Belousov <obelousov@gmail.com> wrote:


Hello.
In our setup kamailio perfoms some logic depending on call direction, inbound or outbound. Call direction is identified by 2 SBC IP (IP_inbound/IP_outbound), we currently use for that 2 dispatcher groups and that is working fine.

Now number of peer nodes increased from one SBC till few tens, but we still need to keep SIP-links adjacency, meaning that call which arrived from SBC_N IP_inbound
need to be submitted via same SBC_N IP_outbound and vice versa. There could be few approaches to implement that requirement, I'm wondering if can use existing dispatcher function/select destination logic to support SIP-links adjacency.
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Regards,

David Villasmil
email: david.villasmil.work@gmail.com
phone: +34669448337