Yealink VLAN DHCP Scope configuration on VLAN Windows DHCP Server

Yealink VLAN DHCP Scope configuration on VLAN Windows DHCP Server

To configure Yealink phones to get VLAN ID from the default DHCP Server follow the below instructions.

Step 1

Login to local windows dhcp server and configure a new scope option for Yealink phone.
a) Right click IPv4
b) select “Set Predefined Options”
windows_dhcp_define_new_scope_option

Step 2

a) Click on “Add”
b) Fill the “Option Type”
c) Select “Data Type” as String.
d) Code is “132”
e) Finish the Options by clicking “OK” on all other dialog boxes.
yealink_define_vlan_code

Step 3

a) Right click Scope Options
b) Select “Configure Options”
configure_dhcp_options

Step 4

a) Scroll till the end of the list and select the Yealink VLAN option.
b) Under String value put the VLAN ID which you want to set on yealink phone.

yealink_dhcp_vlan_scope

Advertisements

Disable / Enable Elstatix GUI (httpd) from your phone: Asterisk Dialplan

  1. Create 2 scripts to start & stop httpd daemon.
    1. httpstop
      #!/usr/bin/php
      <?php
      $output = $ret = NULL;
      exec("/sbin/service httpd stop 2>&1", $output, $ret);
      ?>
    2. httpstart
      #!/usr/bin/php
      <?php
      $output = $ret = NULL;
      exec("/sbin/service httpd start 2>&1", $output, $ret);
      ?>
  2. Make them executable (chmod +x) and copy to /usr/share/elastix/privileged
  3. Edit the file /etc/asterisk/extensions_custom.conf and add the lines under context [from-internal-custom].
    [from-internal-custom]
    exten => 120,1,Playback(posix-restarting) ; "Stop HTTP Server"
    exten => 120,2,Wait(1)
    exten => 120,3,System(sudo /usr/sbin/elastix-helper httpstop)
    exten => 120,4,Playback(disabled)
    exten => 120,5,Hangup
    
    exten => 121,1,Playback(posix-restarting) ; "Start HTTP server"
    exten => 121,2,Wait(1)
    exten => 121,3,System(sudo /usr/sbin/elastix-helper httpstart)
    exten => 121,4,Playback(enabled)
    exten => 121,5,Hangup

    I used the number 120 to stop the web server & 121 to start it.

  4. Reload asterisk and dial 120 & 121 to test.
  5. If you want to dial it from outside add above numbers in “Misc Destination” menu and then select them from IVR menu.

Elastix Tips

Change “From  Name”  in Elastix/FreePBX FAX to Email

Edit the file /var/lib/asterisk/bin/fax-process.pl

Change the line starting with “From: $from” to  “From: FAX Mailer \<$from\>” or put any name instead of FAX Mailer.

Assign only one Fax Device for each elastix user

Edit  the file /var/www/html/modules/sendfax/index.php

