Enswitch installation on AWS: Difference between revisions

From Integrics Wiki
Jump to navigation Jump to search
Content deleted Content added
Vlasis (talk | contribs)
No edit summary
Vlasis (talk | contribs)
No edit summary
Line 20: Line 20:
Index: etc/kamailio/kamailio_58.cfg
Index: etc/kamailio/kamailio_58.cfg
===================================================================
===================================================================
--- etc/kamailio/kamailio_58.cfg (revision 21219)
--- etc/kamailio/kamailio_58.cfg (revision 21240)
+++ etc/kamailio/kamailio_58.cfg (working copy)
+++ etc/kamailio/kamailio_58.cfg (working copy)
@@ -334,6 +334,11 @@
@@ -334,6 +334,11 @@
Line 26: Line 26:
}
}
if ( is_method( "INVITE" ) ) {
if ( is_method( "INVITE" ) ) {
+ #!ifdef AWS_EXTERNAL_IP
+ # AWS start
+ if ( src_ip == AWS_INTERNAL_IP ) {
+ if ( src_ip == AWS_INTERNAL_IP ) {
+ fix_nated_sdp("3",AWS_EXTERNAL_IP);
+ fix_nated_sdp("3",AWS_EXTERNAL_IP);
+ }
+ }
+ # AWS end
+ #!endif
$var(pai_count) = 0;
$var(pai_count) = 0;
while( defined $(hdr(P-Asserted-Identity)[$var(pai_count)]) ) {
while( defined $(hdr(P-Asserted-Identity)[$var(pai_count)]) ) {
$var(pai_count) = $var(pai_count) + 1;
$var(pai_count) = $var(pai_count) + 1;
@@ -359,6 +364,12 @@
@@ -359,6 +364,11 @@
if ( is_method( "BYE" ) ) {
if ( is_method( "BYE" ) ) {
t_on_branch( "BRANCH" );
t_on_branch( "BRANCH" );
}
}
+ #!ifdef AWS_EXTERNAL_IP
+
+ # AWS start
+ if ( is_method( "SUBSCRIBE" ) ) {
+ if ( is_method( "SUBSCRIBE" ) ) {
+ set_advertised_address( AWS_INTERNAL_IP );
+ set_advertised_address( AWS_INTERNAL_IP );
+ }
+ }
+ #!endif
+
if ( ! t_relay() ) {
if ( ! t_relay() ) {
sl_reply_error();
sl_reply_error();
}
}
@@ -368,6 +379,11 @@
@@ -368,6 +378,11 @@
onreply_route[ REPLY ] {
onreply_route[ REPLY ] {
if ( sdp_content() ) {
if ( sdp_content() ) {
$avp(ENSWITCH-CIPHERS-SAFE) = $rb;
$avp(ENSWITCH-CIPHERS-SAFE) = $rb;
+ #!ifdef AWS_EXTERNAL_IP
+ # AWS start
+ if ( src_ip == AWS_INTERNAL_IP ) {
+ if ( src_ip == AWS_INTERNAL_IP ) {
+ fix_nated_sdp("3",AWS_EXTERNAL_IP);
+ fix_nated_sdp("3",AWS_EXTERNAL_IP);
+ }
+ }
+ # AWS end
+ #!endif
}
}
force_rport();
force_rport();
@@ -494,6 +510,10 @@
@@ -494,6 +509,9 @@
# enforce routing to sipd
# enforce routing to sipd
rewritehostporttrans("127.0.0.1:5080;transport=udp");
rewritehostporttrans("127.0.0.1:5080;transport=udp");
remove_hf( "Route" );
remove_hf( "Route" );
+ #!ifdef AWS_EXTERNAL_IP
+ # AWS start
+ set_advertised_address( AWS_INTERNAL_IP );
+ set_advertised_address( AWS_INTERNAL_IP );
+ # AWS end
+ #!endif
+
route( FORWARD );
route( FORWARD );
exit;
exit;

Revision as of 14:25, 24 April 2025

How to set up Enswitch on a single machine cluster on AWS

This set up has been tested successfully on an Enswitch 4.0 single machine cluster with Kamailio 5.8.2 and Asterisk 13.38.3:

  • Under the global configuration, create two machines, one for the internal IP address and FQDN and the other for the external IP and FQDN. Set only the internal address machine to accept calls as an Asterisk server.
  • Under the global configuration, create domains for the internal IP address, the internal FQDN, the external IP and the external FQDN.
  • Under the global configuration, set the "Message daemon IP address" to be the internal IP address.
  • Edit /etc/kamailio/kamailio.cfg as below:
listen = udp:<internal IP>:5060 advertise <external IP>:5060
listen = tcp:<internal IP>:5060 advertise <external IP>:5060

# AWS
#!define AWS_INTERNAL_IP <internal IP>
#!define AWS_EXTERNAL_IP "<external IP>"
  • Edit /opt/enswitch/current/etc/kamailio/kamailio_58.cfg as below:
Index: etc/kamailio/kamailio_58.cfg
===================================================================
--- etc/kamailio/kamailio_58.cfg	(revision 21240)
+++ etc/kamailio/kamailio_58.cfg	(working copy)
@@ -334,6 +334,11 @@
 		}
 	}
 	if ( is_method( "INVITE" ) ) {
+		#!ifdef AWS_EXTERNAL_IP
+		if ( src_ip == AWS_INTERNAL_IP ) {
+		        fix_nated_sdp("3",AWS_EXTERNAL_IP);
+		}
+		#!endif
 		$var(pai_count) = 0;
 		while( defined $(hdr(P-Asserted-Identity)[$var(pai_count)]) ) {
 			$var(pai_count) = $var(pai_count) + 1;
@@ -359,6 +364,11 @@
 	if ( is_method( "BYE" ) ) {
 		t_on_branch( "BRANCH" );
 	}
+	#!ifdef AWS_EXTERNAL_IP
+	if ( is_method( "SUBSCRIBE" ) ) {
+		set_advertised_address( AWS_INTERNAL_IP );
+	}
+	#!endif
 	if ( ! t_relay() ) {
 		sl_reply_error();
 	}
@@ -368,6 +378,11 @@
 onreply_route[ REPLY ] {
 	if ( sdp_content() ) {
 		$avp(ENSWITCH-CIPHERS-SAFE) = $rb;
+		#!ifdef AWS_EXTERNAL_IP
+		if ( src_ip == AWS_INTERNAL_IP ) {
+		        fix_nated_sdp("3",AWS_EXTERNAL_IP);
+		}
+		#!endif
 	}
 
 	force_rport();
@@ -494,6 +509,9 @@
 		# enforce routing to sipd
 		rewritehostporttrans("127.0.0.1:5080;transport=udp");
 		remove_hf( "Route" );
+		#!ifdef AWS_EXTERNAL_IP
+		set_advertised_address( AWS_INTERNAL_IP );
+		#!endif
 		route( FORWARD );
 		exit;
 	}
  • - In /etc/asterisk/sip.conf add a local-public, a local-private, a public IP and a private IP stanza, eg:
[enswitch-local-public]
host = <external IP>
fromdomain = <external IP>
type = friend
insecure = port,invite
context = from-internal
canreinvite = no
nat = yes
t38pt_udptl = yes

[enswitch-local-private]
host = <internal IP>
fromdomain = <internal IP>
type = friend
insecure = port,invite
context = from-internal
canreinvite = no
nat = yes
t38pt_udptl = yes

[<external IP>]
host = <external IP>
fromdomain = <external IP>
type = friend
insecure = port,invite
context = from-internal
canreinvite = no
nat = yes
t38pt_udptl = yes

[<internal IP>]
host = <internal IP>
fromdomain = <internal IP>
type = friend
insecure = port,invite
context = from-internal
canreinvite = no
nat = yes
t38pt_udptl = yes