Dahdi trunk routing

Hi,

I have a FreePBX 13.0.190.7 system with 4 dahdi trunks.
Right now i have one inbound route with did set to any and its destination is ring group. Works fine.
But now i want one of the trunks to go directly to one extension and while this may seem like a simple thing to do i have not figured out what im doing wrong. Can someone help?

I tried simply making a new route and setting the ‘DID’ to the phone number for that trunk and disabled the ‘any’ trunk then none of the phones rang.

Next i tried going to DAHDI Channel DIDs and i setup one for each trunk and i did not really know what the channels meant… i assumed that it has something to do with the channel from the trunk settings but mine are all set to ‘Analog Channel 1’ under dahdi settings when editing the trunks. so i just made then 1,2,3,4 then made an inbound route for each trunk. Now all phones ring regardless of which trunk the call comes in from so i am clearly missing something here.

You are going in the right direction. The way to go is with the DAHDI channel DID module. You should set each port that is currently connected to an analog line (there is no need to create a DID for a port that is not connected). The channel reference is in fact the port, each channel corresponds to a port. The idea is to assign a different DID to each port if what you are trying to accomplish is to always direct incoming calls on a specific line to a specific destination. What is usually done is to assign the line number that corresponds to that line, but this is just for ease of read, you can assign any number that you want. One thing to consider is that if you have several analog lines on a hunt group from the provider, you will have incoming calls on a port that is not necesary the one that the dialed number belongs to.

For example, let’s say you have 3 lines:
Line 1, port 1, phone number (212)234-5678
Line 2, port 2, phone number (212)345-6789
Line 3, port 3, phone number (212)456-7890

You can use the phone number as the DID and then create inbound trunks using the DIDs that you created to direct the calls from a specific port into a specific destination.

If the lines are in a hunt group from your provider, a caller may dial 234-5678, which is port 1, but the call might arrive on port 2 or port 3, if port 1 is currently being used. This is important if what you want is to have an incoming call directed to a specific destination based on the number dialed by the caller, as a hunt group has a 1:N relation, instead of a 1:1 relation of lines not in a hunt group.

If you want to direct the calls based on the incoming port, no matter whether the dialed number corresponds to that port or not (as can happen on lines that are part of a hunt group), then you don’t have to worry about the hunt group, even though that use case might seem a little strange.

Thank you for the reply. So i think i need to make sure i have my dahdi trunks setup properly.
Maybe i should make a new thread for this but i dont understand how to set the dahdi trunks.
It would make sense to say that trunk 1 is port 1 and trunk 2 is port 2 but thats not how mine is.
The items in the list seem to change…
Right now i have
Group 0 Round Robin Ascending
Group 0 Ascending
Group 0 Round Robin Descending
Group 0 Descending

and at one point i had this in the drop down.
Analog Channel 1
Analog Channel 2
Analog Channel 3
Analog Channel 4

But if i try to select those Analog Channel 1 etc… for each trunk they disappear… So i am very confused about what to select there. But i need to have the right selection made there so that my routing will work properly.

Groups on DAHDI are used for outgoing calls, so Asterisk can decide which port to use, for example in case all your lines are billed at the same rate and you don’t mind sending calls through any of them at any time. It groups all the lines that are in the same group to create an “analog” outgoing multi-channel trunk. Let’s say you have 4 analog lines grouped together in group 0 (g0), so if you create a DAHDI trunk and assign it to group 0, you can have 4 outgoing calls at the same time and Asterisk decides which analog line to use from that group of 4 lines.

It would be so much easier to help you if you post your DAHDI configuration files, there are some located on /etc/dahdi and others on /etc/asterisk, just do an ls-al|grep dahdi on /etc/asterisk and all your dahdi related files will be listed.

Post the files here and I will try to help you with your configuration.

[root@localhost ~]# ls -al /etc/asterisk|grep dahdi
-rw-rw-r–. 1 asterisk asterisk 664 Nov 14 10:31 chan_dahdi_additional.conf
-rw-rw-r–. 1 asterisk asterisk 886 Dec 28 2016 chan_dahdi.conf
-rw-rw-r-- 1 asterisk asterisk 766 Dec 28 2016 chan_dahdi.conf.bak
-rw-rw-r-- 1 asterisk asterisk 737 Dec 28 2016 dahdi-channels.conf
-rw-rw-r-- 1 asterisk asterisk 0 Dec 28 2016 dahdi-channels.conf.bak

GNU nano 2.0.9 File: /etc/asterisk/chan_dahdi_additional.conf

;--------------------------------------------------------------------------------;
;          Do NOT edit this file as it is auto-generated by FreePBX.             ;
;--------------------------------------------------------------------------------;
; For information on adding additional paramaters to this file, please visit the ;
; FreePBX.org wiki page, or ask on IRC. This file was created by the new FreePBX ;
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;
; is totally deliberate.                                                         ;
;--------------------------------------------------------------------------------;