Comment the line starting with  $arrFaxList = array(“none”=> and add the below two lines.

// $arrFaxList = array(“none”=>’– ‘.$arrLang[“Select a Fax Device”].’ –‘);
$usrname=$_SESSION[‘elastix_user’];
exec(“sqlite3 -separator ‘|’ /var/www/db/acl.db \”select extension from acl_user where name=’$usrname’\””,$user_exten);

Add the following line after the line starting with  “foreach($faxes as $values){”

if($_SESSION[‘elastix_user’] == “admin” || $user_exten[0] == $values[‘extension’])

Edit  the file /var/www/html/modules/faxviewer/index.php

Add the following 2 lines after the line starting with  “if(is_array($arrResult) && $total>0) {”

$usrname=$_SESSION[‘elastix_user’];
exec(“sqlite3 -separator ‘|’ /var/www/db/acl.db \”select extension from acl_user where name=’$usrname’\””,$user_exten);

Add the following line after the line starting with   ” $fax[$k] = htmlentities($fax[$k], ENT_COMPAT, ‘UTF-8’);”

 if($user_exten[0] == $fax[‘destiny_fax’] OR $_SESSION[‘elastix_user’] == “admin”){

Add a close the bracket after ” “<a href=’?menu=$module_name&action=edit&id=”.$fax[‘id’].”‘>”._tr(‘Edit’).”</a>”); }

Change Elastix admin password

sqlite3 /var/www/db/acl.db "UPDATE acl_user SET md5_password = '`echo -n password|md5sum|cut -d ' ' -f 1`' WHERE name = 'admin'"

Now Elastix admin password is 'password' (without quotes)

FreePBX – Call Recording and RAMDISK

Asterisk call recording is resource intensive especially when the number of calls in the PBX is high. If you record all the calls directly to the HDD in asterisk  pbx and you got a large call volume (number of calls) then it will damage your PBX’s HDD very soon. On such cases using RAMDISK and seperate HDD may solve the problem.

Install freepbx. If you are not using SAN  use 2 HDDs for better results. One for OS+asterisk and one as a storage for recorded files.  Here I’m using /record as the storage location and  /astrec as the mount point for RAMDISK. Format and mount the 2nd HDD  to /record at the time of OS installation(or create an fstab entry if you are doing it later). After installation give write permission or assign asterisk user as the owner of /record & /astrec.

/bin/chown -R asterisk.asterisk /record
/bin/mkdir  /astrec
/bin/chown -R asterisk.asterisk /astrec

After the freepbx installation edit “/boot/grub/grub.conf” and put the the ramdisk size.

#boot=/dev/hda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Elastix (2.6.18-194.3.1.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-194.3.1.el5 ro root=LABEL=/
ramdisk_size=1000000
initrd /initrd-2.6.18-194.3.1.el5.img

Here I used RAMDISK size as 1GB(1000000) . The size depends on the number of calls,the average time for one call,and the recording format.

Remove the 3 directories from asterisk spool directory because we are going to use ramdisk instead of those.

rm -rf /var/spool/asterisk/monitor
rm -rf /var/spool/asterisk/system
rm -rf /var/spool/asterisk/tmp

Edit the file “/etc/rc.local” and append the  below code.

#Put this in rc.local to create ramdisk during bootup
/sbin/mke2fs -m 0 /dev/ram0
/bin/mount /dev/ram0 /astrec
/bin/mkdir /astrec/monitor
/bin/mkdir /astrec/system
/bin/mkdir /astrec/tmp
/bin/chown -R asterisk.asterisk /astrec
#For more infor on ramdisk:
#http://www.vanemery.com/Linux/Ramdisk/ramdisk.html

#Link asterisk's default folders to our ramdisk
/bin/ln -s /astrec/system /var/spool/asterisk
/bin/ln -s /astrec/tmp /var/spool/asterisk
/bin/ln -s /astrec/monitor /var/spool/asterisk

At the time of booting the above lines in rc.local creates RAMDISK and mount it to “/astrec”.

Create the file “/var/lib/asterisk/agi-bin/mvrec.sh” and put the below contents.

#!/bin/bash
/bin/mv $1/$2.$3 /record 3>&1 1>&2 2>&3 | tee /var/log/asterisk/mvrec.log

The above code will transfer the recorded file from RAMDISK to the location /record., Use the file “/var/log/asterisk/mvrec.log”  for troubleshooting purpose. Make the script executable.

chmod 755 /var/lib/asterisk/agi-bin/mvrec.sh

Log in to freepbx interface and change the General Settings as shown in screen shot.

Extension Recording Override:Enabled
Call recording format:	wav
Recording Location:	/var/spool/asterisk/monitor/
Run after record: /var/lib/asterisk/agi-bin/mvrec.sh ^{MIXMON_DIR} ^{CALLFILENAME} ^{MIXMON_FORMAT}

On FreePBX GUI goto  “Extensions” and select one of the extensions in which you want to enable call recording.

If you are using Elastix change the recording directory in elastix monitoring configuration file.

 /var/www/html/modules/monitoring/configs/default.conf.php
 $arrConfModule['records_dir']       = '/record/';

Select the appropriate recording option.

Try calling between 2 extension after enabling call recording.  See the asterisk cli output. Use the file “/var/log/asterisk/mvrec.log” for troubleshooting.

If you are using specific context other than from-internnal context, don’t forget to add the Macros. For example

[custom-checklock]
exten => _.,1,NoOp(AMPUSER/${CALLERID(num)}/locked)
exten => _.,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/locked)}=0]?carryon)
exten => _.,n,Set(PINCOUNT=0)
;exten => _.,n,Set(VALIDPIN=1234)
exten => _.,n(readpin),Read(PIN,vm-password,4,,,4)
exten => _.,n,Gotoif($[${PIN}=${VALIDPIN}]?carryon)
exten => _.,n,Gotoif($[${PIN}=${DB(AMPUSER/${CALLERID(num)}/locked)}]?carryon)
exten => _.,n,Set(PINCOUNT=$[${PINCOUNT}+1])
exten => _.,n,Playback(vm-incorrect)
exten => _.,n,GotoIf($[${PINCOUNT}>2]?h)
exten => _.,n,Wait(1)
exten => _.,n,Goto(readpin)
exten => _.,n(carryon),Set(DB(AMPUSER/${CALLERID(num)}/unlocked)=${PIN})
exten => _.,n,NoOp(${DB_DELETE(AMPUSER/${CALLERID(num)}/locked)})
;exten => _.,n,Dial(DAHDI/g0/${EXTEN})
exten => _.,n,Macro(user-callerid,SKIPTTL,)
exten => _.,n,Macro(record-enable,${AMPUSER},OUT,)
exten => _.,n,Macro(dialout-trunk,2,${EXTEN},)
exten => h,1,Macro(hangupcall,)
;exten => 911,1,Goto(CallingRule_Out39,${EXTEN},1)
;exten => h,1,Hangup

