Home » Technology » SIP Proxies Make Asterisk Shine and Save You Money

The Most Versatile VoIP Provider: FREE PORTING

SIP Proxies Make Asterisk Shine and Save You Money

We're going to take a break today and have a little fun by showing how to quickly connect to any other Asterisk® system to make free calls forever! It's been a long time since we discussed SIP proxies and some newer members of the Asterisk community may not appreciate what a cost-saving feature SIP proxies can be in your Asterisk system particularly if you, or your friends, or your business associates have other Asterisk systems in far away places. And, for the experts, yes, we're going to talk about Dundi soon. But, for today, we'll add a little FreePBX secret that wasn't even covered in the excellent FreePBX Training Seminar last week.

To get started, we're going to use dyndns.org as our dynamic SIP proxy server, i.e. to translate fully-qualified domain names (FQDNs) into IP addresses for Asterisk servers. In short, it works much like a DNS server. You type in a domain name, and the SIP proxy server looks up the IP address for you. Why does this all matter you might be asking? Well, when you have access to a "phone number" or account on a remote Asterisk server, you can reach that number through the Internet without paying any connection fees to any hosting provider. In fact, you don't even need a hosting provider to make today's exercise work. It's a pure point-to-point SIP connection from your Asterisk server to another Asterisk server. Think of it as a Skype-to-Skype call: connect for free, talk forever, pay nothing.

The Nerd Vittles Demo. Let's begin with a quick little demo to show how powerful the technology really is. We're going to assume you have an Asterisk system configured with FreePBX such as PBX in a Flash. If not, you'll have to do some reading between the lines. So we're going to add an entry to /etc/asterisk/extensions_custom.conf so that you can make a direct call to our demo hosted server at Aretta Communications in Atlanta by dialing D-E-M-O from any extension on your system. This demo also will give you a good idea why hosted service rocks since our Aretta-hosted PBX in a Flash server is sitting one millisecond off the Internet backbone.

To set this up at your end, log into your Asterisk server as root and issue the following commands only if you don't already have an extension 3366 (demo) on your system. Otherwise, edit the script and change 3366 to an available extension on your PBX.

cd /root
wget http://pbxinaflash.net/scripts/demo.pbx
chmod +x demo.pbx
./demo.pbx

Now go to any phone connected to your Asterisk server and dial D-E-M-O. NOTE: For those using FreePBX 2.4, you may need to add a Misc Destination. If so, call it Demo and enter 3366 as the number to dial. Reload the dialplan when prompted and try the call again. None of the demo apps require a password except for MailCall, option 1. The password is 1234.

Rolling Your Own on the Server-Side Now that you've seen how this works, you're probably wondering how to roll your own. This could be used for dialing into your Asterisk server from any other Asterisk server on the planet. So here's how to set up the server-side of a Poor Man's SIP server:

First, we'd recommend you obtain a fully-qualified domain name from dyndns.org and point it to the IP address of your Asterisk server. This isn't absolutely necessary provided your Asterisk server doesn't have a dynamic IP address. Obviously, if it has a dynamic IP address and your provider changes your IP address, then the SIP route must be adjusted at the client ends that will be making calls to your system.

Second, if you have a default incoming route, do NOT change the No setting for Allow Anonymous Inbound SIP Calls in the General Setting section of FreePBX. Otherwise, anyone can access your PBX from anywhere.

What we want to do instead of opening your system up to total anonymous SIP access is open a small hole for access to a specific extension or IVR (in the case of the demo). So here's how we did it for the demo above on the host system. This hole would normally be added in /etc/asterisk/extensions.conf; however, FreePBX "owns" that file and rewrites it periodically so we don't want to put our new code there. Instead, we will copy the code block from extensions.conf that we want to modify to /etc/asterisk/extensions_override_freepbx.conf. And then we'll add our changes there. Then our modifications won't get stepped on by the next FreePBX reload. The piece we want including our changes (in bold) is shown below so just cut-and-paste it into extensions_override_freepbx.conf. Be sure to examine the quotation marks to be sure WordPress hasn't converted anything to fancy quotes!!

[from-sip-external]
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?from-trunk,${DID},1)
exten => 3366,1,Goto(from-trunk,${DID},1)
exten => demo,1,Goto(from-trunk,3366,1)

exten => s,n,Set(TIMEOUT(absolute)=15)
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,NoOp(Hangup)
exten => i,1,NoOp(Invalid)
exten => t,1,NoOp(Timeout)

Once you've saved the new code, reload your dialplan: asterisk -rx "dialplan reload". Now all we have to do is add an Inbound Route in FreePBX to handle incoming SIP calls to 3366. Click Setup, then Inbound Routes, then Add Incoming Route. For the DID, enter 3366. For the destination, choose an extension, ring group, or IVR to which you want to pass these calls. Submit your change and reload the dialplan when prompted to do so. Your new demo and 3366 anonymous SIP calls are now locked down so that the bad guys can't get into mischief. Remember, no one has to dial a DID (revealing their identity) with anonymous SIP calls... hence the name. All they need is an Internet connection.

Limiting Access By IP Address. In a business environment between branch offices, for example, you might want to further restrict access through direct SIP connections. There's an easy way to do it. Simply replace the 3366 and demo lines of code above with the following using the correct IP address from which you want to permit access. Fancy quote alert applies here, too. All the quotes must look like plain old quotes, not magazine quotes!1

