Thursday, April 21, 2011

Asterisk recepie for Openwrt

$ opkg update
$ opkg install asterisk18 asterisk18-codec-ulaw asterisk18-codec-g726 asterisk18-codec-g722 asterisk18-codec-alaw

root@OpenWrt:~# cat /etc/asterisk/sip.conf
[general]
port = 5060
bindaddr = 0.0.0.0
context = default

[1000]
type=friend
secret=1000
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file

[1001]
type=friend
secret=1001
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file

[1002]
type=friend
secret=1002
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file

root@OpenWrt:~# cat /etc/asterisk/extensions.conf
[others]

[internal]
exten => 1000,1,Dial(SIP/1000)
exten => 1001,1,Dial(SIP/1001)
exten => 1002,1,Dial(SIP/1002)

# /etc/init.d/asterisk restart

Firewall

add the following to /etc/config/firewall to allow SIP traffic

config rule
option src wan
opption proto tcp
option dest_port 5060
option target ACCEPT

Reload your firewall rules
# /etc/init.d/firewall reload

Examine firewall rules and check that 5060 is accepted on zone WAN
# iptables -L -v

Install dyndns.org update script
opkg update
opkg install ddns-scripts
vi /etc/config/ddns

Wednesday, April 20, 2011

Asterisk recepie for Ubuntu

This guide will show how to install a small asterisk PBX in the cloud on a VPS that you and your friends can use to call each other for free using SIP applications on Android, Iphone and Ipad. I have tested this configuration with Sipdroid(Android) and Acrobits Softphone(Iphone,Ipad).

$ sudo apt-get install puppet

file asterisk.pp, please change node name styx to your hostname, please change secrets
###########
class asterisk
{
package { "asterisk": ensure => installed }
exec { "sip.conf" : command => "/bin/echo '
[general]
port = 5060
bindaddr = 0.0.0.0
context = default

[1000]
type=friend
secret=1000
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file

[1001]
type=friend
secret=1001
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file

[1002]
type=friend
secret=1002
#qualify=yes ;latency must be under 2000ms.
nat=yes
host=dynamic ; the devices can be registered with different IPs each time
canreinvite=no ; Asterisk by default redirects
context=internal ; the context of the extensions.conf file
' > /etc/asterisk/sip.conf"
}

exec { "extensions.conf" :
command => "/bin/echo '
[others]

[internal]
exten => 1000,1,Dial(SIP/1000)
exten => 1001,1,Dial(SIP/1001)
exten => 1002,1,Dial(SIP/1002)
' > /etc/asterisk/extensions.conf"
}
}


node styx
{
include asterisk
}


$ sudo puppet -d asterisk.pp

After this you may need to restart asterisk
$ sudo service asterisk restart