[custom-setlock]
exten => s,1,NoOp(In Set Lock)
exten => s,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/unlocked)}=1]?lockit)
exten => s,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/locked)}=0]?readit)
exten => s,n,Read(LOCKEY,vm-password,4,,,4)
exten => s,n,Gotoif($[${LOCKEY}=${DB(AMPUSER/${CALLERID(num)}/locked)}]?readit)
exten => s,n,Playback(vm-pls-try-again)
exten => s,n,Hangup
exten => s,n(readit),Read(PIN1,vm-newpassword,4,,,4)
exten => s,n,Read(PIN2,vm-reenterpassword,4,,,4)
exten => s,n,Gotoif($[${PIN1}=${PIN2}]?okey)
exten => s,n,Playback(an-error-has-occured)
exten => s,n,Hangup
exten => s,n(okey),Set(DB(AMPUSER/${CALLERID(num)}/locked)=${PIN1})
exten => s,n,Playback(locked)
exten => s,n,Hangup
exten => s,n(lockit),Set(DB(AMPUSER/${CALLERID(num)}/locked)=${DB(AMPUSER/${CALLERID(num)}/unlocked)})
exten => s,n,NoOp(${DB_DELETE(AMPUSER/${CALLERID(num)}/unlocked)})
exten => s,n,Playback(locked)
exten => h,1,Hangup

[national]
include => from-internal
exten => _XXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)

[international]
include => from-internal
exten => _XXXX.,1,NoOp(AMPUSER/${CALLERID(num)}/locked)
exten => _XXXX.,n,Goto(custom-checklock,${EXTEN},1)

[mobile]
include => from-internal
exten => 123,1,Goto(custom-setlock,s,1)
exten => _XXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)
exten => _XXXXXXXXXX,1,Goto(custom-checklock,${EXTEN},1)

[changepw]
exten => s,1,Read(LOCKEY,vm-password,4,,,4)
exten => s,n,Gotoif($[${LOCKEY}=2008]?okey)
exten => s,n,Hangup
exten => s,n(okey),Read(EXTNO,superlock,3,,,4)
exten => s,n,Set(DB(AMPUSER/${EXTNO}/locked)=1234)
exten => s,n,Playback(locked)
exten => h,1,Hangup

SIP Status Codes

This is a list of the known SIP status codes

100 – Trying
180 – Ringing
181 – Call Being Forwarded
182 – Call Queued
183 – Session Progress
200 – OK
202 – Accepted
300 – Multiple Choices
301 – Moved Permanently
302 – Moved Temporarily
305 – Use Proxy
380 – Alternative Service
400 – Bad Request
401 – Unauthorized
402 – Payment Required
403 – Forbidden
404 – Not Found
405 – Method Not Allowed
406 – Not Acceptable
407 – Proxy Authentication Required
408 – Request Timeout
409 – Conflict
410 – Gone
411 – Length Required
413 – Request Entity Too Large
414 – Request URI Too Long
415 – Unsupported Media Type
416 – Unsupported URI Scheme
420 – Bad Extension
421 – Extension Required
423 – Interval Too Brief
480 – Temporarily Unavailable
481 – Call/Transaction Does Not Exist
482 – Loop Detected
483 – Too Many Hops
484 – Address Incomplete
485 – Ambiguous
486 – Busy Here
487 – Request Terminated
488 – Not Acceptable Here
491 – Request Pending
493 – Undecipherable
500 – Server Internal Error
501 – Not Implemented
502 – Bad Gateway
503 – Service Unavailable
504 – Server Time-Out
505 – Version Not Supported
513 – Message Too Large
600 – Busy Everywhere
603 – Declined
604 – Does Not Exist Anywhere
605 – Not Acceptable