exten => 3366,n,GotoIf($["${SIPCHANINFO(peerip)}"=↩
"69.59.142.143"]?from-trunk,${DID},1)
exten => demo,n,GotoIf($["${SIPCHANINFO(peerip)}"=↩
"69.59.142.143"]?from-trunk,3366,1)

Avoiding NAT Problems. If you get failed calls after setting up both ends, then you may have NAT issues with your router. Add the following code to /etc/asterisk/sip_additional_custom.conf and reload your dialplan:

[from-trunk]
type=user
nat=yes
insecure=very
dtmfmode=rfc2833
context=from-trunk
canreinvite=no
disallow=all
allow=ulaw
allow=gsm

Rolling Your Own on the Client-Side. For anyone that wants to call "SIP direct" to your system, they would simply add an entry in the [from-internal-custom] context of /etc/asterisk/extensions_custom.conf that looks like either one of the following. Either syntax works for the SIP call to the host server since we inserted entries for both 3366 and demo in the from-sip-external context on the host server. Substitute the FQDN or IP address of your own host server for our extra special one (nerdvittles.kicks-ass.net) unless you want to call our demo, of course.

exten => 3366,1,Dial(SIP/3366@nerdvittles.kicks-ass.net) ; demo from Nerd Vittles

or...

exten => 3366,1,Dial(SIP/demo@nerdvittles.kicks-ass.net) ; demo from Nerd Vittles

Now users on the client-side PBX can dial 3366 from any attached phone to reach the destination you set up on the host server. Enjoy!

Free DID and Free Incoming Calls with IPkall. There's one more really cool thing you can do now that you've mastered setting up SIP proxies with Asterisk. You can sign up for a free DID with free incoming calls to your very own Seattle phone number just like Bill Gates. Here's how:

First, in your extensions_override_freepbx.conf file that we created above, add another line that looks like the following and place it just under the demo line in bold. Change the 701 extension to match an actual ring group or extension number on your system and then reload your dialplan: asterisk -rx "dialplan reload".

exten => ipkall,1,Goto(from-trunk,701,1)

Second, go to dyndns.org and sign up for a dynamic host name with the external IP address of your Asterisk system. You can use any name you like... except nerdvittles.kicks-ass.net. That's already taken.

Third, go to IPkall's web site and fill out the form to get your free DID in Seattle. Choose SIP. Choose an area code for your free phone number. For your SIP phone number, enter ipkall. For your SIP proxy, insert the fully-qualified domain name that you chose from dyndns.org. Or you can just use the public IP address of your Asterisk server. Insert your real email address (or you'll never get your phone number) and create a password. Then wait for your email message with your new telephone number. Now call yourself on the number you just received. It doesn't get much easier than that.

Telephone Reminders Update. In case you missed the fun last month, be sure to read all about our new Telephone Reminders System for Asterisk 1.4 that provides phone and web access to schedule reminders. And, we've now added a few more requested features. First, you now can not only review reminders that have been scheduled, but you also can delete those you no longer want. And all of this still is done from the convenience of your web browser. Now you also can send reminders straight to an intercom/paging device on your system as well as directly to voicemail. For details, visit the PBX in a Flash Forum.


 

Special Thanks to Our Generous Sponsors


FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!
 

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.
 


Some Recent Nerd Vittles Articles of Interest...

  1. Join the following line to the original line of code whenever you encounter the ↩ character. []

5 Comments

  1. You may configure IPKALL through FREEPBX by adding a SIP trunk.
    simply fill in the incoming setting without registering:
    USER CONTEXT: 588
    type=peer
    insecure=very
    host=voiper.ipkall.com
    dtmfmode=rfc2833
    disallow=all
    context=from-trunk
    allow=g729 (or ulaw)
    And that’s it. no need for user name or password..
    One more thing: Dynamic DNS can also be obtained from http://www.no-ip.com, for free.

  2. For some reason, I have only been able to get one way audio with IPKall. I have had this problem for years and have never been able to resolve the issue. The correct ports are open on my router. I can use other sip services. The only one that wont work is IPKall.

    [WM: In your sip_custom.conf file, have you added the code below using the external ip and internal subnet for your network? Also be sure to read the new section in the article about Avoiding NAT Problems.]
    [code]
    externip=66.56.246.186
    localnet=192.168.0.0/255.255.255.0
    [/code]

  3. Thanks Ward for burning your midnight oil and telling us of this feature. Yes we too did the trunk setup like adorah above said. You always help us keep our bells ringing, to a different tone.

  4. Adorah setup here is incomplete and I couldn’t figure out the problem… but here’s how to add IPKall as a Sip Trunk in FreePBX thanks to http://www.voip-info.org/wiki/view/IPKall

    Settings for add Trunk in freepbx

    1. click add sip trunk
    2. leave everything blank except the following items

    Outgoing Settings

    Trunk Name: ipkall
    Peer Details:

    context=from-pstn
    host=voiper.ipkall.com
    type=peer

    Incoming Settings

    ***** USER Context from-trunk *** I changed this to be able to use it without changing a thing… I changed from-external as the USER Context to the number I want to use in the Phone Number in IPKall

    USER Context: 98765

    USER Details:

    allow=g729
    context=from-trunk
    disallow=all
    dtmfmode=rfc2833
    host=voiper.ipkall.com
    insecure=very
    type=peer

    Now in IPKall I would use Phone Number 98765 server address mypbx.dyndns.org
    My sip address in this example is 98765@mypbx.dyndns.org

    Thanks for everything!

Comments are closed.