Telephone system:Cisco phone deployment

From Hackerspace ACKspace
Jump to: navigation, search

Some notes and configuration snippets for deploying the Cisco 79xx series phones


Most settings are taken from Xopr's Asus WL500g running OpenWRT kamikaze RC6 with pivot-rooted USB drive and OpenVPN tunnel. (there's not enough room to host the firmware's on the flash ;)

stuff to know

  • tested with a lot of factory default resets because firmware and/or configs seem to cache unpredictable
  • not clear how to enable logging on atftpd for OpenWRT, either as --no-daemon or writing to log files
  • atftpd on OpenWRT sometimes seemed to crash (testing sccp), resulting in the following behaviour:
    • for sip: 'Requesting Configuration' (seems to boot with cached settings)
    • for sccp: 'Configuring CM List' (seems to boot with cached settings)
    • for factory default: 'Phone Unprovisioned' / UNPROVISIONED
  • couldn't manage to factory reset the 7905 and 7910

DHCP

dnsmasq

small part in /etc/dnsmasq.conf

dhcp-option=66,LOCAL_TFTPD_IP
dhcp-option=150,LOCAL_TFTPD_IP

Note: when setting the TFT server using command line parameters, don't use extra (escaped) quotes: small part in /etc/init.d/S50dnsmasq (uncomment the args to enable the config file mentioned above

args="-K -F $START,$END,$NETMASK,${lease:-12h} --dhcp-option=66,${ipaddr} --dhcp-option=150,${ipaddr}"

TFTP

atftpd

cat /etc/init.d/S55atftpd
#!/bin/sh
/usr/sbin/atftpd --daemon --port 69 --tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100

contents of /tftpboot

dialplan.xml
OS79XX.TXT
P00308000600.bin
P00308000600.loads
P00308000600.sb2
P00308000600.sbn
P00405000700.bin                      
P00405000700.sbn
P0S3-06-3-00.bin
P0S3-8-12-00.loads
P0S3-06-3-00.sbn
P0S3-8-12-00.sb2
RINGLIST.DAT
S00105000300.sbn
SIPDefault.cnf
SEP<mac_of_sccp_phone_w_ext>.cnf.xml
SIP<mac_of_sip_phone>.cnf
XMLDefault.cnf.xml

File contents

dialplan.xml

<DIALTEMPLATE>
    <TEMPLATE MATCH="\*..#"            Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="\**#"             Timeout="3" User="Phone"/> 
    <TEMPLATE MATCH="\*...#"           Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="\**#"             Timeout="3" User="Phone"/> 
    <TEMPLATE MATCH="\*..#"            Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="\*#..#"           Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="\*#...#"          Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="#..#"             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="#...#"            Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="00*"              Timeout="6" User="Phone"/> 
    <TEMPLATE MATCH="0........."       Timeout="1" User="Phone"/> 
    <TEMPLATE MATCH="10.."             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="12.."             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="13.."             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="131.........."    Timeout="1" User="Phone"/> 
    <TEMPLATE MATCH="#31#.........."   Timeout="1" User="Phone"/> 
    <TEMPLATE MATCH="\*31\*.........." Timeout="1" User="Phone"/> 
    <TEMPLATE MATCH="132.........."    Timeout="1" User="Phone"/> 
    <TEMPLATE MATCH="\*10.."           Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="\*19.."           Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="19.."             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="2222"             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="4444"             Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="112"              Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="911"              Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="999"              Timeout="0" User="Phone"/> 
    <TEMPLATE MATCH="*"                Timeout="4" User="Phone"/> 
</DIALTEMPLATE>

OS79XX.TXT

P0S3-06-3-00

RINGLIST.DAT

CTU	CTU24raw.raw
Chicken	chicken2.raw
New York	newyork.raw
Star Wars	starwars.raw
Old Style	ringer1.pcm
Synth Low	ringer2.pcm

SIPDefault.cnf

# Image Version
#image_version: "P0S3-8-12-00"

# Proxy Server
proxy1_address: "FREESWITCH_IP"

# Proxy Server Port (default - 5060)
proxy1_port:"5060"

