Introduction
Once, the management approved an experiment to implement IP telephony in our office. Since my experience in this area was minimal, the task sparked significant interest in me, and I delved into the study of various aspects of the issue. After my deep dive, I decided to share the knowledge I gained, hoping it would be useful to someone. So...
Source Data
Asterisk was chosen and deployed as the IP PBX. The phone fleet consists of Cisco 7906g, Panasonic UT-KX123B, Grandstream GXP1400, Dlink DPH-150S(E)/F3, Yealink T19, and T21 devices. Such a variety was chosen to experiment with different options and create my perspective on the price/quality/convenience ratio.
Task
Maximally simplify and unify the process of setting up new devices. All phones should be synchronized by time, have a phonebook loaded from server and provide access to settings for the administrator.
The solution to this task is straightforward — implement automatic phone configuration, known as Provisioning. In fact, this article will focus on my implementation of this wonderful feature.
Configuring tftpd, dhcpd
To distribute settings to the phones, I chose tftp as a universal option, supported by all platforms, easy to set up and manage.
No specific setup for tftp was required. I installed the standard tftpd and placed all necessary files in its root directory.
I organized the configuration files by directories according to the phone manufacturer. However, the Cisco device didn’t access its folder, so it had to be stored in the root.
To indicate to the phones the location of the tftp server, I used option-66. Additionally, I divided them into separate classes by manufacturer. Each class received its segment of addresses and an individual folder for configuration files. By the way, devices from D-link had to be identified by MAC addresses since they do not provide manufacturer information in the dhcp request.
Fragment of dhcpd.conf
# Указываем необходимые опции
option option-66 code 66 = text;
class "panasonic" {
match if substring (option vendor-class-identifier,0,9) = "Panasonic";
option option-66 "10.1.1.50/panasonic/";
}
class "cisco" {
match if substring (option vendor-class-identifier,0,36) = "Cisco Systems, Inc. IP Phone CP-7906";
option option-66 "10.1.1.50/cisco/";
}
class "grandstream" {
match if substring (option vendor-class-identifier,0,11) = "Grandstream";
option option-66 "10.1.1.50/grandstream/";
}
class "dlink" {
match if (binary-to-ascii (16,8,":",substring(hardware,1,4)) = "c8:d3:a3:8d") or
(binary-to-ascii (16,8,":",substring(hardware,1,4)) = "90:94:e4:72");
option option-66 "10.1.1.50/dlink/";
}
class "yealink" {
match if substring (option vendor-class-identifier,0,7) = "Yealink";
option option-66 "10.1.1.50/yealink/";
}
Phones had to be forcibly excluded from the general pool. Otherwise, they refused to go to their 'frog pond'.
Subnet configuration example
subnet 10.1.1.0 netmask 255.255.255.0 {
option routers 10.1.1.1;
pool {
deny members of "cisco";
deny members of "panasonic";
deny members of "dlink";
range 10.1.1.230 10.1.1.240;
}
pool {
allow members of "cisco";
range 10.1.1.65 10.1.1.69;
}
pool {
allow members of "panasonic";
range 10.1.1.60 10.1.1.64;
}
pool {
allow members of "dlink";
range 10.1.1.55 10.1.1.59;
}
}
After restarting all involved services, the phones confidently directed their settings to the designated tftp server. All that was left was to place them there.
Cisco 7906
These devices came to me in their factory packaging. I had to reflash them to work with Asterisk. But that's a different story. In this particular case, to configure the device, I created a file named SEPAABBCCDDEEFF.cnf.xml at the root of the tftp server, where AABBCCDDEEFF is the device's MAC address.
There have been many writings about configuring Cisco phones, so I will simply leave the working configuration file.
Settings for Cisco
true
SIP
root
ADMIN_PWD
D-M-Y
Central Pacific Standard Time
10.1.1.4
Unicast
10.1.1.50
2000
5060
5061
10.1.1.50
Disable
120
true
x-cisco-serviceuri-cfwdall
x-cisco-serviceuri-pickup
x-cisco-serviceuri-opickup
x-cisco-serviceuri-gpickup
x-cisco-serviceuri-meetme
x-cisco-serviceuri-abbrdial
false
2
true
true
2
2
0
true
false
6
10
180
3600
5
120
120
5
500
4000
70
true
None
1
false
true
false
false
none
101
3
avt
3
false
false
Cisco Phone
2
false
15000
10
true
false
16384
32766
9
10.1.1.50
5060
2
3
false
3
4
5
true
true
false
true
User #103
103
103
SIP_PWD
$num
5060
184
0
dialplan.xml
*0#
true
2
false
false
1
0
1
0
0
0
1
0
1,7
09:00
12:00
01:00
1
2
10.1.1.50
0
100
50
0
0
5
1
10.1.1.50
0
0
0
0
0
0
1
1
1143565489-a3cbf294-7526-4c29-8791-c4fce4ce4c37
Russian_Russian_Federation
ru_RU
utf-8
1
0
http://10.1.1.50/provisioning/cisco-services.xml
http://10.1.1.50/provisioning/cisco-services.xml
96
0
96
2
0
0
3804
<!-- 10.1.1.50 -->
false
1
D-Link DPH-150S/F3
If you're about to purchase a phone from this series, be cautious, as auto-configuration is supported only in the 150S/F3 model. In the 150S/F2 device that came into my hands, I did not find such functionality.
The configuration file can be in either xml format or plain text. For xml, there is one requirement: the tag must be at the beginning of the line; otherwise, the parser will ignore it and the corresponding parameter value will not change.
To configure the phone, two files are used. f0D00580000.cfg — to store the settings for all phones, and 00112233aabb.cfg (MAC address in lowercase) for individual settings. Individual settings, of course, take precedence.
The complete set of settings contains more than a thousand lines; to avoid cluttering the article, I will describe the minimum sufficient set of settings.
The mandatory elements are the root node VOIP_CONFIG_FILE and the embedded node version. Settings will be applied only if the file version is higher than the current settings in the device. This value can be found through the web interface of the phone in the maintenance section (system management). For factory-default phones, in both cases, this is 2.0002. Additionally, the version of the individual file must be higher than the version of the general file.
First, I will present the file with the general configuration for all phones. Essentially, it contains all settings; the individual file will only manage the phone number and the display text.
In the two blocks below, the time zone and time synchronization parameters are set, the initial port for RTP is established, and a network bridge between the WAN and LAN ports of the device is enabled.
Fragment #1
DHCP 2 1 1 0 VOIP 10000 200 10.1.1.4 1 0 60 12 1500 1 1
The names of the configuration parameters are quite self-explanatory, so there's no need for detailed descriptions.
SIP for a single line
5060 SIP1 10.1.1.50 5060 3600 1 10.1.1.50 1 0 G711A,G711U,G722
Remote management settings
23 80 0 443 1 0 Item1 10.1.1.152 10.1.1.160 Account1 admin ADMIN_PWD 10 Account2 guest GUEST_PWD 5
Phone settings
123 0 112 Company 5 1 30 0 1 0,,1 0 0 1 XML-PBook1 Phonebook http://10.1.1.50/provisioning/dlink-phonebook.xml : 0 0 friend,home,work,business,classmate,colleague
All other settings will remain 'default'. Now, any Dlink phone connected to the network will immediately accept the common set of parameters. To set individual parameters for a device, a separate file is needed. This file should only specify the necessary settings for the individual subscriber.
subscriber settings
2.0006 SIP1 User #117 117 5060 117 SIP_PWD 3600 1 5060 117 SIP_PWD
Panasonic UT-KX123B
These devices receive settings in a slightly different manner. The configuration is stored in text files. The maximum size of a configuration file is 120 KB. Regardless of the number of files, their total size must not exceed 120 KB.
The configuration file consists of a set of lines, subject to the conditions specified below:
- The first line is always a comment line, which must include the following sequence of characters (44 bytes):
# Panasonic SIP Phone Standard Format File #
The hexadecimal representation of this sequence is:
23 20 50 61 6E 61 73 6F 6E 69 63 20 53 49 50 20 50 68 6F 6E 65 20 53 74 61 6E 64 61 72 64 20 46 6F 72 6D 61 74 20 46 69 6C 65 20 23
To prevent accidental alteration of the specified character sequence, it is recommended to start the configuration file with a line:
# Panasonic SIP Phone Standard Format File # DO NOT CHANGE THIS LINE! - Configuration files must end with an empty line.
- Each line must end with the sequence "".
- The maximum length of a line is 537 bytes, including the sequence "".
- The following lines are ignored:
- lines exceeding the limit of 537 bytes;
- empty lines;
- comment lines, starting with the symbol "#";
- Each parameter line is recorded in the form XXX="yyy" (XXX: parameter name, yyy: its value). The value must be enclosed in double quotes.
- Breaking the parameter line into multiple lines is not allowed. This will lead to a configuration file processing error and consequently a failure to initialize.
- Values for some parameters must be specified separately for each line. A parameter with the suffix "_1" in its name is for line 1; "_2" is for line 2, and so on.
- The maximum length of a parameter name is 32 characters.
- The maximum length of a parameter value is 500 characters, excluding double quote characters.
- Spaces in the string are not allowed except when the value includes a space character.
- Some parameter values can be specified as 'empty' to set a parameter to an empty value.
- Parameters are specified without a specific order.
- If the same parameter is specified more than once in the configuration file, the first specified value will be used.
Such a serious set of requirements for the configuration file honestly disappointed me. In my opinion, the interaction with proxy server management for Panasonic phones is extremely inconvenient. By this parameter, the phone significantly lags behind others.
Upon first boot (or after a factory reset), the device tries to load the so-called product file (in this case it is KX-UT123RU.cfg), which should contain the paths to the other configuration files.
Product file# Panasonic SIP Phone Standard Format File # DO NOT CHANGE THIS LINE!
CFG_STANDARD_FILE_PATH="tftp://10.1.1.50/panasonic/{mac}.cfg"
CFG_PRODUCT_FILE_PATH="tftp://10.1.1.50/panasonic/KX-UT123RU.cfg"
CFG_MASTER_FILE_PATH="tftp://10.1.1.50/panasonic/master.cfg"
After this, the phone will display a message about the successful completion of preparation and will wait for a reboot. Only after rebooting will it begin to process its configuration files.
In the master.cfg file, it's recommended to specify common settings for all phones. As with Dlink, I will mention only a few parameters. The names of other parameters and their values can be found in the manufacturer's documentation.
master.cfg############################################################
# System Settings #
############################################################
## Login Account Settings
ADMIN_ID="admin"
ADMIN_PASS="ADMIN_PWD"
USER_ID="user"
USER_PASS="USER_PWD"
## System Time Settings
NTP_ADDR="10.1.1.4"
TIME_ZONE="660"
DST_ENABLE="N"
DST_OFFSET="60"
DST_START_MONTH="3"
DST_START_ORDINAL_DAY="2"
DST_START_DAY_OF_WEEK="0"
DST_START_TIME="120"
DST_STOP_MONTH="10"
DST_STOP_ORDINAL_DAY="2"
DST_STOP_DAY_OF_WEEK="0"
DST_STOP_TIME="120"
LOCAL_TIME_ZONE_POSIX=""
## Syslog Settings
SYSLOG_ADDR="10.1.1.50"
SYSLOG_PORT="514"
SYSLOG_EVENT_SIP="6"
SYSLOG_EVENT_CFG="6"
SYSLOG_EVENT_VOIP="6"
SYSLOG_EVENT_TEL="6"
## Provisioning Settings
OPTION66_ENABLE="Y"
OPTION66_REBOOT="N"
PROVISION_ENABLE="Y"
CFG_STANDARD_FILE_PATH="tftp://10.1.1.50/panasonic/{mac}.cfg"
CFG_PRODUCT_FILE_PATH="tftp://10.1.1.50/panasonic/KX-UT123RU.cfg"
CFG_MASTER_FILE_PATH="tftp://10.1.1.50/panasonic/master.cfg"
############################################################
# Network Settings #
############################################################
## IP Settings
CONNECTION_TYPE="1"
HOST_NAME="UT123"
DHCP_DNS_ENABLE="Y"
STATIC_IP_ADDRESS=""
STATIC_SUBNET=""
STATIC_GATEWAY=""
USER_DNS1_ADDR=""
USER_DNS2_ADDR=""
## DNS Settings
DNS_QRY_PRLL="Y"
DNS_PRIORITY="N"
DNS1_ADDR="10.1.1.1"
DNS2_ADDR=""
## HTTP Settings
HTTPD_PORTOPEN_AUTO="Y"
HTTP_VER="1"
HTTP_USER_AGENT="Panasonic_{MODEL}/{fwver} ({mac})"
HTTP_SSL_VERIFY="0"
CFG_ROOT_CERTIFICATE_PATH=""
## XML Application Settings
XML_HTTPD_PORT="6666"
XMLAPP_ENABLE="Y"
XMLAPP_USERID=""
XMLAPP_USERPASS=""
XMLAPP_START_URL=""
XMLAPP_INITIAL_URL=" "
XMLAPP_INCOMING_URL=""
XMLAPP_TALKING_URL=""
XMLAPP_MAKECALL_URL=""
XMLAPP_CALLLOG_URL=""
XMLAPP_IDLING_URL=""
XMLAPP_LDAP_URL="»
XMLAPP_LDAP_USERID=""
XMLAPP_LDAP_USERPASS=""
In the individual configuration file of the device, traditionally only subscriber settings remain.
aabbccddeeff.cfgDISPLAY_NAME_1="User #168"
PHONE_NUMBER_1="168"
SIP_URI_1="168"
LINE_ENABLE_1="Enabled"
PROFILE_ENABLE_1="Enabled"
SIP_AUTHID_1="168"
SIP_PASS_1="SIP_PWD"
Grandstream GXP-1400
The parameters of these phones are stored in a single XML file named cfg{mac}.xml or in a plain text file named cfg{mac}. This phone requests only the individual configuration file, so optimizing settings by moving them to a common file is not possible. Another feature of Grandstream settings is the naming of parameters. All of them are numbered and designated as P###. For example:
P1650 – controls the web interface for phone management (0 – HTTPS, 1 – HTTP)
P47 – the SIP server address for connection.
If the configuration is stored in a text file, parameters do not require any grouping and can appear in any order. Lines starting with # are considered comments.
If the settings are presented in XML format, they must be nested within the node , which in turn must be nested within . All parameters are recorded as corresponding tags with the parameter value inside.
Example configuration
1
109
109
109
SIP_PWD
User# 109
10.1.1.50
2
10.1.1.50
0
ADMIN_PWD
USER_PWD
ru
0
10.1.1.50/grandstream
1
TZc-11
10.1.1.4
1
http://10.1.1.50/provisioning/grandstream
30
Yealink T19 and T21
Devices of these models support individual configuration files for devices and common ones for the models. In my case, I had to place the common parameters in the files y000000000031.cfg and y000000000034.cfg respectively. Individual configuration files are named according to the MAC address: 00112233aabb.cfg.
Settings for Yealink devices are stored in text format. The only mandatory requirement is the presence of the version in the first line, in the format #!version:1.0.0.1.
All parameters are recorded in the form of parameter = value. Comments should start with the symbol "#". Parameter names and their values can be found in the documentation on the manufacturer's website.
common settings#!version:1.0.0.1
#Configure the WAN port type; 0-DHCP (default), 1-PPPoE, 2-Static IP Address;
network.internet_port.type = 0
#Configure the PC port type; 0-Router, 1-Bridge (default);
network.bridge_mode = 1
#Configure the access type of the web server; 0-Disabled, 1-HTTP & HTTPS(default), 2-HTTP Only, 3-HTTPS Only;
network.web_server_type = 3
#Configure the maximum local RTP port. It ranges from 0 to 65535, the default value is 11800.
network.port.max_rtpport = 10100
#Configure the minimum local RTP port. It ranges from 0 to 65535, the default value is 11780.
network.port.min_rtpport = 10000
security.user_name.admin = root
security.user_password = root:ADMIN_PWD
security.user_name.user = user
security.user_password = user:USER_PWD
#Specify the web language, the valid values are: English, Chinese_S, Turkish, Portuguese, Spanish, Italian, French, Russian, Deutsch and Czech.
lang.wui = Russian
#Specify the LCD language, the valid values are: English (default), Chinese_S, Chinese_T, German, French, Turkish, Italian, Polish, Spanish and Portuguese.
lang.gui = Russian
#Configure the time zone and time zone name. The time zone ranges from -11 to +12, the default value is +8.
#The default time zone name is China(Beijing).
#Refer to Yealink IP Phones User Guide for more available time zones and time zone names.
local_time.time_zone = +11
local_time.time_zone_name = Vladivostok
#Configure the domain name or the IP address of the NTP server. The default value is cn.pool.ntp.org.
local_time.ntp_server1 = 10.1.1.4
#Configure the logo mode of the LCD screen; 0-Disabled (default), 1-System logo, 2-Custom logo;
phone_setting.lcd_logo.mode = 1
#Configure the access URL and dispaly name of the remote phonebook. X ranges from 1 to 5.
remote_phonebook.data.1.url =
remote_phonebook.data.1.name = Phonebook
features.remote_phonebook.flash_time = 3600
individual settings#!version:1.0.0.1
#Enable or disable the account1, 0-Disabled (default), 1-Enabled;
account.1.enable = 1
#Configure the label displayed on the LCD screen for account1.
account.1.label = Test phone
#Configure the display name of account1.
account.1.display_name = User 998
#Configure the username and password for register authentication.
account.1.auth_name = 998
account.1.password = 998
#Configure the register user name.
account.1.user_name = 998
#Configure the SIP server address.
account.1.sip_server_host = 10.1.1.50
#Specify the port for the SIP server. The default value is 5060.
account.1.sip_server_port = 5060
As a result, thanks to the wonderful auto-provision feature provided in the aforementioned phones, there were no problems connecting new devices to the network. It all boiled down to finding the phone's MAC address and generating a configuration file based on a template.
I hope you read to the end and found the content beneficial.
Thank you for your attention.
Source: habr.com
