Monthly Archives: January 2016

How to redirect Avaya phones to different config files based upon source IP address

Hello everyone. I had a situation a while back where I needed to tell the 9630 phones in a remote office about a new call server. It was after-hours and I could not reach the network administrator responsible for the DHCP option strings for that site. I ended up creating a rewrite rule in Apache to redirect these phones to a different config file where I could overwrite the call server settings. Later I did the same thing for an international site where their date/time format was different from everyone else’s.

You can also use the GROUP setting in the phone to load specific config information, but as one reader discovered, the GROUP settings are not available to SIP phones! If you’re using Apache to host your config files, here is how to re-direct those phones to custom files.

If you are using defaults, your Apache config file is probably at /etc/httpd/conf/httpd.conf, and your document root for your web server is probably /var/www/html/

So open /etc/httpd/conf/httpd.conf in your favorite editor and find the section

<Directory "/var/www/html">
...buncha stuff
</Directory>

Inside the <Directory> </Directory> tags, add these lines:

    RewriteEngine On
    RewriteCond {0ed28e3470e974017c124b0897303dd14e34b5245564abb28916e7d48d9b07c0}{REMOTE_ADDR}= 10.101.
    RewriteRule 46xxsettings.txt SPAIN_46xxsettings.txt
    RewriteCond {0ed28e3470e974017c124b0897303dd14e34b5245564abb28916e7d48d9b07c0}{REMOTE_ADDR}= 10.139.
    RewriteRule 46xxsettings.txt OHIO_46xxsettings.txt

This will turn on the Apache rewrite engine and if the remote IP address matches the pattern 10.101, then any request for 46xxsettings.txt will be rewritten to SPAIN_46xxsettings.txt. Likewise, anything from 10.139 will get OHIO_46xxsettings.txt

As I look a this, the rewrite condition should probably start with a carrot ^ to try to match the beginning of the line, but it’s working for me so I don’t want to fiddle. But if I have a phone from 10.210.139.5, this rewrite will probably kick in because of that 10.139. within the IP address. Putting a carrot at the beginning should force it to only match addresses that begin with 10.139.

Unfortunately, you’ll need to restart Apache, but the phones won’t care if they miss a PUT.

[root@phonewebserver httpd]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[root@phonewebserver httpd]#

Mine takes less than a second. I don’t think anything noticed.

So then just create your SPAIN and OHIO settings files and the phone should get those. If it doesn’t seem to work, here are some troubleshooting steps.

Make sure the rewrite module is loading in Apache

Check the httpd.conf file and make sure there is a line to actually load the rewrite module. Mine is on line 190:

LoadModule rewrite_module modules/mod_rewrite.so

Tail the Apache access_log to confirm the IP addresses and GET requests from the phones

In a busy environment, it is not helpful to just tail the access log. But you can tail and grep at the same time! When troubleshooting, I just want to see the GET requests, so enter this command:

tail -f /var/log/httpd/access_log|grep --line-buffered GET

And that will follow the log but only show GET requests. You could also

tail -f /var/log/httpd/access_log|grep --line-buffered 10.139

And this will follow the log but only show activity from the 10.139 subnet

Temporarily enable the rewrite log so you can see what is getting rewritten

Just before the <Directory> tag in Apache, enable the rewrite log with

RewriteLog "/var/log/httpd/rewrite.log"
RewriteLogLevel 4
<Directory "/var/www/html">

You’ll need to restart Apache again. There should be enough information in that rewrite.log to figure out what is happening. It’s a lot of information, so be sure to set the RewriteLogLevel to 0 when you’re done troubleshooting.

I hope this helps! Please let me know how your testing is going. It would also be helpful to know if any of you get your GROUP settings to work over SIP. Thanks all!