Asterisk VoIP Server running on AsusWRT Routers

This tutorial is only for arm routers like RT-AC56U, RT-AC68U, RT-AC87U, RT-AC3200, RT-AC5300...
Asterisk will turn your AsusWRT router into a communications server :)

1 - Flash Rmerlin firmware from here

2a - Install Optware-NG from here

Install necessary packages

ipkg install nano findutils

or

2b - Install Entware-NG from here

Install necessary packages

opkg install nano findutils

3 - Setup Debian Jessie from here

4 - Enter chrooted debian with:

debian enter

5 - Update Debian

apt update && apt upgrade -y

6 - Install Asterisk

apt install asterisk

- Create some user accounts, green color are phone numbers and red color are user names

cat >> /etc/asterisk/extensions.conf << 'EOF'
[tutorial]
exten => 100,1,Dial(SIP/user1)
exten => 101,1,Dial(SIP/user2)
exten => 102,1,Dial(SIP/user3)
EOF

Press ENTER

- Add same user accounts to sip configuration file, in yellow color are the user passwords

cat >> /etc/asterisk/sip.conf << 'EOF'

[user1]
type = friend
defaultuser = user1
secret = pass1
host = dynamic
context = tutorial
nat = force_rport,comedia

[user2]
type = friend
defaultuser = user2
secret = pass2
host = dynamic
context = tutorial
nat = force_rport,comedia

[user3]
type = friend
defaultuser = user3
secret = pass3
host = dynamic
context = tutorial
nat = force_rport,comedia
EOF

Press ENTER
- Exit Debian

exit

10 - Add Asterisk to chrooted services list

echo "" >>/opt/etc/chroot-services.list
echo "asterisk" >>/opt/etc/chroot-services.list
chmod 755 /opt/etc/chroot-services.list

Press ENTER
11 
- Add firewall rules (remove #!/bin/sh if you already have firewall-start script)

cat >> /jffs/scripts/firewall-start << 'EOF'
#!/bin/sh
# SIP on UDP port 5060. Other SIP servers may need TCP port 5060 as well
iptables -A INPUT -p udp -m udp --dport 5060 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5060 -j ACCEPT
# IAX2- the IAX protocol
iptables -A INPUT -p udp -m udp --dport 4569 -j ACCEPT
# IAX - most have switched to IAX v2, or ought to
iptables -A INPUT -p udp -m udp --dport 5036 -j ACCEPT
# RTP - the media stream
# (related to the port range in /etc/asterisk/rtp.conf)
iptables -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT
# MGCP - if you use media gateway control protocol in your configuration
iptables -A INPUT -p udp -m udp --dport 2727 -j ACCEPT
EOF

Press ENTER
12 
- Open ports

sh /jffs/scripts/firewall-start

13 - Start Asterisk from outside debian

debian restart

Now login to your voip devices with accounts created at point 8 and start calling :) a good free android client is CSipSimple



HOW TO INSTALL ASTERISK-GUI

14 - Enter chrooted debian with:

debian enter

15 - Instal necessary packages

apt install git build-essential

16 - Download, compile and install Asterisk-Gui

cd /var/tmp
git clone https://github.com/antirek/asterisk-gui.git
cd asterisk-gui
./configure
make
make install
rm -r /usr/share/asterisk/static-http
ln -s /var/lib/asterisk/static-http/ /usr/share/asterisk/
cp -r /etc/asterisk /etc/asterisk.backup

17 - Enable Gui access

sed -i 's|;enabled=yes|enabled=yes|g' "/etc/asterisk/http.conf"
sed -i 's|;prefix=asterisk|prefix=asterisk|g' "/etc/asterisk/http.conf"
sed -i 's|;enablestatic=yes|enablestatic=yes|g' "/etc/asterisk/http.conf"
sed -i 's|bindaddr=.*|bindaddr=0.0.0.0|g' "/etc/asterisk/http.conf"
sed -i 's/enabled = yes/enabled = yes\nwebenabled = yes/g' "/etc/asterisk/manager.conf"
sed -i 's|#include "manager.d|include "manager.d|g' "/etc/asterisk/manager.conf"

18 - Check Asterisk configuration to see if it will support the GUI

make checkconfig

Should get something like

[email protected]:/var/tmp/asterisk-gui# make checkconfig
--- Checking Asterisk configuration to see if it will support the GUI ---
* Checking for http.conf: OK
* Checking for manager.conf: OK
* Checking if HTTP is enabled: OK
* Checking if HTTP static support is enabled: OK
* Checking if manager is enabled: OK
* Checking if manager over HTTP is enabled: OK
--- Everything looks good ---
* GUI should be available at http://RT-AC68U:8088/asterisk/static/config/index.html * Note: If you have bindaddr=127.0.0.1 in /etc/asterisk/http.conf
you will only be able to visit it from the local machine. Example: http://localhost:8088/asterisk/static/config/index.html * The login and password should be an entry from /etc/asterisk/manager.conf
which has 'config' permission in read and write. For example: [admin]
secret = mysecret18705
read = system,call,log,verbose,command,agent,config
write = system,call,log,verbose,command,agent,config --- Good luck! ---
[email protected]:/var/tmp/asterisk-gui#

19 - Create user name and password for Asterisk GUI

cat >> /etc/asterisk/manager.conf << 'EOF'
[admin]
secret = admin_password
read = system,call,log,verbose,command,agent,config
write = system,call,log,verbose,command,agent,config
EOF

Press ENTER

20 - Restart Asterisk

/etc/init.d/asterisk restart

20 - Go to GUI page 192.168.1.1:8088/asterisk/static/config/index.html and input username and password from point 19
asterisk-gui

To be continued with the rest of setup if requested by user...

Enjoy...

SUBSCRIBE

To be notified by email when a new tutorial is posted :)

Thanks for Subscribing! I'll keeping you up-to-date with latest tutorials!

Something went wrong, try again...