How to list all DND-enable extensions

List DND-enabled extensions

If the DND is set using the DND feature of the IP-Phone then there is no way you can list them. Otherwise, if it is set using FreePBX feature code (*78) then here is the way to do it:


in linux prompt run:
# asterisk -rx “database show DND” or

#asterisk -rx “database show” | grep “/DND/”

# asterisk -rx "database show DND"
/DND/1002                                         : YES
/DND/1004                                         : YES
/DND/1006                                         : YES
/DND/1007                                         : YES

To remove DND from an extension run:

# asterisk -rx “database del DND ext.”



To enable DND manully for an extension run:

# asterisk -rx “database put DND ext. YES”

# asterisk -rx "database put DND 1002 YES"
Updated database successfully

# asterisk -rx "database show DND"
/DND/1002                                         : YES 


a better macro for DND that combines *78 and *79

[ext-local-custom] ; *999 is used for this example exten => *999,1,Macro(DND) exten => *999,n,hangup [macro-DND] exten => s,1,noop(=== macro DND written by Reza ===) exten => s,n,gotoif(${DB_EXISTS(DND/${CALLERID(num)})}?disable-dnd|1) exten => s,n,Set(DB(DND/${CALLERID(num)})=1) exten => s,n,playback(do-not-disturb) exten => s,n,playback(activated) exten => s,n,hangup exten => disable-dnd,1,noop(== DND Deactivated ==) exten => disable-dnd,n,DBDel(DND/${CALLERID(num)}) exten => disable-dnd,n,playback(do-not-disturb) exten => disable-dnd,n,playback(de-activated) exten => disable-dnd,n,hangup exten => h,1,hangup

You may also like