Asterisk Installation

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Goto page Previous  1, 2, 3, ... 27, 28, 29  Next
Author Message
bgeery
DD-WRT Novice


Joined: 11 Apr 2009
Posts: 7

PostPosted: Sun Apr 19, 2009 19:39    Post subject: Reply with quote
what we need is a wiki page with instructions that get us to the point of a working web GUI. After that, it's up to the user to set * up properly. There is plenty of help online for * configuration.
Sponsor
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Thu Apr 23, 2009 14:54    Post subject: Reply with quote
I've got asterisk working on my Asus, but I still have 2 problems.
One is that I can't reach the Asterisk from outside.

I have entered a forward in the webpage and added an iptables rule
Code:
iptables -I INPUT 1 -p udp --dport 5060 -d 192.168.10.1 -j ACCEPT

The same is working for my reverse proxy.

The other problem is that I can call with only one telco-provider of the 2 I have installed, but that might be related to the provider.

Can anyone tell me if he can register from outside the network and if an iptables entry is needed?


Edit: I solved my problem with outgoing calls by using srvlookup (your SIP-provider does need to have it). Test it by issuing:
Code:
# host -t SRV _sip._udp.sipsrv.sipnl.net
_sip._udp.sipsrv.sipnl.net has SRV record 10 33 5060 psip1.sipnl.net.
_sip._udp.sipsrv.sipnl.net has SRV record 10 33 5060 psip2.sipnl.net.
_sip._udp.sipsrv.sipnl.net has SRV record 10 34 5060 psip3.sipnl.net.

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Apr 24, 2009 5:33    Post subject: Reply with quote
I can already post some of my setup.
To make things with optware I have in the past made a mechanism on my router to automatically start services. I created the directory /opt/etc/init.d and all scripts starting with S* are started automatically. Because the directory does not exist at startup I've created a loop which can last for 4 minutes from startup in which it tries to look in /opt/etc/init.d
This is my startup script (administration->commands ->startup)

optware extension:

Code:
echo -e "#!/bin/sh\nn=1\nwhile sleep 3\ndo\n\t[ -d /opt/etc/init.d ] && break\n\t[ \$n -gt 120 ] && break\n\tlet n+=1\ndone" >/tmp/S90optware
echo -e "\nfor f in /opt/etc/init.d/S* ; do\n\t[ -x \$f ] && \$f start\ndone" >>/tmp/S90optware
chmod +x /tmp/S90optware
/tmp/S90optware &


Of course you also need a script which stops all these services when the router goes down:
Code:
for f in /opt/etc/init.d/K* ; do
[ -x $f ] && $f stop
done


All this can be used for other services like samba.


I have 8MB flash on my Asus WL-500 premium, so I can use Brainslayer's mega-version which includes asterisk (Eko's version doesn't include asterisk). If you have 4MB router but USB you can install optware on an USB-stick. I don't know if you can install asterisk using only jffs (don't think so), without usb and small flash you can still make an mmc hardware mod.

asterisk:

In /opt/etc/init.d I've created this script:
# cat /opt/etc/init.d/S90asterisk
Code:
#!/bin/sh

prefix=/usr              # change this to /opt if you want to run the version in optware
astetc=/opt/etc/asterisk
cfg=$astetc/asterisk.conf
astscript=$astetc/asterisk.sh
astlogdir=`grep astlogdir ${cfg} 2>/dev/null | awk -F "=>" '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'`

PATH=${prefix}/bin:${prefix}/sbin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=asterisk
DAEMON=${prefix}/sbin/${NAME}

if [ ! -x ${DAEMON} ] ; then
  prefix=/opt
  DAEMON=${prefix}/sbin/${NAME}
  if [ ! -x ${DAEMON} ] ; then
    echo "Asterisk is not (properly) installed on your system" >&2
    exit 1
  fi
fi

if [ -z "${astlogdir}" ] ; then
  if [ ! -e "$cfg" ] ; then
    echo "$cfg not found.. exiting"
    exit 1
  fi
  echo "I can not determine the directory in which logfiles should be placed (no astlogdir in ${cfg}?)" >&2
  exit 1
fi
if [ ! -d "${astlogdir}" ] ; then
  echo "The directory ${astlogdir} does not exist" >&2
  exit 1
fi

if [ -z "$1" ] ; then
    case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
        S??*) rc="start" ;;
        K??*) rc="stop" ;;
        *) rc="usage" ;;
    esac
else
    rc="$1"
fi

