Auto provisioning for Fanvil BW210P

Auto provisioning for Fanvil BW210P

Fanvil devices are used for IP telephony in our office. Time will tell how justified the choice in favor of cheaper Chinese products is, and I will talk about how I implemented the auto provisioning mechanism on Fanvil BW210P models.

For those who are not familiar with this term, but by some miracle read up to this place, I will explain that auto provisioning is a mechanism that allows you to centrally manage the settings of IP phones.

What it looks like.
The telephone connects to the FTP server, finds its configuration file, and checks the version of the configuration file on server with your own. If the number is different, the config file is applied.

The process uses four files:
dsc.exe - dsCrypt utility. Used to encrypt ready-made configs.(Windows utility. Unfortunately, neither aescrypt, nor aespipe, nor other Linux utilities could create encryption understandable for a telephone set. If someone knows those and tells about them, I would be grateful.)
genconf.sh - a script that generates a ready-made config.
key.txt - a file with an encryption key. The key consists of 64 HEX characters.
users - this can be said to be the base of phones. Contains mac address of the device, sip number and password.

Pure-FTPd server is deployed on Ubuntu 10.04.
Because using the Windows utility had to install wine.

Contents of genconf.sh

#!/bin/bash
uspath=/opt/pathtousersfile/
usfile=(`cat $uspath/users`) 
macdir=/home/pathtoconfigfiles/
a=0 
b=1
c=2

while [ ${usfile[$a]} ] 
do 
dfile=$macdir${usfile[$a]}.txt 

cat <<EOF >>$dfile 
<<VOIP CONFIG FILE>>Version:2.0007                            

<GLOBAL CONFIG MODULE> 
Static IP          :192.168.1.179 
Static NetMask     :255.255.255.0 
Static GateWay     :192.168.1.1 
Default Protocol   :2 
Primary DNS        :202.96.134.133 
Alter DNS          :202.96.128.68 
DHCP Mode          :1 
DHCP Dns           :1 
Domain Name        : 
Host Name          :VOIP 
Pppoe Mode         :0 
HTL Start Port     :10000 
HTL Port Number    :200 
SNTP Server        :209.81.9.7 
Enable SNTP        :1 
Time Zone          :44 
Enable Daylight    :0 
SNTP Time Out      :60 
DayLight Shift Min :60 
DayLight Start Mon :3 
DayLight Start Week:5 
DayLight Start Wday:0 
DayLight Start Hour:2 
DayLight Start Min :0 
DayLight End Mon   :10 
DayLight End Week  :5 
DayLight End Wday  :0 
DayLight End Hour  :2 
DayLight End Min   :0 
MMI Set            :-1 
MTU Length         :1500 
Register WD Time   :0 

<LAN CONFIG MODULE> 
Lan Ip             :192.168.10.1 
Lan NetMask        :255.255.255.0 
Bridge Mode        :1 

<TELE CONFIG MODULE> 
Dial End With #    :1 
Dial Fixed Length  :0 
Fixed Length       :11 
Dial With Timeout  :1 
Dial Timeout value :5 
Dialpeer With Line :0 
Poll Sequence      :0 
Accept Any Call    :1 
Phone Prefix       : 
Local Area Code    : 
IP call network    :. 
--Port Config--    : 
P1 No Disturb      :0 
P1 Mute            :0 
P1 No Dial Out     :0 
P1 No Empty Calling:0 
P1 Enable CallerId :1 
P1 Forward Service :0 
P1 SIP TransNum    : 
P1 SIP TransAddr   : 
P1 SIP TransPort   :5060 
P1 CallWaiting     :1 
P1 CallTransfer    :1 
P1 Call3Way        :1 
P1 AutoAnswer      :0 
P1 No Answer Time  :20 
P1 Warm Line Time  :0 
P1 Extention No.   : 
P1 Auto HandDown   :0 
P1 Auto Handdown Ti:3 
P1 Hotline Num     : 
P1 Record Server   : 
P1 Enable Record   :0 
P1 Busy N/A Line   :0 

