Asterisk and Sipgate

This is a short description on how to get your Asterisk machine to work with sipgate.de. A lot of people seem to have some trouble with this. I assume for this document that you have some basic knowledge with Asterisk already or have at least setup your Asterisk server already.

Here are some terms I use in this document:

  • PSTN: Public Switched Telefphone Network, the normal telephone network
  • SIP: Session Initiation Protocol, a protocal for doing VoIP calls

Prerequisits

Of course you need a Sipgate account for this to work. With Sipgate you can get a PSTN->SIP number. This number is free of charge and if you only receive calls or only make SIP->SIP calls, it will stay free of charge. If you however want to do calls to the PSTN, you need to put some money into your account.

Configuring Asterisk

There are two files which are of interest. One is the file sip.conf and the other is extensions.conf, both files can be found in the Asterisk configuration directory, usually this is /etc/asterisk/.
I always think that showing an example configuration is the easiest way to start, so here are the relevant parts from my sip.conf file:

[general]
port = 5060
bindaddr = 0.0.0.0
context = default
register => SIPGATENUM:PASSWD@sipgate.de/SIPGATENUM

[SIPGATENUM]
type=peer
username=SIPGATENUM
fromuser=SIPGATENUM
secret=PASSWD
context=default
host=sipgate.de
fromdomain=sipgate.de
insecure=very
caninvite=no
canreinvite=no
nat=no
disallow=all
allow=ulaw
allow=alaw

[sipgate_de_in]
type=peer
fromdomain=sipgate.de
host=sipgate.de
context=incoming
diallow=all
allow=ulaw
allow=alaw

Replace all occurences with SIPGATENUM with your 7-digit Sipgate number and of course PASSWD with your Sipgate password. Note that you must truncate the first two digits of the Sipgate number (41 in my case) to get your 7-digit number.
In the "general" section, we specified that we will be registering with Sipgate. In the part of your Sipgate number, we specified a number of things. These entries worked best for me. Note that I only allowed aLaw and uLaw encoding here to have a good voice quality. You can also specify other codecs to use here if you have a low bandwidth. On this page Sipgate informs about the codecs which are supported.
In the "sipgate_de_in" section, I specify in which context to go when a call comes in from sipgate.de. This is the context incoming. This context will be needed in the extensions.conf file:

[general]
exten => _0.,1,NoOp(Call via sipgate.de)
exten => _0.,2,Ringing
exten => _0.,3,SetCallerID(John Doe)
exten => _0.,4,Dial(SIP/${EXTEN:1}@SIPGATENUM,60)
exten => _0.,5,Hangup

[incoming]
exten => SIPGATENUM,1,NoOp(Incoming call on sipgate.de)
exten => SIPGATENUM,2,Ringing
exten => SIPGATENUM,3,Wait(1)
exten => SIPGATENUM,4,Dial(IAX2/christoph&SIP/30&${CONSOLE},30)
exten => SIPGATENUM,5,VoiceMail(u30)
exten => SIPTAGETNUM,6,Hangup

Again replace all occurances of SIPGATENUM with your Sipgate number as above.
So, in the "general" section of this file, I specified that when dialing "0" plus the number that I want to dial, the call should go out over my Sipgate account. Actually part 4 of the "0"-extension is the most crucial part. Here it says that Asterisk should dialout using the SIP protocol with the entry specified in sip.conf under the SIPGATENUM (this is the entry block that we created in sip.conf earlier). There's also a timeout given. The first "0" that was dialed to get into the extension will be truncated from the number that is passed on to Sipgate.
The "incoming" section gets called when a call comes in via Sipgate. We specified this earlier in the sip.conf file under the "sipgate_de_in" section. Here you have to set the extension number to your Sipgate number in order for this to work. Here we let the user wait a bit until we finally again come to the most important part 4. In part 4, the call is forwared via the IAX2 protocol to the user registered under the name "christoph", also forwarded via the SIP protocol to the registered user "30" and also forwarded to the Asterisk console. All this is done for 30 seconds. After that the call gets sent to voicemail. Of course you can also leave out the voicemail stuff because it must be configured too.
You have to modify part 4 to fit your needs! Maybe it is easiest to simply have it sent to the Asterisk console at first to see if it's working.

I hope this helped to get you started, have fun playing with Asterisk.

Comments

2 inbound sipgate accounts

Thank-you for an extremely helpful article - I have trawled the net but only here found how to set up my Sipgate account with asterisk correctly. However, I am now trying to have 2 inbound Sipgate accounts but am finding this impossible to implement.

I am trying to have 2 inbound Sipgate.co.uk numbers into my Linux Asterisk box. When I register one number on Asterisk all is OK. If I add a second number, however, Asterisk stops recognising the first for INBOUND calls. I have seen this problem mentioned in other discussion forums but have not seen a solution.

Does anyone know if it is a Sipgate policy not to allow 2 numbers to be registered on an * box for inbound calls? If not, any workarounds for this problems spring to mind?

Sip Show Registry confirms that both numbers remain registered on Asterisk even though the first number stops functioning.

Thanks agin for an excellent article.

Re: 2 inbound sipgate accounts

Hi!

I have configured this at my box. Show my your sip.conf and extensions.conf and I can help you. I have two numbers configured for my box at Sipgate, however with sipgate.de... maybe they have a policy at co.uk, however I doubt it. I'm sure we can work this out.
If you wanna get in touch quicker, than through the comments here, send me an E-Mail. However I will post the parts of the sip.conf and extensions.conf here later.