case "$rc" in
    start)
        echo "Starting $NAME"
        if [ -n "`pidof $NAME`" ]; then
            echo "$NAME already running" >&2
        else
            if [ ! -e $cfg ]; then
              echo "missing $cfg" >&2
              exit 1
            fi
            [ -z "`uptime | grep " min"`" ] || rm ${astlogdir}/messages
            $DAEMON -m -C $cfg >/dev/null &
        fi
        if [ ! -e /tmp/www/cgi-bin/asterisk ]; then
          if [ -f $astscript ]; then
            echo "Copying webscript"
            mkdir -p /tmp/www/cgi-bin
            ln -s "${astscript}" /tmp/www/cgi-bin/asterisk
          else
            echo "Webscript (${astscript}) NOT found.. NO websupport"
          fi
        fi
        ;;
    stop)
        if [ -n "`pidof $NAME`" ]; then
            echo "Stopping $NAME"
            killall $NAME 2> /dev/null
        else
            echo "$NAME already stopped"
            exit 1
        fi
        ;;
    restart)
        "$0" stop
        sleep 1
        "$0" start
        ;;
    status)
        if [ -n "`pidof $NAME`" ]; then
            $DAEMON -V
            $DAEMON -rx "core show channels"
            echo -e "\nCurrent Dialplan:\n"
            $DAEMON -rx "dialplan show"
            echo -e "\nLogfile:"
            tail ${astlogdir}/messages
        else
            echo "$NAME is not running"
            exit 1
        fi
        ;;
    *)
        echo "Usage: $0 (start|stop|restart|usage|status)"
        ;;
esac

exit 0

On the prompt create this symbolic link:
Code:
ln -s /opt/etc/init.d/S90asterisk /opt/etc/init.d/K10asterisk


Place configs in /opt/etc/asterisk
cat /opt/etc/asterisk/asterisk.conf
Code:
[directories]
astetcdir => /opt/etc/asterisk
;astmoddir => /opt/lib/asterisk/modules
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /opt/var/lib/asterisk
astdatadir => /opt/var/lib/asterisk
astagidir => /opt/var/lib/asterisk/agi-bin
astspooldir => /opt/var/spool/asterisk
astrundir => /var/run
astlogdir => /opt/var/log/asterisk

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)


Last edited by frater on Sat Jul 04, 2009 5:46; edited 2 times in total
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Fri Apr 24, 2009 6:59    Post subject: Reply with quote
frater wrote:
I have 8MB flash on my Asus WL-500 premium, so I can use Brainslayer's mega-version which includes asterisk
Where did you find that version? Can you post some info about that build, and a link to download?
Since I didn't know that a version with built-in Astersik exists, I used EKO's build, with a USB stick.
I remember asking on the forum what do people recommend for asterisk, all experts said that EKO+Optware is the only solution. Nobody mentioned that there is actually a build containing Asterisk inside.
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Fri Apr 24, 2009 7:39    Post subject: Reply with quote
cpe-eagle wrote:
I am wondering, I have a WRT54GS v3 with DD-WRT build 11793 w/voip is it hard to install asterisk onto it?
Hi!

I successfully installed Asterisk v1.4 onto DD-WRT build 11793 mega (on Asus WL-500G Premium) like this:
- enabled and cleared JFFS partition in the WEB GUI
- prepared a USB stick with Ext3, mounted to /opt in the WEB GUI (I guess FAT would also do fine, and other SD/MMC mods too)
- installed Optware according to this
- installed asterisk14 with command
Code:
/opt/bin/ipkg-opt  --tmp-dir /tmp install asterisk14
also installed the same way asterisk14-core-sounds-en-g729, asterisk14-extra-sounds-en-g729, asterisk14-moh-freeplay-g729, and what else I needed
- installed a very nice small GUI called Asterisk Management script from here. This webpage lists not only the GUI, but all the startup scripts and what else you need to do in order to make it work. (You only need to follow these steps from point 3. Install Asterisk for DD-WRT: Install Optware startup script, Install startup scripts, Install Asterisk Management script)

Works very nice!
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Apr 24, 2009 15:22    Post subject: Reply with quote
robertut wrote:
frater wrote:
I have 8MB flash on my Asus WL-500 premium, so I can use Brainslayer's mega-version which includes asterisk
Where did you find that version? Can you post some info about that build, and a link to download?

Every Brainslayer Mega-version published in 2009 contains Asterisk. Hence its bigger size.

No GUI-support though.. Just the barebone binaries.

Alas this link didn't give me any new info on how to handle registration from the Internet...
Can you tell me if you can register a phone from the Internet on your router?

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Apr 24, 2009 17:13    Post subject: Reply with quote
I found that webscript very usefull so I included that file in my S90asterisk (I changed my previous post to reflect that change)

