Documentation

Contents – Basic Setup

  1. Next steps after downloading the image
  2. Determine hostname / IP address
  3. Basic configuration
  4. Email setup
  5. Initial Asterisk setup
  6. Changing passwords
  7. More documentation

Contents – Advanced Topics

  1. Fax gateway
  2. Security: HowTo for Asterisk and Fail2Ban
  3. Running RasPBX without Internet connection
  4. GSM VoIP Gateway with Chan_dongle
  5. Security Considerations
  6. Backup your System
  7. Running RasPBX from an External USB HDD or Thumb Drive

Basic Setup

1. Next steps after downloading the image

Instructions on how to write the downloaded image to your card can be found here:
http://elinux.org/RPi_Easy_SD_Card_Setup

The image is only utilizing 4GB of your card, even if you bought a bigger one. On a bigger card, you can make more space available to your root partition by running on the console of your booted RPi:

raspi-config

Select the option expand_rootfs. If you rather prefer to do this manually, one of the easiest ways is using GParted on Linux. Details can be found here:
http://elinux.org/RPi_Resize_Flash_Partitions#Manually_resizing_the_SD_card_using_a_GUI_on_Linux

2. Determine hostname / IP address

Once your RPi is booted, you need to know it’s hostname or IP address for ssh login or to open the web GUI. On Windows computers, you can just use the hostname raspbx to access your RPi.

SSH login:

ssh root@raspbx

Web GUI:

http://raspbx

On Macintosh, use raspbx.local instead:

ssh root@raspbx.local

Web GUI:

http://raspbx.local

In case this is not successful you can check your router’s DHCP client list, and search for the IP associated with the name raspbx.
If this is still not working out, you can always just connect an HDMI monitor and USB keyboard, log in to the console with user root, password raspberry, and run the command:

ifconfig

3. Basic configuration

After your RPi has booted successfully, log in either on the console or by ssh with user root and password raspberry. Follow these steps to complete the initial configuration:

Choose your timezone:

configure-timezone

Configure locale settings:

dpkg-reconfigure locales

Configure keyboard settings (not needed when working with ssh only):

dpkg-reconfigure keyboard-configuration

4. Email setup

Email delivery from your RPi is needed if you plan to have voicemails sent to users by email. Email already works in the default configuration using Exim4 as MTA. By default, Exim is configured to directly send mails to the recipient MX hosts. This is however discouraged, as many email providers classify emails coming from dynamic IP addresses as spam. To avoid this, you need to set a smarthost. Unless you have an open SMTP server on your network that can be used as smarthost without authentication, you will need to specify SMTP authentication credentials as well. It is basically possible to use almost any publicly available freemailer as smarthost with the RPi. Have username and password as well as SMTP hostname (sometimes also referred to as outgoing mail server) of the email account you are going to use ready. Run on the console:

dpkg-reconfigure exim4-config

On the first configuration page select “mail sent by smarthost; received via SMTP or fetchmail”. On the following pages just keep the default values by pressing enter, until you reach the page starting with “Please enter the IP address or the host name of a mail server…”. Here, enter the SMTP hostname of your email provider. Again, keep default values on the remaining pages.
Then, edit the file passwd.client by running:

nano /etc/exim4/passwd.client

Add your credentials at the bottom of this file in the following format:

SMTP_HOSTNAME:USERNAME:PASSWORD

In most cases, the SMTP hostname used in this file is identical to the hostname used as smarthost before. If email fails to work, specify the reverse lookup of your email provider’s SMTP host IP address here. For Google Mail, set this to *.google.com

Some email providers also require you to use sender addresses identical to one of the public email adresses of your account. In this case, edit:

nano /etc/email-addresses

On the bottom of this file add:

root: your_email@someisp.com
asterisk: your_email@someisp.com

This configures the sender address of all outgoing mail to your_email@someisp.com.

Finally, to activate your configuration run:

update-exim4.conf

You can test your email setup with this command:

send_test_email your_email@someisp.com

A test email should reach your inbox shortly.

5. Initial Asterisk setup

Point your browser to the RPi’s hostname or IP address (http://raspbx).

The default login to FreePBX is:
user: admin
password: admin

For inital setup please follow this guide:
http://www.freepbx.org/support/documentation/installation/first-steps-after-installation

Most of the configuration steps presented here apply to the RPi as well. If you are going to use SIP technology, you absolutely need to follow section 5, “Configure Asterisk SIP Settings”. After filling the Asterisk SIP Settings page, you need to go back to the console and run:

amportal restart

This step is only required once after Asterisk SIP Settings have been configured for the first time. For all other configuration changes just use the red apply config button in the GUI.

6. Changing passwords

Once you are done with basic installation, you might want to change the following important passwords to keep your setup safe. As long as your system is running with a private IP address behind a router with all ports closed, these passwords will only affect people trying to log in from inside your network, as no one can log in from outside anyway.

Change the password for SSH or console login with:

passwd

To change the FreePBX login select AdminAdministrators in FreePBX. On the right side of the page below Add User select admin. The password can be changed here.

There are 2 more passwords that should be changed. In FreePBX open SettingsAdvanced Settings. Find the field Asterisk Manager Password and change this password. On the same page, search for User Portal Admin Password and change the password for the ARI administrator login as well.

7. More documentation

Further documentation on how to work with the FreePBX GUI can be found here:

http://www.freepbx.org/support/documentation

http://wiki.freepbx.org/

 

Advanced Topics

1. Fax gateway

Fax gateway support in RasPBX is provided by HylaFAX, an optional feature which needs to be installed manually by calling:

install-fax

This command is added with upgrade #5, see the downloads page for details. Make sure you have been running raspbx-upgrade and your system is up to date, otherwise this command is not available.

After installation is complete, you can configure a fax extension at your choice. This can also be skipped and done later by calling:

add-fax-extension

This is configuring HylaFAX, Iaxmodem and FreePBX. An additional extension is added to FreePBX which can be used as inbound destination for your fax DID. Faxes to this extension will be emailed to the address specified during the add-fax-extension run.

It is possible to have as many fax extensions as required by calling add-fax-extension multiple times. Each extension can me mapped to a different email address, thus having several virtual fax machines with different recipients.

For sending faxes, any HylaFAX client such as Winprint HylaFAX or any other can be used. A complete list can be found here:
http://www.hylafax.org/content/Desktop_Client_Software

The default user to connect to HylaFAX is root with empty password.

2. Security: HowTo for Asterisk and Fail2Ban

Razvan Turtureanu wrote a very detailed and clear how-to for installing Fail2Ban with Asterisk on RasPBX. Read the complete tutorial in the forum. The last section other security tips gives a good overview on security in general, be sure to read this even if you don’t decide to install Fail2Ban.

With upgrade #8, Fail2Ban can be installed easily by calling:

install-fail2ban

This installer includes all steps described by Razvan’s tutorial.

3. Running RasPBX without Internet connection

If Internet connection is not continuously present or not present at all, 2 issues can appear that prevent calling between extensions:

A. On system boot, current time is obtained through NTP. Asterisk only starts after time has been set correctly, to avoid problems that have been seen in connection with a large time jump on the system. If Asterisk is started with wrong time first and time is properly set later, audio on calls can be seriously distorted. Thus, the boot scripts only start Asterisk after time has been set, and in setups without Internet connection Asterisk will not start by default. To overcome this, install fake-hwclock:

apt-get install fake-hwclock

It saves the time on shutdown and loads it again on reboot.

Update: Dnsmasq is installed and configured as described below with upgrade #10. The steps below are not needed if all the latest upgrades are installed.

B. Asterisk gets into trouble when DNS lookups fail, leaving an unstable system. This can be fixed by installing dnsmasq:

apt-get install dnsmasq

configure:

cd /etc
mv resolv.conf resolv.conf.dnsmasq

edit /etc/dnsmasq.conf, change this section

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/resolv.conf.dnsmasq

Then create /etc/resolv.conf with contents:

nameserver 127.0.0.1

Then reload:

/etc/init.d/dnsmasq restart

 

11 thoughts on “Documentation

  1. Hi,

    It is very interesting to be able to run Freepbx + Asterisk in the RPi. I myself installed Freepbx and Asterisk 10 on it the day I received it.

    However, running the whole LAMP stack on it is a bit “heavy” on its CPU.

    So, my ideia would be:

    In the RPi run only:
    - Asterisk
    - PHP (for the FreePbx modules)

    In another server:
    - Run the LAMP stack (Apache, MySql, PHP)

    Freepbx architecture would need to be adjusted for the configuration files to be
    moved to RPi from the Linux Server.

    Would this be feasible?

    • According to the latest information I have g729 is a closed source codec and not available for the ARM platform. Therfore it is not supported on the RPi (yet).

        • The code I mentioned above is begging for someone with ARM assembler experience to do some massive optimisations. Things like use of the LDM and STM instructions with a barrel shift to process multiple registers in few clock cycles. Not to mention that ARM has built in saturated arithmetic (operands that start Q).

          Take a look at the C code, it’s full of moves and shifts that could be done in parallel. Looks like some on started on the ARM assembler and didn’t get very far.

          This could be very promising, but only as long as a mention of the patent and the original authors is not forgotten. It might have to be done as a “patch”.

          • We’re going there – somewhere like this:

            Read the code = whereever you see something line this:

            for(i=0; i<L_WINDOW; i++)
            sum = L_mac_Ov(sum, y[i], y[i] )

            call L_DotSquareProduct(sum, y, L_WINDOW)

            It is not perfect. I haven't done assembler for years!

            Word32 L_DotSquareProduct( Word32 subtotal, Word16 *pX, Word16 n )
            {
            long total;
            total = 0;

            __asm __volatile ( \
            "sasm_L_DotProductLoop: \n" \
            "cmp %[n], #0 \n" \
            "ble sasm_L_exit \n" \
            "cmp %[n], #8 \n" \
            "blt sasm_L_LT8 \n" \
            "ldmia %[pX]!, {r4, r5, r6, r7} \n" \
            "smlad %[t], r4, r4, %[t] \n" \
            "smlad %[t], r5, r5, %[t] \n" \
            "smlad %[t], r6, r6, %[t] \n" \
            "smlad %[t], r7, r7, %[t] \n" \
            "subs %[n], %[n], #8 \n" \
            "bal sasm_L_DotProductLoop \n" \
            "sasm_L_LT8: \n" \
            "cmp %[n], #2 \n" \
            "blt sasm_L_LT2 \n" \
            "ldr r4, [%[pX]], #4 \n" \
            "smlad %[t], r4, r4, %[t] \n" \
            "subs %[n], %[n], #2 \n" \
            "bal sasm_L_LT8 \n" \
            "sasm_L_LT2: \n" \
            "cmp %[n], #0 \n" \
            "beq sasm_L_exit \n" \
            "ldr r4, [%[pX]], #0 \n" \
            "smlabb %[t], r4, r4, %[t] \n" \
            "sasm_L_exit: \n" \
            "qdadd %[t], %[s], %[t] \n" \
            : [t] "+r" (total), [pX] "+r" (pX), [n] "+r" (n) , [s] "+r" (subtotal) \
            : \
            : "r4", "r5", "r6", "r7" );

            return total;
            }

  2. Hello, what about chan_dongle or chan_datacard availability? If they are not included in bundle, do you have asterisk sources and it is possible to compile them? Have you tried such channels on raspberry PI, what’s feedback?

    • I haven’t tried these modules yet. You can find the original asterisk sources in:
      /usr/src/asterisk-1.8.14.0
      Run make menuselect from there to build additional modules.