Opening Firewall Ports: Amazon - EC2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4
At a glance
Powered by AI
Some key things to configure for FreeSWITCH on EC2 include opening firewall ports for SIP and RTP, updating the kernel timer to 1000Hz, and configuring the external SIP and RTP IPs. The documentation provides guidance on these configuration steps.

The steps include opening firewall ports for SIP/RTP, updating the kernel timer, and configuring the external SIP and RTP IPs in the configuration files by setting the bind_server_ip, external_rtp_ip, and external_sip_ip variables.

The configuration files that need changes are vars.xml, sip_profiles/internal.xml, sip_profiles/external.xml, and switch.conf.xml. Parameters like aggressive-nat-detection, ext-rtp-ip, ext-sip-ip, and rtp port ranges need to be configured.

Amazon_EC2

Contents
1 Getting Started 1.1 Opening Firewall Ports 1.1.1 SIP 1.1.2 RTP 1.1.3 Additional EC2 NAT Notes 1.2 Sofia External IP Config 1.3 Updating Kernel Timer to 1000HZ 2 FAQ 2.1 Q: What distro should I use? 2.2 Q: Are there any public AMI images with FreeSWITCH pre-installed? 2.3 Q: Can I run this as a production switch? 3 External Links

Getting Started
There is not much difference between running on Amazon Elastic Cloud than any other Linux server, but here are a few things to keep in mind.

Opening Firewall Ports


SIP
ec2-authorize default -P udp -p 5060

RTP
ec2-authorize default -P udp -p 16384-32768

The RTP port range given should match your configuration in switch.conf.xml.

Additional EC2 NAT Notes For SIP, setup a security group with the following ports enabled (easiest to do with Elasticfox):
udp udp udp tcp udp tcp tcp udp 16384:32768 4569 5060 5060 5080 5080 8000 8000

Contents

Amazon_EC2 Make sure you make the security group, and apply it before you boot the instance. After this, the quick and dirty install guide worked just fine for me. You'll just need to tweak the default dialplan to your needs. You may also need to make some of the following changes, particularly the external sip and RTP IPs (for which you will need to create an Elastic IP and attach it to your Instance.) conf/vars.xml
<X-PRE-PROCESS cmd="set" data="bind_server_ip=<AWS EIP>"/> <X-PRE-PROCESS cmd="set" data="external_rtp_ip=<AWS EIP>"/> <X-PRE-PROCESS cmd="set" data="external_sip_ip=<AWS EIP>"/>

conf/sip_profiles/internal.xml
<param <param <param <param <param <param <param <param <param name="aggressive-nat-detection" value="true"/> name="multiple-registrations" value="true"/> name="ext-rtp-ip" value="$${external_rtp_ip}"/> name="ext-sip-ip" value="$${external_sip_ip}"/> name="NDLB-received-in-nat-reg-contact" value="true"/> name="NDLB-force-rport" value="true"/> name="NDLB-broken-auth-hash" value="true"/> name="enable-timer" value="false"/> name="auth-calls" value="true"/>

conf/sip_profiles/external.xml
<param <param <param <param name="aggressive-nat-detection" value="true"/> name="ext-rtp-ip" value="$${external_rtp_ip}"/> name="ext-sip-ip" value="$${external_sip_ip}"/> name="NDLB-force-rport" value="true"/>

conf/autoload/switch.conf.xml
<param name="rtp-start-port" value="16384"/> <param name="rtp-end-port" value="32768"/>

Sofia External IP Config


You shouldn't have to make any changes to the Sofia profile. The FreeSWITCH Auto NAT feature will take care of this automatically. However, if you want to do this manually, edit the sip_profiles/internal.xml file and replace auto-nat with the external IP address in the ext-rtp-ip and ext-sip-ip parameters.

Updating Kernel Timer to 1000HZ


If using Ubuntu on EC2 (and elsewhere) the kernel timer is by default set to 100HZ or 250HZ which will lead to worse call-quality. You can use the following steps to change this setting and recompile the kernel. (These were used on Ubuntu Lucid 10.04, but should work for newer versions too.)
#Shows the current kernel timer settings: cat /boot/config-`uname -r` | grep HZ #Add multiverse to your sources if it isn't already

Additional EC2 NAT Notes

Amazon_EC2
aptitude -y build-dep linux-image-$(uname -r)

aptitude -y install libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev kernel-package c cd /usr/src # This is 700mb so it takes a while to download and set up git clone git://kernel.ubuntu.com/ubuntu/ubuntu-lucid.git cd ubuntu* git checkout --track -b ec2 origin/ec2 fakeroot debian/rules clean

fakeroot debian/rules editconfigs #Choose: yes for amd64 -> Processor type and features -> Timer frequency -> change to 1000HZ (cha # this takes about 40min on a large instance fakeroot debian/rules binary #check an image deb file was created cd .. ls *.deb #Install dpkg -i linux-*.deb #Reboot instance cat /boot/config-`uname -r` | grep HZ # If not changed, then edit (towards the end of) /boot/grub/menu.lst

replacing the current kern

If you need more help then the #ubuntu-kernel IRC channel is the best place to ask, also read these pages: [1] [2] [3] [4]

FAQ
Q: What distro should I use?
Its up to you! However, some recommend CentOS.

Q: Are there any public AMI images with FreeSWITCH pre-installed?


As of September 3, 2008, running
ec2-describe-images -x all | grep freeswitch

from the Amazon cloud command line utility yields:


IMAGE IMAGE ami-999672f0 ami-1be30672 freeswitch-fedora-6-svn-rev-9178/image.manifest.xml rbuilder-online/freeswitch-0.0.1-x86_11952.img.manifest.xml

811137716

099034111

Updating Kernel Timer to 1000HZ

Amazon_EC2
IMAGE ami-dae306b3 rbuilder-online/freeswitch-0.0.1-x86_11963.img.manifest.xml

099034111

NOTE: These are very old versions of FreeSWITCH. Your best bet will be to checkout the latest FS trunk and build a fresh copy on your EC2 instance. There's a more updated AMI available on EU region: foneAPI-generic-32bit-freeswitch-v1 (works very good on High-CPU Medium Instance - c1.medium)

Q: Can I run this as a production switch?


A small instance is not recommended for running FreeSWITCH in production, however you should be happy with a High CPU Medium instance. Experiences: From Cfurmori in May 2009: I wouldn't recommend running FreeSWITCH in production on Amazon EC2. I purchased a 1 year instance of a small server setup and used a base CentOS 5.3 image 32-bit x86. Built FreeSWITCH from the latest snapshot and it worked great for dev and testing purposes but the call quality was pretty bad at times. I spent a fair amount of time tuning / testing / watching resource utilizations running a 4 person conference and I would see an average of 0.5 to 1.0 second audio delay. I tried with direct SIP phone registrations and through a SIP trunk provider, same results. EC2 is a great dev/test platform but I would say your best to run a realtime voice application on a physical server. You can virtualize voice systems but they need to be designed and engineered by someone that knows what they are doing. A mailing list user said in March 2010: "We run FreeSWITCH on AWS' EC2. A medium EC2 instance is happily supporting 100 Polycom users, conference bridges etc. Been running for over a year. We also use FlowRoute as our PSTN->SIP Interface, and also Skype Business SIP. Our users are scattered across the globe - so having the box sitting on AWS' network infrastructure is key to avoiding issues with latency, jitter, packet loss (i.e. I don't think we could afford the connectivity AWS gives us if we had to provision this in-house)."

External Links
Amazon EC2 subwiki - Getting started guide and links to documentation.

Q: Are there any public AMI images with FreeSWITCH pre-installed?

You might also like