The seperate startup-script for this webpage was too comprehensive for such a simple task (checking for existence of dir before creating one... my god it's a ramdisk). I also found it wiser to use a symbolic link instead of a copy (saves valuable RAM-space)

This symbolic link is called "asterisk" instead of "asterisk.sh" so the link becomes: http://192.168.1.1/user/cgi-bin/asterisk

You can download the (slightly) modified script here:
Code:
cd /opt/etc/asterisk
wget http://wd.mirmana.com/asterisk.sh


These are the differences:
Code:
21c21
< asterisk_version="1.2"
---
> asterisk_version="1.4"
27c27
< operation_system_variant=""
---
> operation_system_variant="dd-wrt"
32c32
<   asterisk="/opt/sbin/asterisk"
---
>   asterisk="/usr/sbin/asterisk"


Do change it back to /opt/sbin/asterisk if you prefer to use the optware version (is newer).

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Fri Apr 24, 2009 17:49    Post subject: Reply with quote
Try this:
http://www.voip-info.org/wiki/view/Asterisk+SIP+NAT+solutions

I think point 3 applies to your case.

Also, remember that just opening port 5060 may not be enough for the SIP protocol, as the server specifies a second UDP port dynamically to the client when connecting, you need to instruct the server and the client onto limitations.

You might want to use a SIP proxy on the router to overcome the limitation. Check if included in the builds (SIPatH or Milkfish) can help you or not.

Extra resources:
http://www.asteriskguru.com/tutorials/sip_nat_oneway_or_no_audio_asterisk.html
http://www.voip-info.org/wiki/view/NAT+and+VOIP
http://www.voipuser.org/forum_topic_7295.html
http://www.linuxjournal.com/article/9399

Please let us know how you are getting along. We need your feedback!
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Fri Apr 24, 2009 17:57    Post subject: Reply with quote
I decided to make a Wiki entry on installing Asterisk. Let's make a two-version:
- one for installation with Optware
- one for the one which is included in BrainSlayer's builds
Wanna help?
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Fri Apr 24, 2009 19:54    Post subject: Reply with quote
My router has a WAN-IP, so it's not using NAT itself. That's the reason why I want it on my router.

I even told it its WAN-IP and the local-adresses... (But that may well be the problem)

I can do almost everything I need. (place calls to the outside world using 2 SIP-providers, receive calls from both sip-providers, place calls internally)

The only thing I can not do is register from the outside. With "tcpdump -i vlan1" I can see those packets coming (so my ISP is passing them) but no registration is possible....

But you have it working don't you?
Can you register a phone from the Internet on your local box? I didn't see any instructions if a port forward was needed but did it just like I did it for my reverse proxy which is working like a breeze (see the seperate tutorial I wrote on that one).

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Fri Apr 24, 2009 21:02    Post subject: Reply with quote
frater wrote:
But you have it working don't you?
Can you register a phone from the Internet on your local box?
I didn't try it like this, so I don't know if it works. I use it like you do, but without having to register a phone from the Internet side (yet).
But I think your case is when Asterisk is behind nat, and you wish to register a phone (client) from WAN side. That's pretty much a problem as a simple port forwarding of 5060 is not enough - the phone is waiting for an answer on a different port, wich is dynamically allocated. I think.
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sat Apr 25, 2009 8:24    Post subject: Reply with quote
Solved it!
It was quite simple, but I managed to make it more complicated. I think I went on automatic pilot because I installed a reverse-proxy before and there I went through the NAT-table. I should have just made the iptables rule to my WAN-address and not make that port forward to the LAN-address.

I can register by merely opening port 5060 udp to my wan-address but on some sites.

I entered this in my firewall rules (asministration->commands->save firewall):

Code:
iptables -I INPUT 1 -p udp --dport 5060 -j ACCEPT
iptables -I INPUT 1 -p udp --dport 4569 -j ACCEPT
iptables -I INPUT 1 -p udp --dport 2727 -j ACCEPT
iptables -I INPUT 1 -p udp --dport 12000:13000 -j ACCEPT


The 2nd rule is for IAX2 which I haven't configured (Inter Asterisk Exchange?)

Edit: (not true)I also discovered I needed to (re)start asterisk because it goes down after (re-)applying the firewall rules. My reverse-proxy doesn't have this problem.


I opened up port 12000 to 13000 for RTP (real-time packets) which are the actual audiostreams. You should match rtp.conf with this.

I still had some one-way audio problems with a device coming from the Internet but solved this by changing "reinvite" to "no" in sip.conf
I changed all reinvites to no, btw, but I don't know if that's necessary or even advisable.
I'm relatively new to SIP and Asterisk but I'm not that impressed by its robustness... There's a lot on which it can go wrong. If you think you have it all covered it turns out that some kind of combination doesn't work where it previous did work.

Testing should go further than just letting the phones ring and being a cheapo (that's the reason for getting into VoIP) one doesn't that often test with those lines for which you have to pay.

I now have a laptop with HSDPA (mobile Internet) to my disposal which makes it a bit easier to test Laughing

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)


Last edited by frater on Fri May 22, 2009 16:31; edited 1 time in total
robertut
DD-WRT User


Joined: 30 Mar 2009
Posts: 145

PostPosted: Sat Apr 25, 2009 9:42    Post subject: Reply with quote
frater wrote:
The 2nd rule is for IAX2 which I haven't configured (Inter Asterisk Exchange?)
What's the third rule for?
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sat Apr 25, 2009 11:10    Post subject: Reply with quote
MGCP (Media Gateway Control Protocol).
I just added that rule because asterisk is listening on it and I'm still uncertain about various configs.

I'm now in the phase of testing every kind of setup. I placed several succesfull calls using different kind of devices and infrastructures...

I've written sip.conf and extensions.conf from the ground up and all the other files are coming from the optware-packages.

I guess a lot of features are not needed for my situation and in the near future I'll be trying a minimalistic config.

BTW... Do you know how to limit a client to only local extensions and don't use the 2 outgoing providers I made?

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)
frater
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 2777