<DSP CONFIG MODULE> 
Signal Standard    :1 
Handdown Time      :200 
G729 Payload Length:1 
G723 Bit Rate      :1 
G722 Timestamps    :0 
VAD                :1 
Ring Type          :1 
Dtmf Payload Type  :101 
Disable Handfree   :0 
RTP PROBE          :0 
--Port Config--    : 
P1 Output Vol      :5 
P1 Input Vol       :3 
P1 HandFree Vol    :5 
P1 RingTone Vol    :5 
P1 Codec           :-1 
P1 Voice Record    :0 
P1 Record Playing  :1 
P1 UserDef Voice   :0 
P1 First Codec     :0 
P1 Second Codec    :1 
P1 Third Codec     :17 
P1 Forth Codec     :15 
P1 Fifth Codec     :23 
P1 Sixth Codec     :9 

<SIP CONFIG MODULE> 
SIP  Port          :5060 
Stun Address       : 
Stun Port          :3478 
Stun Effect Time   :50 
SIP  Differv       :0 
Extern Address     : 
Url Convert        :1 
Reg Retry Time     :32 
Strict BranchPrefix:1 
--SIP Line List--  : 
EOF 
">>$dfile1 Phone Number  :${usfile[$b]} 
">>$dfile1 Display Name  :${usfile[$b]} 
">>$dfile1 Sip Name      : 
">>$dfile1 Register Addr :voip.server.net
">>$dfile1 Register Port :5060 
">>$dfile1 Register User :${usfile[$b]} 
">>$dfile1 Register Pwd  :${usfile[$c]} 
">>$dfile1 Register TTL  :32 
">>$dfile1 Enable Reg    :1 
">>$dfile1 Proxy Addr    :voip.neoflex.ru 
">>$dfile1 Proxy Port    :5060 
">>$dfile1 Proxy User    :${usfile[$b]} 
">>$dfile1 Proxy Pwd     :${usfile[$c]} 
cat <<EOF >>$dfile 
SIP1 Signal Enc    :0 
SIP1 Signal Key    : 
SIP1 Media Enc     :0 
SIP1 Media Key     : 
SIP1 Local Domain  : 
SIP1 Fwd Service   :0 
SIP1 Ring Type     :0 
SIP1 Fwd Number    : 
SIP1 Hotline Number: 
SIP1 Enable Detect :0 
SIP1 Detect TTL    :60 
SIP1 Server Type   :0 
SIP1 User Agent    :Voip Phone 1.0 
SIP1 PRACK         :0 
SIP1 KEEP AUTH     :0 
SIP1 Session Timer :0 
SIP1 Gruu          :0 
SIP1 DTMF Mode     :1 
SIP1 DTMF SIP-INFO :0 
SIP1 Use Stun      :0 
SIP1 Via Port      :1 
SIP1 Subscribe     :0 
SIP1 Sub Expire    :300 
SIP1 Single Codec  :0 
SIP1 CLIR          :0 
SIP1 Strict Proxy  :0 
SIP1 Direct Contact:0 
SIP1 History Info  :0 
SIP1 DNS SRV       :0 
SIP1 Transfer Expir:0 
SIP1 Ban Anonymous :0 
SIP1 Dial Without R:0 
SIP1 DisplayName Qu:0 
SIP1 Presence Mode :0 
SIP1 RFC Ver       :1 
SIP1 Signal Port   :0 
SIP1 Transport     :0 
SIP1 Use Mixer     :0 
SIP1 Mixer Uri     : 
SIP1 Long Contact  :0 
SIP1 Auto TCP      :0 
SIP1 Click to Talk :0 
SIP1 Mwi No.       : 
SIP1 Park No.      : 
SIP1 Help No.      : 
SIP2 Phone Number  : 
SIP2 Display Name  : 
SIP2 Sip Name      : 
SIP2 Register Addr : 
SIP2 Register Port :5060 
SIP2 Register User : 
SIP2 Register Pwd  : 
SIP2 Register TTL  :60 
SIP2 Enable Reg    :0 
SIP2 Proxy Addr    : 
SIP2 Proxy Port    :5060 
SIP2 Proxy User    : 
SIP2 Proxy Pwd     : 
SIP2 Signal Enc    :0 
SIP2 Signal Key    : 
SIP2 Media Enc     :0 
SIP2 Media Key     : 
SIP2 Local Domain  : 
SIP2 Fwd Service   :0 
SIP2 Ring Type     :0 
SIP2 Fwd Number    : 
SIP2 Hotline Number: 
SIP2 Enable Detect :0 
SIP2 Detect TTL    :60 
SIP2 Server Type   :0 
SIP2 User Agent    :Voip Phone 1.0 
SIP2 PRACK         :0 
SIP2 KEEP AUTH     :0 
SIP2 Session Timer :0 
SIP2 Gruu          :0 
SIP2 DTMF Mode     :1 
SIP2 DTMF SIP-INFO :0 
SIP2 Use Stun      :0 
SIP2 Via Port      :1 
SIP2 Subscribe     :0 
SIP2 Sub Expire    :300 
SIP2 Single Codec  :0 
SIP2 CLIR          :0 
SIP2 Strict Proxy  :0 
SIP2 Direct Contact:0 
SIP2 History Info  :0 
SIP2 DNS SRV       :0 
SIP2 Transfer Expir:0 
SIP2 Ban Anonymous :0 
SIP2 Dial Without R:0 
SIP2 DisplayName Qu:0 
SIP2 Presence Mode :0 
SIP2 RFC Ver       :1 
SIP2 Signal Port   :0 
SIP2 Transport     :0 
SIP2 Use Mixer     :0 
SIP2 Mixer Uri     : 
SIP2 Long Contact  :0 
SIP2 Auto TCP      :0 
SIP2 Click to Talk :0 
SIP2 Mwi No.       : 
SIP2 Park No.      : 
SIP2 Help No.      : 

<IAX2 CONFIG MODULE> 
Server   Address   : 
Server   Port      :4569 
User     Name      : 
User     Password  : 
User     Number    : 
Voice    Number    :0 
Voice    Text      :mail 
EchoTest Number    :1 
EchoTest Text      :echo 
Local    Port      :4569 
Enable   Register  :0 
Refresh  Time      :60 
Enable   G.729     :0 

<PPPoE CONFIG MODULE> 
Pppoe User         :user123 
Pppoe Password     :XXXXXXX 
Pppoe Service      :ANY 
Pppoe Ip Address   : 

<MMI CONFIG MODULE> 
Telnet Port        :23 
Web Port           :80 
Remote Control     :1 
Enable MMI Filter  :0 
Telnet Prompt      : 
--MMI Account--    : 
Account1 Name      :admin 
Account1 Pass      :XXXXXXXXX 
Account1 Level     :10 
Account2 Name      :guest 
Account2 Pass      :XXXXXXXX
Account2 Level     :5 

<QOS CONFIG MODULE> 
Enable VLAN        :0 
Enable diffServ    :0 
DiffServ Value     :0 
VLAN ID            :0 
802.1P Value       :0 
VLAN Recv Check    :0 
Data VLAN ID       :0 
Data 802.1P Value  :0 
Diff Data Voice    :0 
Enable PVID        :0 
PVID Value         :0 

<DEBUG CONFIG MODULE> 
MGR Trace Level    :0 
SIP Trace Level    :0 
IAX Trace Level    :0 
Trace File Info    :0 

<AAA CONFIG MODULE> 
Enable Syslog      :0 
Syslog address     :0.0.0.0 
Syslog port        :514 

<ACCESS CONFIG MODULE> 
Enable In Access   :0 
Enable Out Access  :0 

<DHCP CONFIG MODULE> 
Enable DHCP Server :0 
DHCP Relay Target  : 
Enable DNS Relay   :1 
DHCP Update Flag   :0 
TFTP  Server       :0.0.0.0 
--DHCP List--      : 
Item1 name         :lan 
Item1 Start Ip     :192.168.10.1 
Item1 End Ip       :192.168.10.30 
Item1 Param        :snmk=255.255.255.0:maxl=1440:rout=192.168.10.1:dnsv=192.168.10.1 

<NAT CONFIG MODULE> 
Enable Nat         :1 
Enable Ftp ALG     :1 
Enable H323 ALG    :0 
Enable PPTP ALG    :1 
Enable IPSec ALG   :1 

<PHONE CONFIG MODULE> 
Keypad Password    :XXXX
LCD Logo           :t 
Time 12hours       :0 
MWI Number         :*97 
Display PhoneNum   :0 
Memory Key 1       : 
Memory Key 2       : 
Memory Key 3       : 
Memory Key 4       : 
Memory Key 5       : 
Memory Key 6       : 
Memory Key 7       : 
Memory Key 8       : 
Memory Key 9       : 
Memory Key 10      : 
Missed Call Led    :1 
Voice Message Led  :1 

<AUTOUPDATE CONFIG MODULE> 
Download Username  :admin 
Download password  :XXXXXXXXXX 
Download Server IP :voip-set.server.net 
Config File Name   : 
Config File Key    :fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Download Protocol  :1 
Download Mode      :2 
Download Interval  :1 
DHCP Option 66     :0 

<VPN CONFIG MODULE> 
VPN mode           :-1 
L2TP LNS IP        : 
L2TP User Name     : 
L2TP Password      : 
Enable VPN Tunnel  :0 
VPN Server IP      :0.0.0.0 
VPN Server Port    :80 
Server Group ID    :VPN 
Server Area Code   :12345 
<<END OF FILE>> 
EOF 

./dsc.exe key.txt e $dfile $macdir${usfile[$a]} 
rm $dfile 

a=`expr $a + 3` 
b=`expr $b + 3` 
c=`expr $c + 3` 

done

To customize the file to your settings, you need to change the values ​​of the following fields:

uspath=/opt/pathtousersfile/ 
macdir=/home/pathtoconfigfiles/

In the --SIP Line List--, fields

">>$dfile1 Register Addr		#адрес VOIP сервера
">>$dfile1 Register Port		#порт VOIP сервера
">>$dfile1 Proxy Addr
">>$dfile1 Proxy Port

Section --MMI Account--, fields

Account1 Name		#администратор настроек телефонного аппарата
Account1 Pass		#пароль администратора
Account2 Name		
Account2 Pass 

Section

, поле
Keypad Password #пароль доступа к настройкам непосредственно через телефон MWI Number #номер доступа к голосовой почте

Section

, поля
Download Username #Пользователь FTP сервера Download password #Пароль на FTP сервер Download Server IP #Адрес FTP сервера Config File Key #Ключ шифрования

But I would recommend first configuring the phone via the web interface to your taste, then save the configured config in the MAINTENANCE — CONFIG — Backup Config section. And then insert your file into genconf.sh. Of course, don't forget about the block

--SIP Line List--  : 
EOF 
">>$dfile1 Phone Number  :${usfile[1]} 
">>$dfile1 Display Name  :${usfile[1]} 
">>$dfile1 Sip Name      : 
">>$dfile1 Register Addr :voip.server.net
">>$dfile1 Register Port :5060 
">>$dfile1 Register User :${usfile[1]} 
">>$dfile1 Register Pwd  :${usfile[2]} 
">>$dfile1 Register TTL  :32 
">>$dfile1 Enable Reg    :1 
">>$dfile1 Proxy Addr    :voip.server.net 
">>$dfile1 Proxy Port    :5060 
">>$dfile1 Proxy User    :${usfile[1]} 
">>$dfile1 Proxy Pwd     :${usfile[2]}

The format of the users file is simple and straightforward. Mac address, number, and password separated by spaces.

xxxxxxxxxxxx 101 password
xxxxxxxxxxxx 102 password
xxxxxxxxxxxx 103 password

This completes the server setup. Check that when you run genconf, the necessary files are created in the right place and let's move on to the phone.

In the phone settings itself, in the MAINTENANCE menu, in the AUTO PROVISION section, you need to set the settings to the following form.

Auto provisioning for Fanvil BW210P

It is better to leave the Config File Name field empty. The fact is that by default the phone searches
files in the form of their mas address. Which are formed after running genconf.sh

In my case, after applying the new settings, the Update Mode field value takes the form Update at time interval. This will allow, in case of changing the settings, not to jump around all the devices, but to wait about an hour until the phone updates itself.

After bringing the settings to the appropriate form, you should click Apply and reboot the phone.

Pay attention to the Current Config Version field. It is by this parameter that the phone determines whether to apply the firmware or not. In order for the changes to apply, you need to increase the value <>Version: в файле genconf.sh

To understand if anything is happening at all serverYou can do this by running the following command: iftop -f "dst port 21" -n . You can tell that the settings have been applied successfully by the Current Config Version field, which will differ from the default 2.0002.

P.S. Many thanks to Andrey Volovik from Vimkom for his invaluable tips and recommendations.

Source: habr.com

Buy reliable hosting for sites with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster