I wrote the following script to support the automated construction of a full-mesh configuration of dial-peers in Cisco IOS.
The original driver for this was a scalability issue with Cisco's Call Manager Express (CME) feature in that each time a new site, or range of DIDs for an existing site, was added to the network then every other router in the network would have to be touched to update the configuration with a new dial-peer for the new DID range. This isn't an issue really when you have a Unity Call Manager managing everything and acting as a centralized directory server. However, when you have no central source of directory information (like when you are trying to save money and implementing VoIP on a very tight budget) you need some efficient way to keep all of the routers in the network educated about all of the DID ranges in the network. The below script helped me do that and works great for my needs.
#!/bin/sh VCC="voice class codec 1000 codec preference 1 g711ulaw codec preference 2 g729r8 bytes 30 codec preference 3 g729br8 bytes 30" cat dp_list.txt | while read a target_router b c; do outfile="${target_router}_dp_config.txt" echo "!" >${outfile} echo "${VCC}" >>${outfile} echo "!" >>${outfile} cat dp_list.txt | grep -v ${target_router} | while read sequence hostname pattern ipv4_target; do echo "dial-peer voice ${sequence} voip" >> ${outfile} echo "descrip SEQ ${sequence} FOR ${pattern} TO ${hostname} AT ${ipv4_target}" >> ${outfile} echo "destination-pattern ${pattern}" >> ${outfile} echo "progress_ind setup enable 3" >> ${outfile} echo "voice-class codec 1000" >> ${outfile} echo "voice-class h323 1" >> ${outfile} echo "session target ipv4:${ipv4_target}" >> ${outfile} echo "dtmf-relay h245-alphanumeric" >> ${outfile} echo "ip qos dscp ef media" >> ${outfile} echo "ip qos dscp af41 signaling" >> ${outfile} echo "!" >> ${outfile} done echo "end" >> ${outfile} echo "" >> ${outfile} done |
Ok, so for this script you need to supply an input file with the following tab-delimited pieces of information:
- Sequential dial-peer numeric identifier. I start mine at 1000000 and increment by 10.
- Destination router hostname
- DID/Number range (regex encouraged!)
- IPv4 address of destination router
Here is a sample of that input:
1000270 router027 91859960.. 192.168.1.27 1000280 router028 9185826953 192.168.1.28 1000290 router029 9185831071 192.168.1.29 1000300 router030 86381680.. 192.168.1.30 1000310 router027 86381681.. 192.168.1.27 1000320 router029 863686[0-3][1-4].. 192.168.1.29 |
In this example, you can see that additional ranges were added to sites 27 and 29, but this is no problem for the script, it does the right thing. The most important part is keeping the sequence number unique. You could even make it more intuitive by embedding the site number into the sequence number, like 1XXXXYY, where XXXX is your site number (assuming you have <10k sites) and YY are the DID/number ranges for the site (assuming <=100 ranges per site). This would make the above sequence 1000290->1002900 and 1000320->1002901. You get the idea.
Of course, this can be extended in any way that meets your needs. The important part of the script is that it builds a config for each hostname that includes all rows from the input file that are from !hostname. Once the configurations are built, you can use SNMP & TFTP to get them loaded to each router in the network. Further still, using cron to run the script & TFTP load on a regular basis will always keep everything in sync. Let the machines do the work for you!
Leave me comments if you like, don't like, have ideas for improvement, etc. If you want, also give a visit to an advertiser.
No comments:
Post a Comment