PostPosted: Sat Apr 25, 2009 12:32    Post subject: Reply with quote
Changed the startup script a bit. I will kill the logfile before asterisk starts, but only after a recent reboot of the system.


# cat /opt/etc/init.d/S90asterisk
Code:
#!/bin/sh

prefix="/usr"
astetc=/opt/etc/asterisk
cfg=$astetc/asterisk.conf
astscript=$astetc/asterisk.sh
astlogdir=`grep astlogdir ${cfg} 2>/dev/null | awk -F "=>" '{print $2}' | sed 's/^[ \t]*//;s/[ \t]*$//'`

PATH=${prefix}/bin:${prefix}/sbin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=asterisk
DAEMON=${prefix}/sbin/${NAME}

[ -x ${DAEMON} ] || exit 0

if [ -z "${astlogdir}" ] ; then
  if [ ! -e "$cfg" ] ; then
    echo "$cfg not found.. exiting"
    exit 1
  fi
  echo "I can not determine the directory in which logfiles should be placed (no astlogdir in ${cfg}?)" >&2
  exit 1
fi
if [ ! -d "${astlogdir}" ] ; then
  echo "The directory ${astlogdir} does not exist" >&2
  exit 1
fi

if [ -z "$1" ] ; then
    case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
        S??*) rc="start" ;;
        K??*) rc="stop" ;;
        *) rc="usage" ;;
    esac
else
    rc="$1"
fi

case "$rc" in
    start)
        echo "Starting $NAME"
        if [ -n "`pidof $NAME`" ]; then
            echo "$NAME already running"
        else
            if [ ! -e $cfg ]; then
              echo "missing $cfg"
              exit 1
            fi
            [ -z "`uptime | grep " min"`" ] || rm ${astlogdir}/messages
            $DAEMON -m -C $cfg >/dev/null &
        fi
        if [ ! -e /tmp/www/cgi-bin/asterisk ]; then
          if [ -f $astscript ]; then
            echo "Copying webscript"
            mkdir -p /tmp/www/cgi-bin
            ln -s "${astscript}" /tmp/www/cgi-bin/asterisk
          else
            echo "Webscript (${astscript}) NOT found.. NO websupport"
          fi
        fi
        ;;
    stop)
        if [ -n "`pidof $NAME`" ]; then
            echo "Stopping $NAME"
            killall $NAME 2> /dev/null
        else
            echo "$NAME already stopped"
            exit 1
        fi
        ;;
    restart)
        "$0" stop
        sleep 1
        "$0" start
        ;;
    status)
        if [ -n "`pidof $NAME`" ]; then
            $DAEMON -V
            $DAEMON -rx "core show channels"
            echo -e "\nCurrent Dialplan:\n"
            $DAEMON -rx "dialplan show"
            echo -e "\nLogfile:"
            tail ${astlogdir}/messages
        else
            echo "$NAME is not running"
            exit 1
        fi
        ;;
    *)
        echo "Usage: $0 (start|stop|restart|usage|status)"
        ;;
esac

exit 0

_________________
Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge

DD-WRT v24-sp2 vpn (c) 2010 NewMedia-NET GmbH
Release: 12/16/10 (SVN revision: 15758M)


Last edited by frater on Mon Jun 29, 2009 20:19; edited 2 times in total
Goto page Previous  1, 2, 3, ... 27, 28, 29  Next Display posts from previous:    Page 2 of 29
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum