Enswitch installation on AWS

From Integrics Wiki
Revision as of 14:25, 24 April 2025 by Vlasis (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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