<div dir="ltr">Any hints about this?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Sep 29, 2020 at 4:46 PM Mihai <<a href="mailto:m@mokalife.ro">m@mokalife.ro</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi all,<div><br></div><div>I need some help on getting to work my scenario:</div><div><br></div><div>I have 3 asterisk servers, and, every agent is connecting to which server they need by contacting the PublicIP. (the problem is that I need to reuse the IP address on others servers) . I want if is possible to use Opensips as proxy, so that agents can connect to those asterisk servers by virtualhost (example. asterisk1.behindproxy.example, asterisk2.behindproxy.example ). Basically I want to proxy everything thru OpenSIPs.</div><div><br></div><div><br></div><div>I am using centos 7 with the following packages installed:</div><div><div>opensips-dialplan-module-3.1.0-1.el7.x86_64</div><div>opensips-yum-releases-3.1-5.el7.noarch</div><div>opensips-b2bua-module-3.1.0-1.el7.x86_64</div><div>opensips-regex-module-3.1.0-1.el7.x86_64</div><div>opensips-mysql-module-3.1.0-1.el7.x86_64</div><div>opensips-3.1.0-1.el7.x86_64</div><div><br></div></div><div><br></div><div><br></div><div>What I tried so far is this config, it dose send my users to required Asterisk servers, but on the asterisk server I don't see their IP ( i see the IP of the proxy) and that's it ....</div><div>the dispatcher list is this from mysql:</div><div><br></div><div>Any help is apreciated.</div><div><div>+----+-------+----------------+--------+-------+--------+----------+-------+-------------+</div><div>| id | setid | destination | socket | state | weight | priority | attrs | description |</div><div>+----+-------+----------------+--------+-------+--------+----------+-------+-------------+</div><div>| 1 | 1 | sip:172.16.0.2 | NULL | 2 | 1 | 0 | | sip1 |</div><div>| 2 | 2 | sip:172.16.0.3 | NULL | 2 | 1 | 0 | | sip2 |</div><div>| 3 | 3 | sip:172.16.0.4 | NULL | 2 | 1 | 0 | | sip3 |</div><div>+----+-------+----------------+--------+-------+--------+----------+-------+-------------+</div></div><div><br></div><div><br></div><div><div>####### Global Parameters #########</div><div>#debug_mode=yes</div><div>log_level=4</div><div>log_stderror=no</div><div>log_facility=LOG_LOCAL0</div><div>udp_workers=4</div><div>socket=udp:<a href="http://0.0.0.0:5060" target="_blank">0.0.0.0:5060</a></div><div>####### Modules Section ########</div><div><br></div><div>#set module path</div><div>mpath="/usr/lib64/opensips/modules"</div><div><br></div><div>#### SIGNALING module</div><div>loadmodule "signaling.so"</div><div><br></div><div>loadmodule "db_mysql.so"</div><div>loadmodule "db_text.so"</div><div><br></div><div>#### StateLess module</div><div>loadmodule "sl.so"</div><div><br></div><div>#### Transaction Module</div><div>loadmodule "tm.so"</div><div>modparam("tm", "fr_timeout", 5)</div><div>modparam("tm", "fr_inv_timeout", 30)</div><div>modparam("tm", "restart_fr_on_each_reply", 0)</div><div>modparam("tm", "onreply_avp_mode", 1)</div><div><br></div><div>#### Record Route Module</div><div>loadmodule "rr.so"</div><div>modparam("rr", "append_fromtag", 0)</div><div><br></div><div>#### MAX ForWarD module</div><div>loadmodule "maxfwd.so"</div><div><br></div><div>#### SIP MSG OPerationS module</div><div>loadmodule "sipmsgops.so"</div><div><br></div><div>#### FIFO Management Interface</div><div>loadmodule "mi_fifo.so"</div><div>modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")</div><div>modparam("mi_fifo", "fifo_mode", 0666)</div><div><br></div><div>#### USeR LOCation module</div><div>loadmodule "usrloc.so"</div><div>modparam("usrloc", "nat_bflag", "NAT")</div><div>modparam("usrloc", "working_mode_preset", "single-instance-no-db")</div><div><br></div><div>#### REGISTRAR module</div><div>loadmodule "registrar.so"</div><div>modparam("registrar", "retry_after", 30)</div><div><br></div><div>#### DIALOG module</div><div>loadmodule "dialog.so"</div><div>modparam("dialog", "enable_stats", 0)</div><div>modparam("dialog", "hash_size", 1024)</div><div>modparam("dialog", "log_profile_hash_size", 4)</div><div>modparam("dialog", "default_timeout", 21600) # 6h</div><div>modparam("dialog", "dlg_extra_hdrs", "Hint: credit expired\r\n")</div><div>modparam("dialog", "dlg_match_mode", 0)</div><div>modparam("dialog", "options_ping_interval", 20)</div><div>modparam("dialog", "reinvite_ping_interval", 600)</div><div><br></div><div>### nat_traversal</div><div>loadmodule "nat_traversal.so"</div><div>modparam("nat_traversal", "keepalive_interval", 60)</div><div>modparam("nat_traversal", "keepalive_method", "OPTIONS")</div><div>modparam("nat_traversal", "keepalive_from", "sip:keepalive@opensips.proxy")</div><div>modparam("nat_traversal", "keepalive_extra_headers", "User-Agent: OpenSIPS\r\nX-NAT: yes\r\n")</div><div>modparam("nat_traversal", "keepalive_state_file", "/var/run/opensips/keepalive_state")</div><div><br></div><div><br></div><div>######################################################################</div><div>## Dispatcher Module Parameters</div><div>######################################################################</div><div>loadmodule "dispatcher.so"</div><div>#modparam("dispatcher", "list_file", "/etc/opensips/dispatcher.list")</div><div>modparam("dispatcher", "db_url", "mysql://opensips:opensipsrw@localhost/opensips")</div><div>modparam("dispatcher", "dst_avp", "$avp(271)")</div><div>modparam("dispatcher", "attrs_avp", "$avp(272)")</div><div>modparam("dispatcher", "grp_avp", "$avp(273)")</div><div>modparam("dispatcher", "cnt_avp", "$avp(274)")</div><div>modparam("dispatcher", "hash_pvar", "$avp(273)")</div><div>modparam("dispatcher", "ds_ping_method", "OPTIONS")</div><div>modparam("dispatcher", "ds_ping_from", "sip:sipcheck@opensips.proxy")</div><div>modparam("dispatcher", "ds_ping_interval", 10)</div><div>modparam("dispatcher", "ds_probing_threshhold", 3)</div><div>modparam("dispatcher", "ds_probing_mode", 1)</div><div>modparam("dispatcher", "options_reply_codes", "501,403,404,400,200")</div><div><br></div><div>loadmodule "proto_udp.so"</div><div><br></div><div>####### Routing Logic ########</div><div># main request routing logic</div><div><br></div><div>route{</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if (!mf_process_maxfwd_header(10)) {</div><div><span style="white-space:pre-wrap"> </span>send_reply(483,"Max hops reached");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if (has_totag()) {</div><div><br></div><div><span style="white-space:pre-wrap"> </span># handle hop-by-hop ACK (no routing required)</div><div><span style="white-space:pre-wrap"> </span>if ( is_method("ACK") && t_check_trans() ) {</div><div><span style="white-space:pre-wrap"> </span>t_relay();</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># sequential request within a dialog should</div><div><span style="white-space:pre-wrap"> </span># take the path determined by record-routing</div><div><span style="white-space:pre-wrap"> </span>if ( !loose_route() ) {</div><div><span style="white-space:pre-wrap"> </span># we do record-routing for all our traffic, so we should not</div><div><span style="white-space:pre-wrap"> </span># receive any sequential requests without Route hdr.</div><div><span style="white-space:pre-wrap"> </span>send_reply(404,"Not here");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># route it out to whatever destination was set by loose_route()</div><div><span style="white-space:pre-wrap"> </span># in $du (destination URI).</div><div><span style="white-space:pre-wrap"> </span>route(relay);</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># CANCEL processing</div><div><span style="white-space:pre-wrap"> </span>if (is_method("CANCEL")) {</div><div><span style="white-space:pre-wrap"> </span>if (t_check_trans())</div><div><span style="white-space:pre-wrap"> </span>t_relay();</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># absorb retransmissions, but do not create transaction</div><div><span style="white-space:pre-wrap"> </span>t_check_trans();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if ( !(is_method("REGISTER") ) ) {</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>if (is_myself("$fd")) {</div><div><span style="white-space:pre-wrap"> </span># do nothing<span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>} else {</div><div><span style="white-space:pre-wrap"> </span># if caller is not local, then called number must be local</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>if (!is_myself("$rd")) {</div><div><span style="white-space:pre-wrap"> </span>send_reply(403,"Relay Forbidden On: $si ");</div><div><span style="white-space:pre-wrap"> </span>#send_reply(200,"Relay $fd ");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># preloaded route checking</div><div><span style="white-space:pre-wrap"> </span>if (loose_route()) {</div><div><span style="white-space:pre-wrap"> </span>xlog("L_ERR",</div><div><span style="white-space:pre-wrap"> </span>"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");</div><div><span style="white-space:pre-wrap"> </span>if (!is_method("ACK"))</div><div><span style="white-space:pre-wrap"> </span>send_reply(403,"Preload Route denied");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># record routing</div><div><span style="white-space:pre-wrap"> </span>if (!is_method("REGISTER|MESSAGE"))</div><div><span style="white-space:pre-wrap"> </span>record_route();</div><div><br></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>if (!is_myself("$rd")) {</div><div><span style="white-space:pre-wrap"> </span>append_hf("P-hint: outbound\r\n"); </div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>route(relay);</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># requests for my domain</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>if (is_method("PUBLISH|SUBSCRIBE")) {</div><div><span style="white-space:pre-wrap"> </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if (is_method("REGISTER")) {</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>if (!save("location"))</div><div><span style="white-space:pre-wrap"> </span>sl_reply_error();</div><div><br></div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if ($rU==NULL) {</div><div><span style="white-space:pre-wrap"> </span># request with no Username in RURI</div><div><span style="white-space:pre-wrap"> </span>send_reply(484,"Address Incomplete");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span># do lookup with method filtering</div><div><span style="white-space:pre-wrap"> </span>if (!lookup("location","m")) {</div><div><span style="white-space:pre-wrap"> </span>t_reply(404, "Not Found");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>route(relay);</div><div>}</div><div><br></div><div><br></div><div>route[relay] {</div><div><span style="white-space:pre-wrap"> </span># for INVITEs enable some additional helper routes</div><div><span style="white-space:pre-wrap"> </span>if (is_method("INVITE")) {</div><div><span style="white-space:pre-wrap"> </span>t_on_branch("per_branch_ops");</div><div><span style="white-space:pre-wrap"> </span>t_on_reply("handle_nat");</div><div><span style="white-space:pre-wrap"> </span>t_on_failure("missed_call");</div><div><span style="white-space:pre-wrap"> </span>}</div><div><br></div><div><span style="white-space:pre-wrap"> </span>if (!t_relay()) {</div><div><span style="white-space:pre-wrap"> </span>send_reply(500,"Internal Error");</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><br></div><div><br></div><div><span style="white-space:pre-wrap"> </span>switch ($fd){</div><div><span style="white-space:pre-wrap"> </span>case "<a href="http://asterisk1.example.com" target="_blank">asterisk1.example.com</a>":</div><div><span style="white-space:pre-wrap"> </span>if (!ds_select_dst(1, 0)) {</div><div><span style="white-space:pre-wrap"> </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre-wrap"> </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>ds_select_dst(1, 8, "ud", "default", 1); </div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span>case "<a href="http://asterisk1.example.com" target="_blank">asterisk1.example.com</a>":</div><div><span style="white-space:pre-wrap"> </span>if (!ds_select_dst(2, 0)) {</div><div><span style="white-space:pre-wrap"> </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre-wrap"> </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>ds_select_dst(2, 8, "ud", "default", 1); </div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span>case "<a href="http://asterisk1.example.com" target="_blank">asterisk1.example.com</a>":</div><div><span style="white-space:pre-wrap"> </span>if (!ds_select_dst(3, 0)) {</div><div><span style="white-space:pre-wrap"> </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre-wrap"> </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div><span style="white-space:pre-wrap"> </span>ds_select_dst(3, 8, "ud", "default", 1); </div><div><span style="white-space:pre-wrap"> </span>log("---- flag value is $dd -- branch $fd \n");</div><div><span style="white-space:pre-wrap"> </span>break;</div><div><span style="white-space:pre-wrap"> </span>default:</div><div><span style="white-space:pre-wrap"> </span> log("unknow destination");</div><div><span style="white-space:pre-wrap"> </span> exit;</div><div><span style="white-space:pre-wrap"> </span>}<span style="white-space:pre-wrap"> </span></div><div>}</div><div><br></div><div><br></div><div><br></div><div><br></div><div>branch_route[per_branch_ops] {</div><div><span style="white-space:pre-wrap"> </span>xlog("new branch at $ru\n");</div><div>}</div><div><br></div><div><br></div><div>onreply_route[handle_nat] {</div><div><span style="white-space:pre-wrap"> </span>xlog("incoming reply\n");</div><div>}</div><div><br></div><div><br></div><div>failure_route[missed_call] {</div><div><span style="white-space:pre-wrap"> </span>if (t_was_cancelled()) {</div><div><span style="white-space:pre-wrap"> </span>exit;</div><div><span style="white-space:pre-wrap"> </span>}</div><div>}</div></div></div></div></div></div>
</blockquote></div>