# Emergency Proxy info
proxy_emergency: "FREESWITCH_IP"
proxy_emergency_port: "5060"

# Backup Proxy info
proxy_backup: "FREESWITCH_IP"
proxy_backup_port: "5060"

# Outbound Proxy info
outbound_proxy: "FREESWITCH_IP"
outbound_proxy_port: "5060"

# NAT/Firewall Traversal
nat_enable: "1" # Only enable when using the OpenVPN tunnel; remote office
nat_address: "10.0.50.13" # TODO: try and remove it from either this or the specific config

voip_control_port: "5061"
start_media_port: "16384"
end_media_port: "32766"
nat_received_processing: "0"

# Proxy Registration (0-disable (default), 1-enable)
proxy_register: "1"

# Phone Registration Expiration [1-3932100 sec] (Default - 3600)
timer_register_expires: "100" # below 120 seconds for maintaining UDP 'connection' state in Linux

# Codec for media stream (g711ulaw (default), g711alaw, g729)
preferred_codec: "none"

# TOS bits in media stream [0-5] (Default - 5)
tos_media: "5"

# Enable VAD (0-disable (default), 1-enable)
enable_vad: "0"

# Allow for the bridge on a 3way call to join remaining parties upon hangup
cnf_join_enable: "1" ; 0-Disabled, 1-Enabled (default)

# Allow Transfer to be completed while target phone is still ringing
semi_attended_transfer: "1" ; 0-Disabled, 1-Enabled (default)

# Telnet Level (enable or disable the ability to telnet into this phone
telnet_level: "2" ; 0-Disabled (default), 1-Enabled, 2-Privileged

# Inband DTMF Settings (0-disable, 1-enable (default))
dtmf_inband: "1"

# Out of band DTMF Settings (none-disable, avt-avt enable (default), avt_always - always avt ) dtmf_outofband: "avt" ~np~# DTMF dB Level Settings (1-6dB down, 2-3db down, 3-nominal (default), 4-3db up, 5-6dB up)
dtmf_db_level: "3"

# SIP Timers
timer_t1: "500" ; Default 500 msec
timer_t2: "4000" ; Default 4 sec
sip_retx: "10" ; Default 11
sip_invite_retx: "6" ; Default 7
timer_invite_expires: "180" ; Default 180 sec

# Setting for Message speeddial to mail box (*97)
messages_uri: "1233"

# TFTP Phone Specific Configuration File Directory
tftp_cfg_dir: "./"

# Time Server
sntp_mode: "unicast"
sntp_server: "time.nist.gov" # IP address here alternatively
time_zone: "CET"
dst_offset: "1"
dst_start_month: "April"
dst_start_day: ""
dst_start_day_of_week: "Sun"
dst_start_week_of_month: "1"
dst_start_time: "02"
dst_stop_month: "Oct"
dst_stop_day: ""
dst_stop_day_of_week: "Sunday"
dst_stop_week_of_month: "8"
dst_stop_time: "2"
dst_auto_adjust: "1"

# Do Not Disturb Control (0-off, 1-on, 2-off with no user control, 3-on with no user control)
dnd_control: "0" ; Default 0 (Do Not Disturb feature is off)

# Caller ID Blocking (0-disabled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
callerid_blocking: "0" ; Default 0 (Disable sending all calls as anonymous)

# Anonymous Call Blocking (0-disbaled, 1-enabled, 2-disabled no user control, 3-enabled no user control)
anonymous_call_block: "0" ; Default 0 (Disable blocking of anonymous calls)

# Call Waiting (0-disabled, 1-enabled, 2-disabled with no user control, 3-enabled with no user control)
call_waiting: "1" ; Default 1 (Call Waiting enabled)

# DTMF AVT Payload (Dynamic payload range for AVT tones - 96-127)
dtmf_avt_payload: "101" ; Default 100

# XML file that specifies the dialplan desired
dial_template: "dialplan"

# Network Media Type (auto, full100, full10, half100, half10)
network_media_type: "auto"

#Autocompletion During Dial (0-off, 1-on [default])
autocomplete: "0"

#Time Format (0-12hr, 1-24hr [default])
time_format_24hr: "0"

# URL for external Phone Services
services_url: "http://FREESWITCH_IP/provisioning/services.php" # IP address here alternatively

# URL for external Directory location
directory_url: "http://FREESWITCH_IP/provisioning/directory.php" # IP address here alternatively

# URL for branding logo
logo_url: "http://FREESWITCH_IP/provisioning/ACKspace.bmp" # IP address here alternatively

# Remote Party ID
remote_party_id: 1 ; 0-Disabled (default), 1-Enabled 

XMLDefault.cnf.xml

<Default>
  <callManagerGroup>
    <members>
      <member priority="0">
        <callManager>
          <ports>
            <ethernetPhonePort>2000</ethernetPhonePort>
          </ports>
          <processNodeName>FREESWITCH_IP</processNodeName>
        </callManager>
      </member>
    </members>
    <loadInformation6 model="IP Phone 7910">P00308000600</loadInformation6>
    <loadInformation124 model="Addon 7914">S00105000300</loadInformation124>
    <loadInformation8 model="IP Phone 7940">P00308000600</loadInformation8>
  </callManagerGroup>
</Default>

Cisco CP-7900 configuration

Setting up configuration files can be done by using the gencfg.sh script. It uses both SEP.cnf.xml and SIP.cnf template files to create config files that can either set up SIP or SCCP.

extra info

auto_answer.pl

#!/usr/bin/perl
#Set auto_answer on cisco 79xx phone via telnet.
#Hack around the inability of the sip software to set via a config file.

#Public domain, no warranty at all. (http://www.comtek.co.uk)

use Net::Telnet();
use List::Util qw(reduce);
use constant PROMPT => "SIP Phone";
use constant PASSWORD => "cisco";

@to_set=();
@to_unset=();

if((@ARGV<3)||(!(@ARGV%2)))
{
        print "Syntax: set_auto_answer <ip> <list>\n\twhere <list> is a list of "
          ." one or more '<line num> <0|1>'\n"
          ."\nEg: set_auto_answer 1.1.1.1 1 0 2 1\n";
        exit 1;
}
$target_ip=shift;

do
{
        my ($line, $setting)=(shift, shift);
        if($setting)
        {
                push(@to_set, $line);
        }
        else
        {
                push(@to_unset, $line);
        }
}while(@ARGV);

#For logs, use "" or *STDOUT
$t=new Net::Telnet(Timeout => 1, Output_log => *STDOUT, Input_log => "", Dump_log => "");
$t->open($target_ip);

$t->waitfor('/Password :.*$/');
$t->print(PASSWORD);

$t->waitfor('/'.PROMPT.'>.*$/');

@tmp=$t->cmd("show config");
@tmp=grep(/^auto_answer : /, @tmp);
die("Bad auto_answer")
  if(scalar(@tmp)!=1);

@tmp[0]=~/([0-9]+)/;
$auto_answer=$1;

@to_set=grep {  !(1<<($_-1) & $auto_answer)  } @to_set;
@to_unset=grep {1<<($_-1) & $auto_answer} @to_unset;

exit 0
  if( !@to_unset && !@to_set  );

print "Enabling auto-answer for line(s): ".(reduce {$a.", ".$b} @to_set)."\n"
  if(@to_set);
print "Disabling auto-answer for line(s): ".(reduce {$a.", ".$b} @to_unset)."\n"
  if(@to_unset);

$t->print("test open");

sub wait_then_press
{
        foreach my $key (@_)
        {
                $t->waitfor('/'.PROMPT.'>.*$/');
                $t->print("test ".$key);
        }
}

sub toggle_line
{
        my($line)=@_;
        wait_then_press("offhook", "onhook", "key set", "key 6", "key 8", "key ".$line, "key soft1", "key soft2", "key soft2", "key set");
}

foreach my $line (@to_unset, @to_set)
{
        print "Toggling line: $line\n";
        toggle_line($line);
}

$t->waitfor('/'.PROMPT.'>.*$/');
$t->print("test close");

$t->waitfor('/'.PROMPT.'>.*$/');
$t->print("exit");

print "Success.\n";