<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,</p>
<p>I'm using Keealived for configuration: <br>
</p>
<p>OpensSIPs1 IP 1.2.3.4</p>
<p>OpenSIPs2 IP 5.6.7.8</p>
<p>Virtual IP: 10.11.12.13</p>
<p><br>
</p>
<p>OpenSIPs1:</p>
<p><b>keepalived.conf</b></p>
<p>vrrp_script check_sip {<br>
<b>script "/etc/keepalived/node01.sh"</b><br>
interval 3<br>
fall 2<br>
rise 2<br>
}<br>
<br>
vrrp_instance VI_OS {<br>
state MASTER<br>
interface eth0<br>
virtual_router_id 1<br>
advert_int 1<br>
<b>notify /etc/keepalived/opensips.sh</b><br>
virtual_ipaddress {<br>
10.11.12.13 dev eth0<br>
}<br>
track_script {<br>
check_sip<br>
}<br>
}</p>
<p>each time there is a change in the servers status, keepalived
ejecute opensips.sh script<br>
</p>
<p><b>node01.sh</b></p>
<p>#!/bin/bash<br>
<br>
node01=1.2.3.4<br>
node02=5.6.7.8<br>
<b>return_code=0</b><br>
timeout 2 sipsak -s <a class="moz-txt-link-freetext" href="sip:$node01:5060">sip:$node01:5060</a><br>
exit_status=$?<br>
if [[ $exit_status -eq 0 ]]; then<br>
echo "sip ping successful to node01 [$node01]"<br>
exit $return_code<br>
fi<br>
timeout 2 sipsak -s <a class="moz-txt-link-freetext" href="sip:$node02:5060">sip:$node02:5060</a><br>
exit_status=$?<br>
if [[ $exit_status -eq 0 ]]; then<br>
echo "sip ping successful to node02 [$node02]"<br>
return_code=1<br>
fi<br>
echo "return code [$return_code]"<br>
exit $return_code</p>
<p><b>opensips.sh</b><br>
</p>
<p>#!/bin/bash<br>
<br>
TYPE=$1<br>
NAME=$2<br>
STATE=$3<br>
<br>
case $STATE in<br>
"MASTER") /usr/sbin/opensipsctl fifo
dlg_set_sharing_tag_active vip<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 1<br>
exit 0<br>
;;<br>
"BACKUP") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 0<br>
exit 0<br>
;;<br>
"FAULT") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 0<br>
exit 0<br>
;;<br>
*) echo "unknown state"<br>
exit 1<br>
;;<br>
esac<br>
</p>
<p>in this file I move the sharing tag and pinging NAT in the MASTER
status and remove in BAKCUP and FAULT status<br>
</p>
<p>OpenSIPs2:</p>
<p><b>keepalived.conf</b></p>
<p>vrrp_script check_sip {<br>
script "/etc/keepalived/node02.sh"<br>
interval 3<br>
fall 2<br>
rise 2<br>
}<br>
vrrp_instance VI_OS {<br>
state BACKUP<br>
interface eth0<br>
virtual_router_id 1<br>
advert_int 1<br>
notify /etc/keepalived/opensips.sh</p>
<p> virtual_ipaddress {<br>
10.11.12.13 dev eth0<br>
}<br>
track_script {<br>
check_sip<br>
}<br>
}<br>
</p>
<p><b>node02.sh</b></p>
<p>#!/bin/bash<br>
<br>
node01=1.2.3.4<br>
node02=5.6.7.8<br>
<b>return_code=1</b><br>
timeout 2 sipsak -s <a class="moz-txt-link-freetext" href="sip:$node01:5060">sip:$node01:5060</a><br>
exit_status=$?<br>
if [[ $exit_status -eq 0 ]]; then<br>
echo "sip ping successful to node01 [$node01]"<br>
exit $return_code<br>
fi<br>
timeout 2 sipsak -s <a class="moz-txt-link-freetext" href="sip:$node02:5060">sip:$node02:5060</a><br>
exit_status=$?<br>
if [[ $exit_status -eq 0 ]]; then<br>
echo "sip ping successful to node02 [$node02]"<br>
return_code=0<br>
fi<br>
echo "return code [$return_code]"<br>
exit $return_code<br>
</p>
<p><b>opensips.sh</b></p>
<p>#!/bin/bash<br>
<br>
TYPE=$1<br>
NAME=$2<br>
STATE=$3<br>
<br>
case $STATE in<br>
"MASTER") /usr/sbin/opensipsctl fifo
dlg_set_sharing_tag_active vip<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 1<br>
exit 0<br>
;;<br>
"BACKUP") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 0<br>
exit 0<br>
;;<br>
"FAULT") /usr/sbin/opensipsctl fifo dlg_list_sharing_tags<br>
/usr/sbin/opensipsctl fifo nh_enable_ping 0<br>
exit 0<br>
;;<br>
*) echo "unknown state"<br>
exit 1<br>
;;<br>
esac<br>
</p>
<p>Then you have to install sipsak and change your iptables
configuration.</p>
<p>opensips.cfg</p>
<p>OpenSIPs1:</p>
<p>listen=udp:1.2.3.4:5060<br>
listen=udp:10.11.12.13:5060<br>
</p>
<p>#### DIALOG module<br>
loadmodule "dialog.so"<br>
modparam("dialog", "dlg_match_mode", 1)<br>
modparam("dialog", "default_timeout", 21600)<br>
modparam("dialog", "db_mode", 0)<br>
modparam("dialog", "dlg_sharing_tag", "vip=active")<br>
modparam("dialog", "dialog_replication_cluster", 3)<br>
modparam("dialog",
"db_url","mysql://opensips:password@localhost/opensips")</p>
<p>if (is_method("INVITE")) {<br>
route(AUTH);<br>
create_dialog();<br>
set_dlg_sharing_tag("vip");<br>
do_accounting("db","cdr");<br>
if (isbflagset(NAT)) setflag(NAT);<br>
}<br>
</p>
<p>OpenSIPs2:</p>
<p>listen=udp:5.6.7.8:5060<br>
listen=udp:10.11.12.13:5060</p>
<p>#### DIALOG module<br>
loadmodule "dialog.so"<br>
modparam("dialog", "dlg_match_mode", 1)<br>
modparam("dialog", "default_timeout", 21600)<br>
modparam("dialog", "db_mode", 0)<br>
modparam("dialog", "dlg_sharing_tag", "vip=backup")<br>
modparam("dialog", "dialog_replication_cluster", 3)<br>
modparam("dialog",
"db_url","mysql://opensips:password@localhost/opensips")<br>
</p>
<p>same INVITE block</p>
<p><a class="moz-txt-link-freetext" href="https://blog.voipxswitch.com/2017/12/26/kamailio-high-availability-using-keepalived/">https://blog.voipxswitch.com/2017/12/26/kamailio-high-availability-using-keepalived/</a><br>
</p>
<p>Regards<br>
</p>
<p><br>
</p>
<pre class="moz-signature" cols="72">---
I'm SoCIaL, MayBe</pre>
<div class="moz-cite-prefix">El 13/03/2020 a las 12:20, Sharad Kumar
via Users escribió:<br>
</div>
<blockquote type="cite"
cite="mid:5469a9cf-88ce-1cd2-9893-e80ab01bcc21@protonmail.com">Hi,
<br>
<br>
Can you show us that how you are creating dialogs ? and where are
you setting your sharing tag, like this -
<br>
<br>
set_dlg_sharing_tag("vip");
<br>
<br>
Thank you
<br>
<br>
<br>
_______________________________________________
<br>
Users mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
<br>
</blockquote>
</body>
</html>