Configure SIP gate for Asterisk

Preface
Recently I came to the point when I needed to configure telephony in my Plutohome installation. Maybe it isn’t so complicated task but I spent some time to study Asterisk functionality and resolve some problems with connection Asterisk and Cisco SIP gate. So, I decided put my experience into this brief howto.

Task

I have a Plutohome installation with Asterisk int he house and SIP gate in the office. There is an Internet connection between house and office.

Configuration

To configure Asterisk Plutohome includes Asterisk Management Portal (AMP). Sure it’s possible to modify config files directly but there is a risk of overriding of your changes during system upgrade. So, I used AMP.

Configuring Outbound Routing

First of all we have to define a new trunk. Load AMP – Additional –> Configuration –> Telephony and go to Setup –> Trunks –> Add New Trunk. It’ll be enough to specify just trunk name and its properties:

type=peer
host=your.sip.host/ip
username=your-username
secret=your-password

Basically, only two properties should be mandatory – type and host. In my case I defined a preferable codec to talk with Cisco SIP gate:

disallow=all
allow=g729

By default Plutohome Asterisk misses g723 and g729 codecs which are native for Cisco routers (I guess). We can easily check this fact by connecting to the Asterisk shell
sudo asterisk -r
and run a command
core show translation
Result should be similar to this:

asterisk-codecs

So, you have to download them to your core (choose correct Asterisk version and processor), place them into
/usr/lib/asterisk/modules
and restart Asterisk. If Asterisk doesn’t start or errors appear in the its log try another codec.
If everything ok the picture will be like that

asterisk-codecs

The new SIP trunk will be stored in the sip_additional.conf.

After that we need to define a new rule for outbound calls. There is an one which is already defined – ZAP. I just reassign SIP trunk instead of ZAP and that’s all.

Don’t forget to click on the top of main form to apply changes and restart Asterisk.

Configuring Incoming Calls

Debugging

1. It’s difficult to understand the problem using Asterisk log only. It may give you some idea but to have more details it’s better to use tcpdump (run it on your core):
tcpdump -vvv port 5060 -Xx -s 1600 -w /tmp/asterisk-tcpdump.txt
and then you can load created file to the WhiteShark to read it comfortable.
2. If you see the answer from SIP gate
488 Not Acceptable Media
it’s definitely problem with codecs. See the previous tip to trace the problem and find what codec Asterisk trys to use.
See also