ClearOS‎ > ‎Asterisk‎ > ‎

Large Scale VoIP/Asterisk Deployment (Aastra sets)

Nobody wants to go into a web config for every phone and manually enter a bunch of settings when you're trying to deploy a lot of SIP stations.  Aastra sets feature fantastic TFTP options that are well thought out.  By making their sets support fetching both a generic (aastra.cfg) and a specific ([MAC-address].cfg) config file via TFTP, it becomes easy to bring a set up in a registration mode, then using the registration mode an installer can simply dial an activation code from the set to register it.  This will write the set-specific config file, and send a notify message that will encourage the set to reboot itself.

1) Add DNS option 66 (TFTP server location) and enable TFTP.

I run asterisk on my ClearOS firewall, which serves DHCP with dnsmasq.  Therefore, I just added the following lines to /etc/dnsmasq/dhcp.conf
dhcp-option=eth1,66,"192.168.1.1"
enable-tftp
tftp-root=/var/tftp
Then restart the service.  The nice thing here is that dnsmasq now not only serves dhcp, but also tftp -- simple!

2) Create files in /var/tftp.

You'll need at least two files: the generic config for registration, and a specific config for an extension.

 aastra.cfg

tftp server: 192.168.1.1
tftp path: /

sip registrar ip: 192.168.1.1
sip registrar port: 5060
sip proxy ip: 192.168.1.1
sip proxy port: 5060

sip user name: register
sip auth name: register
sip password:  register
sip registration period: 60

time zone name: US-Eastern
# US-Central
# US-Mountain
# US-Pacific
# US-Alaska
# US-Aleutian
# US-Hawaii
time server1: 2.us.pool.ntp.org
time server2: 3.us.pool.ntp.org
time server3: 0.us.pool.ntp.org

####Preferences:
live dialpad: 1
options simple menu: 1
date format: 2

sip screen name: Registration
sip screen name 2: Please dial code
sip display name: registration

hostname: Aastra-SIP
#admin password: 22222
#user password:
web interface enabled: 0
sip send mac: 0

 103.cfg

#103
#The above line is a reference for when this file
#gets copied to [MAC].cfg
tftp server: 192.168.1.1

tftp path: /

sip registrar ip: 192.168.1.1
sip registrar port: 5060
sip proxy ip: 192.168.1.1
sip proxy port: 5060

sip user name: 103
sip auth name: 103
sip password:  notSecure
sip registration period: 60

time zone name: US-Eastern
time server1: 2.us.pool.ntp.org
time server2: 3.us.pool.ntp.org
time server3: 0.us.pool.ntp.org

####Preferences:
live dialpad: 1
options simple menu: 1
date format: 2

sip screen name: Somebody
sip screen name 2: x103
sip display name: 103

hostname: Aastra-57i-103
#admin password: 22222
#user password:
web interface enabled: 0
sip send mac: 0

call waiting tone period: 10

sip vmail: 86
softkey1 type: dnd
softkey2 type: blf
softkey2 label: 101
softkey2 value: 101
softkey3 type: blf
softkey3 label: 102
softkey3 value: 102



3) Write the AGI script that will process the registration.

The goal is to copy the extension config file to a new file with the mac address of the device.
This is written in ruby, and requires the ruby-agi gem.

 register.agi

#!/usr/bin/ruby
require 'rubygems'
require 'ruby-agi'
require 'fileutils'

agi = AGI::new()
uri = ARGV[0]

reason = false

mac = ""
unless reason
  if( uri =~ /(\d+\.\d+\.\d+\.\d+)/ )
    #URI: sip:register@[Client IP]:[port]
    ip = $1
    mac = `arp -a |awk '/#{ip}/ {print $4}'`
    mac.chomp!
    mac.gsub!(":", "")
  else
    reason = "Could not identify registration client IP"
  end
end

unless reason
  unless ( mac =~ /[0-9a-f]{12}/i )
    reason = "MAC address wasn't properly formatted"
  end
end

extension = ""
unless reason
  if(ARGV[1] =~ /\*\*(\d+)/ )
    extension = $1
    ####I wasn't getting playback in the channel.  I could see the action,
    ####but I wasn't getting audio.  So I converted to variable, and changed
    ####the algorithm.
    #agi.say_digits(extension)
    agi.set_variable("REGISTEREDXTN", extension)
  else
    reason = "I could not determine the extension to register"
  end
end

unless reason
  begin
    FileUtils.copy("/var/tftp/#{extension}.cfg", "/var/tftp/#{mac}.cfg")
  rescue
    reason = "#{$!}"
  end
end

unless reason
  agi.set_variable("REGISTERED", "TRUE")
else
  agi.set_variable("REGISTERED", reason)
end

4) Update your asterisk configuration


section from: extensions.conf

[register]
    exten => 664,1,Answer()
    exten => 664,n,Set(CHANNEL(musicclass)=default)
    exten => 664,n,MusicOnHold()
   
    exten => _**XX.,1,NoOp("URI: ${SIPURI}")
    exten => _**XX.,n,AGI(register.agi, ${SIPURI}, ${EXTEN})
    exten => _**XX.,n,GotoIf($["${REGISTERED}" = "TRUE"]?win:fail)
   
    exten => _**XX.,n(win),Playback("auth-thankyou")
    exten => _**XX.,n,Playback("for")
    exten => _**XX.,n,Playback("registrar")
    exten => _**XX.,n,Playback("station")
    exten => _**XX.,n,SayDigits(${REGISTEREDXTN})
    ;See: https://issues.asterisk.org/view.php?id=14488
    ;This is still the only way to issue a notify.
    exten => _**XX.,n,System(/usr/sbin/asterisk -rx "sip notify aastra-check-cfg register")
    exten => _**XX.,n,Hangup
   
    exten => _**XX.,n(fail),NoOp("Reason: ${REGISTERED}")
    exten => _**XX.,n,Playback("something-terribly-wrong")
    exten => _**XX.,n,Hangup
   
    exten => _.,1,Goto(i,1)
    exten => i,1,Playback(sorry-cant-let-you-do-that3)
    exten => i,n,Hangup
   
    exten => h,1,NoOp("Goodbye!")

sections from: sip.conf

[103]
    notifyringing=yes
    notifyhold=yes
    allowsubscribe=yes
    call-limit=2
    host=dynamic
    type=friend
    secret=notSecure
    context=default
    insecure=port,invite
    canreinvite=yes
    nat=no
    mailbox=103
    jitterbuffer=yes
    callerid="Somebody" <103>
    permit=192.168.1.0/0.0.0.0
    qualify=5000
[register]
    type=friend
    secret=register
    host=dynamic
    context=register
    canreinvite=no
    permit=192.168.1.0/0.0.0.0

5) Done!  Now plug in your Aastra set.  It'll come up into registration mode, and you can just dial **103 to register it!

Comments