If you have added new hardware to your Asterisk box like FXO/FXS cards, there are a few configuration steps.

Note: If you didn’t compile Asterisk with DAHDI, you will need to do those first. See Ubuntu 14.04 Server: Install Asterisk 13 (opens in new tab/window) for Installing Asterisk, and just do the steps for compiling DAHDI and compiling Asterisk, but leave out “&& make samples” so you don’t overwrite your configs. Warning, back up your configs.

I would recommend running sudo -i to switch to root for the following, otherwise, add sudo to the beginning of each command.

At this point I would also recommend opening up 2 SSH sessions to your Asterisk box. One to sit on the Asterisk console, and one to edit different files.

First, make sure DAHDI sees the card:

dahdi_scan -vvvvv

If you do not see any output, run dahdi_hardware and make sure it at least sees the card. If it does see the card, but no modules, then you may need to modify your system to load the correct kernel modules on boot. For example, I had to force my system to load the wctdm24xxp module on boot. If it does not see the card, make sure it is seated in the slot correctly and is known to be good.

If you have a hardware echo cancellation module, add a line in /etc/dahdi/genconf_parameters to enable use of it:

echo_can                hwec

Note: You can add this line anywhere, but I added it where the rest of the echo_can lines were. This is done here so you can continue to use the two tools below to automatically create updated configs with your custom settings.

Then, generate the new configuration files:

dahdi_genconf -vvvvvv

Then, configure the kernel for the installed modules:

dahdi_cfg -vvvvvv

You should see your modules show up in the channel map, and a configuration for the mg2/hwec echo canceller.

Restart DAHDI:

service dahdi restart

Point file chan_dahdi.conf to /etc/asterisk/dahdi-channels.conf:

# open chan_dahdi.conf and include it under the section [channels]
  #
  # NOTE: You can edit and configure /etc/asterisk/dahdi-channels.conf at any time 
  # to set up your specific options there.
  ...
  [channels]
  ...
  #include /etc/asterisk/dahdi-channels.conf
  ...

Restart Asterisk:

service asterisk restart

Verify everything is working:

asterisk -rvvvvv

dahdi show status
dahdi show channels

If everything goes ok, and you have an FXS channel, you should now get dialtones!

Well that was easy, let’s set up a basic dialplan and a physical extension. I happen to have 2 FXS modules in my machine, so here is an easy example of how to get started with the new hardware:

vi /etc/asterisk/extensions.conf

Scroll all the way down to the bottom and put the following:

[from-internal]
exten => 100,1,Dial(DAHDI/1)
exten => 101,1,Dial(DAHDI/2)

Save and exit. Then, reload the dialplan in the Asterisk console:

dialplan reload

“But how did you know to use the [from-internal] context??” you may scream at me over the internet. The answer is the dahdi-channels.conf which told me on line 30.

context=from-internal

Now you should be able to call extension 100 or 101 and hear the sweet ring of success.