Next…chan_dahdi.conf

group=1
callgroup=1
pickupgroup=1
immediate=no

;Sangoma AFT-200 [slot:0 bus:1 span:1]
context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 1

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 2

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 3

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 4

GNU nano 2.0.9 File: /etc/asterisk/dahdi-channels.conf

; Autogenerated by /usr/sbin/setup-sangoma 2016-12-28
; If you edit this file and execute /usr/sbin/setup-sangoma again,
; your manual changes will be LOST.
; Dahdi Channels Configurations (chan_dahdi.conf)
;
; This is not intended to be a complete chan_dahdi.conf. Rather, it is intended
; to be #include-d by /etc/chan_dahdi.conf that will include the global settings
;

;Sangoma AFT-200 [slot:0 bus:1 span:1]
context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 1

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 2

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 3

context=from-zaptel
group=0
echocancel=yes
signalling = fxs_ks
channel => 4

what about /etc/dahdi ?

I ran this but nothing happens when i run it. Am i doing it wrong?
ls -al /etc/dahdi|grep dahdi

for /etc/dahdi, just do ls-al /etc/dahdi

You should at least see a file called system.conf

[root@localhost ~]# ls -al /etc/dahdi
total 56
drwxr-xr-x. 2 asterisk asterisk 4096 Dec 28 2016 .
drwxr-xr-x. 94 root root 4096 Nov 14 11:52 …
-rw-r–r–. 1 asterisk asterisk 1617 Mar 18 2016 assigned-spans.conf.sample
-rw-r–r–. 1 asterisk asterisk 6095 Mar 18 2016 genconf_parameters
-rw-r–r–. 1 asterisk asterisk 771 Mar 18 2016 init.conf
-rwxr-xr-x. 1 asterisk asterisk 2187 Mar 18 2016 modules
-rw-r–r–. 1 asterisk asterisk 2187 Mar 18 2016 modules.sample
-rw-r–r–. 1 asterisk asterisk 820 Mar 18 2016 span-types.conf.sample
-rw-r–r-- 1 asterisk asterisk 372 Dec 28 2016 system.conf
-rw-r–r-- 1 asterisk asterisk 372 Dec 28 2016 system.conf.bak
-rw-r–r–. 1 asterisk asterisk 11673 Mar 18 2016 system.conf.sample

#autogenerated by /usr/sbin/wancfg_dahdi do not hand edit
#autogenrated on 2016-12-28
dahdi Channels Configurations
#For detailed Dahdi options, view /etc/dahdi/system.conf.bak
loadzone=us
defaultzone=us

#Sangoma AFT-200 [slot:0 bus:1 span:1]
fxsks=1
echocanceller=mg2,1
fxsks=2
echocanceller=mg2,2
fxsks=3
echocanceller=mg2,3
fxsks=4
echocanceller=mg2,4

Shell settings for Dahdi initialization scripts.

This replaces the old/per-platform files (/etc/sysconfig/zaptel,

/etc/defaults/zaptel)

The maximal timeout (seconds) to wait for udevd to finish generating

device nodes after the modules have loaded and before running dahdi_cfg.

#DAHDI_DEV_TIMEOUT=40

A list of modules to unload when stopping.

All of their dependencies will be unloaded as well.

#DAHDI_UNLOAD_MODULES=“” # Disable module unloading
#DAHDI_UNLOAD_MODULES=“dahdi echo” # If you use OSLEC

Override settings for xpp_fxloader

#XPP_FIRMWARE_DIR=/usr/share/dahdi
#XPP_HOTPLUG_DISABLED=yes
#XPP_HOTPLUG_DAHDI=yes
#ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes

Disable udev handling:

#DAHDI_UDEV_DISABLE_DEVICES=yes
#DAHDI_UDEV_DISABLE_SPANS=yes

Let me know if you want to see anymore.

Thank you very much. I got it working now thanks to you.
I put all the trunks on Group 0 Round Robin Ascending
I created 4 DAHDI Channel DIDs with channels 1 - 4
I created 4 Inbound routes 3 of them with the same destination and the 4th going to one extension like i wanted.
Then i called each number to see where they went, found the one that went to the extension i wanted and switched it with the one that was supposed to go there.

I am not quite sure i understand the dahdi trunks completely but have a much better understanding now.

Great that you got it working! You can think of multi-channel DAHDI trunks on analog lines, also known as PSTN or POTS, as a 2 parts concept: outgoing multi-channel trunking is made possible by the dahdi driver grouping your ports and incoming multi-channel is achieved when your provider puts some or all of your lines in a hunt group with a main number that can ring any of the lines in the group.