<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">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">      </span>if (!mf_process_maxfwd_header(10)) {</div><div><span style="white-space:pre">          </span>send_reply(483,"Max hops reached");</div><div><span style="white-space:pre">         </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span>if (has_totag()) {</div><div><br></div><div><span style="white-space:pre">           </span># handle hop-by-hop ACK (no routing required)</div><div><span style="white-space:pre">         </span>if ( is_method("ACK") && t_check_trans() ) {</div><div><span style="white-space:pre">                        </span>t_relay();</div><div><span style="white-space:pre">                    </span>exit;</div><div><span style="white-space:pre">         </span>}</div><div><br></div><div><span style="white-space:pre">            </span># sequential request within a dialog should</div><div><span style="white-space:pre">           </span># take the path determined by record-routing</div><div><span style="white-space:pre">          </span>if ( !loose_route() ) {</div><div><span style="white-space:pre">                       </span># we do record-routing for all our traffic, so we should not</div><div><span style="white-space:pre">                  </span># receive any sequential requests without Route hdr.</div><div><span style="white-space:pre">                  </span>send_reply(404,"Not here");</div><div><span style="white-space:pre">                 </span>exit;</div><div><span style="white-space:pre">         </span>}</div><div><br></div><div><span style="white-space:pre">            </span># route it out to whatever destination was set by loose_route()</div><div><span style="white-space:pre">               </span># in $du (destination URI).</div><div><span style="white-space:pre">           </span>route(relay);</div><div><span style="white-space:pre">         </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span># CANCEL processing</div><div><span style="white-space:pre">   </span>if (is_method("CANCEL")) {</div><div><span style="white-space:pre">          </span>if (t_check_trans())</div><div><span style="white-space:pre">                  </span>t_relay();</div><div><span style="white-space:pre">            </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span># absorb retransmissions, but do not create transaction</div><div><span style="white-space:pre">       </span>t_check_trans();</div><div><br></div><div><span style="white-space:pre">     </span>if ( !(is_method("REGISTER")  ) ) {</div><div><span style="white-space:pre">                </span></div><div><span style="white-space:pre">              </span>if (is_myself("$fd")) {</div><div><span style="white-space:pre">                             </span># do nothing<span style="white-space:pre"> </span></div><div><span style="white-space:pre">              </span>} else {</div><div><span style="white-space:pre">                      </span># if caller is not local, then called number must be local</div><div><span style="white-space:pre">                    </span></div><div><span style="white-space:pre">                      </span>if (!is_myself("$rd")) {</div><div><span style="white-space:pre">                            </span>send_reply(403,"Relay Forbidden On: $si ");</div><div><span style="white-space:pre">                         </span>#send_reply(200,"Relay $fd ");</div><div><span style="white-space:pre">                              </span>exit;</div><div><span style="white-space:pre">                 </span>}</div><div><span style="white-space:pre">             </span>}</div><div><br></div><div><span style="white-space:pre">    </span>}</div><div><br></div><div><span style="white-space:pre">    </span># preloaded route checking</div><div><span style="white-space:pre">    </span>if (loose_route()) {</div><div><span style="white-space:pre">          </span>xlog("L_ERR",</div><div><span style="white-space:pre">                       </span>"Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]");</div><div><span style="white-space:pre">           </span>if (!is_method("ACK"))</div><div><span style="white-space:pre">                      </span>send_reply(403,"Preload Route denied");</div><div><span style="white-space:pre">             </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span># record routing</div><div><span style="white-space:pre">      </span>if (!is_method("REGISTER|MESSAGE"))</div><div><span style="white-space:pre">         </span>record_route();</div><div><br></div><div><span style="white-space:pre">      </span></div><div><span style="white-space:pre">      </span>if (!is_myself("$rd")) {</div><div><span style="white-space:pre">            </span>append_hf("P-hint: outbound\r\n"); </div><div><span style="white-space:pre">                </span></div><div><span style="white-space:pre">              </span>route(relay);</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span># requests for my domain</div><div><span style="white-space:pre">      </span></div><div><span style="white-space:pre">      </span>if (is_method("PUBLISH|SUBSCRIBE")) {</div><div><span style="white-space:pre">               </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre">             </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span>if (is_method("REGISTER")) {</div><div><span style="white-space:pre">                                </span></div><div><span style="white-space:pre">              </span>if (!save("location"))</div><div><span style="white-space:pre">                      </span>sl_reply_error();</div><div><br></div><div><span style="white-space:pre">            </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span>if ($rU==NULL) {</div><div><span style="white-space:pre">              </span># request with no Username in RURI</div><div><span style="white-space:pre">            </span>send_reply(484,"Address Incomplete");</div><div><span style="white-space:pre">               </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span># do lookup with method filtering</div><div><span style="white-space:pre">     </span>if (!lookup("location","m")) {</div><div><span style="white-space:pre">            </span>t_reply(404, "Not Found");</div><div><span style="white-space:pre">          </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div><br></div><div><span style="white-space:pre">    </span>route(relay);</div><div>}</div><div><br></div><div><br></div><div>route[relay] {</div><div><span style="white-space:pre">  </span># for INVITEs enable some additional helper routes</div><div><span style="white-space:pre">    </span>if (is_method("INVITE")) {</div><div><span style="white-space:pre">          </span>t_on_branch("per_branch_ops");</div><div><span style="white-space:pre">              </span>t_on_reply("handle_nat");</div><div><span style="white-space:pre">           </span>t_on_failure("missed_call");</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">    </span>if (!t_relay()) {</div><div><span style="white-space:pre">             </span>send_reply(500,"Internal Error");</div><div><span style="white-space:pre">   </span>}</div><div><span style="white-space:pre">     </span>exit;</div><div><br></div><div><br></div><div><span style="white-space:pre">       </span>switch ($fd){</div><div><span style="white-space:pre">                 </span>case "<a href="http://asterisk1.example.com">asterisk1.example.com</a>":</div><div><span style="white-space:pre">                              </span>if (!ds_select_dst(1, 0)) {</div><div><span style="white-space:pre">                                   </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre">                                      </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre">                                     </span>exit;</div><div><span style="white-space:pre">                         </span>}</div><div><span style="white-space:pre">                             </span></div><div><span style="white-space:pre">                              </span>ds_select_dst(1, 8, "ud", "default", 1); </div><div><span style="white-space:pre">                                </span>break;</div><div><span style="white-space:pre">                        </span>case "<a href="http://asterisk1.example.com">asterisk1.example.com</a>":</div><div><span style="white-space:pre">                              </span>if (!ds_select_dst(2, 0)) {</div><div><span style="white-space:pre">                                   </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre">                                      </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre">                                     </span>exit;</div><div><span style="white-space:pre">                         </span>}</div><div><span style="white-space:pre">                             </span>ds_select_dst(2, 8, "ud", "default", 1); </div><div><span style="white-space:pre">                                </span>break;</div><div><span style="white-space:pre">                        </span>case "<a href="http://asterisk1.example.com">asterisk1.example.com</a>":</div><div><span style="white-space:pre">                              </span>if (!ds_select_dst(3, 0)) {</div><div><span style="white-space:pre">                                   </span>log("ERROR: no active destinations found!\n");</div><div><span style="white-space:pre">                                      </span>send_reply(503, "Service Unavailable");</div><div><span style="white-space:pre">                                     </span>exit;</div><div><span style="white-space:pre">                         </span>}</div><div><span style="white-space:pre">                             </span>ds_select_dst(3, 8, "ud", "default", 1); </div><div><span style="white-space:pre">                                </span>log("---- flag value is $dd -- branch $fd \n");</div><div><span style="white-space:pre">                             </span>break;</div><div><span style="white-space:pre">                        </span>default:</div><div><span style="white-space:pre">                      </span>    log("unknow destination");</div><div><span style="white-space:pre">                    </span>    exit;</div><div><span style="white-space:pre">           </span>}<span style="white-space:pre">                    </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">     </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">    </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">      </span>if (t_was_cancelled()) {</div><div><span style="white-space:pre">              </span>exit;</div><div><span style="white-space:pre"> </span>}</div><div>}</div></div></div></div></div></div>