adspace


How to create dynamic users on simple Asterisks server for
simple extension based x-change?

Answer Posted / Danish Ali

To create dynamic users on an Asterisk server for simple extension-based exchange, you can follow these steps:

1. Install and configure the Asterisk server according to your operating system (Linux, FreeBSD, etc.).
2. Create a new context in the dialplan for dynamic user creation by editing the appropriate files (extensions.conf or extensions_extra.conf). Here is an example of a context named 'dynamic':
[dynamic]
; Extensions that don't have a defined destination
exten => s.,1,Dial(Local/${EXTEN},T)
exten => s._X.,1,Voicemail(${EXTEN}@localvm)
exten => s._XX.,1,VoicemailMain

3. Create an Asterisk script to create dynamic users on-the-fly. In this example, the script will be called 'DynamicUser':
#!/bin/bash
; Set the desired context and prefix for your dynamic users
CONTEXT=dynamic
PREFIX=100

; Find available extensions
avail=$(asterisk -rx "agi config extension" | awk '{print $2}' | grep -v '^$')
min_ext=$((100 + ${#avail}))

; Prompt for the new user's password
read -p "Enter a password for the new user: " password
read -p "Confirm the password: " confirm_password
if [ "$password" != "$confirm_password" ]; then
echo "Passwords do not match. Aborting."
exit 1
fi

; Create a new extension with the available number and the provided password
asterisk -rx "agi config extension ${min_ext} password ${password}"
asterisk -rx "sip show settings dynamiccontext"
asterisk -rx "dialplan context add $CONTEXT"
asterisk -rx "sip show settings dynamicprefix"
asterisk -rx "dialplan context add ${PREFIX}"
asterisk -rx "sip reload"

4. Save the script as DynamicUser and make it executable by running:
chmod +x DynamicUser

5. Test the dynamic user creation by running the script, e.g.:
./DynamicUser

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is your most recent experience with VERTAS backup software?

2180


What do you understand by the term ‘structured cabling’. State the main rules that should be used when installing a cable. 31. Show that maximum cabling area for LAN for horizontal cabling runs is approximately 200m.

1713


1. What ports does FTP traffic travel over? 2. What ports does mail traffic utilize? 3. What ports do HTTP and HTTPS use? 4. Why is NTP required in an NFS network? 5. Name some common mal software on the server side 6. What is CPAN? How do you access it? 7. What is PEAR? 8. What advantages does mod_perl have over a perl CGI? 9. What is required to do SSL in Apache 1.x? 10. What is Tcl? 11. What is a servlet engine/container? 12. What is BIND? 13. Name the steps to setup a slave zone in BIND 14. Name the steps to setup a primary zone in BIND 15. What commands would you use under Solaris or Linux to modify/view an LDAP tree?

2842