Search code examples
google-cloud-platformsiptelephonyfreeswitchsip-server

Installing Freeswitch on Google Cloud VM


I have installed Freeswitch (centos7) on a Google Cloud VM. This is just a test instance.

Haven't made any changes to the config yet.

The server starts up fine but I can't get any audio through while testing. Have opened the firewall as per the link: https://freeswitch.org/confluence/display/FREESWITCH/Firewall

The freeswitch logs show the call coming in and the audio being sent out.

Would someone be able to suggest anything to help me resolve this?

Regards vm


Solution

  • After looking around a bit it looks like there are some gotchas with running Freeswitch on a cloud provider. So far there is official documentation about running it on Amazon EC2, and it says it's not officially supported. I'll try to adapt it to Google Cloud Platform, maybe this will work for you.

    1 - Create a Debian Jesse 8 instance

    gcloud compute instances create freeswitch-test --image-family debian-8 --image-project debian-cloud --tags=freeswitch
    

    2 - Create the required firewall rules to open the ports it needs to run. From the documentation looks it should be UPD:16384-32768,TCP:8081-8082,TCP/UDP:5060,UDP:4569,TCP/UDP:8000

     gcloud compute firewall-rules create freeswitch-policy --allow UDP:16384-32768,TCP:8081-8082,TCP:5060,UDP:5060,UDP:4569,TCP:8000,UDP:8000 --source-ranges=0.0.0.0/0 --target-tags=freeswitch
    

    Then you want freeswitch to be able to know its external IP when it starts up. I think the best way might be to reserve a static IP and then create a forwarding rule:

    gcloud compute addresses create freeswitch-ip --region us-east1
    gcloud compute target-pools create freeswitch --region us-east1
    gcloud compute target-pools add-instances freeswitch --instances freeswitch-test --instances-zone us-east1-b
    gcloud compute forwarding-rules create freeswitch-forwarding --address freeswitch-ip --region us-east1 --target-pool   freeswitch
    

    Now to configure the static IP on freeswitch:

    conf/vars.xml
    
    <X-PRE-PROCESS cmd="exec-set" data="bind_server_ip=[YOUR-IP]">
    <X-PRE-PROCESS cmd="exec-set" data="[YOUR-IP]"/>
    <X-PRE-PROCESS cmd="exec-set" data="[YOUR-IP]"/>
    
    
    
    conf/sip_profiles/internal.xml
    
    <param name="aggressive-nat-detection" value="true"/>
    <param name="multiple-registrations" value="true"/>
    <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
    <param name="ext-sip-ip" value="$${external_sip_ip}"/>
    <param name="NDLB-received-in-nat-reg-contact" value="true"/>
    <param name="NDLB-force-rport" value="true"/>
    <param name="NDLB-broken-auth-hash" value="true"/>
    <param name="enable-timer" value="false"/>
    <param name="auth-calls" value="true"/>
    
    
    conf/sip_profiles/external.xml
    
    
    <param name="aggressive-nat-detection" value="true"/>
    <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
    <param name="ext-sip-ip" value="$${external_sip_ip}"/>
    <param 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"/>