FreePBX settings for Draytel

Its taken a few hours work, but the below settings seem to work for incoming calls on Draytel to my Asterisk installation




These are loosely based on the settings described here:

Changing Network Interface on Centos

Now I’ve got wired connectivity into the basement, I dont need to have the uplink between the comms pc and the router on Wifi. The interface shown here as wlp3s0 will now be called eth1


This article basically describes the process


However, I’ll also need to change the /etc/sysconfig/network-scripts/ifcfg-eth1 file to contain the IP address previously assigned to wlp3s0, and run

ip link set dev wlp3s0 down
service network restart

This is to ensure that incoming requests from the internet hit the new adapter, not the old one, which may be reassigned to something else later on.

Next, I’ll need to check firewalld has kept up with the changes

firewall-cmd --get-active-zones

and check eth1 is in the external zone

External IP Reporting from CENTOS

Much like my PHP example of external IP reporting, the following script performs exactly the same task, but in Centos. This combined with creating a custom system service should provide dynamic IP resolution even if the PC reboots.

while [ $i == 1 ]
datestring=$(date –utc +%FT%TZ)
oldip=$(cat $ipdir$ipfile)
echo “Getting IP… ”
#if [ 1 -ne 1 ]
if [ $oldip != $wanip ]
echo My IP has changed! Saving change to file…
echo $wanip > $ipdir$ipfile
echo Connecting to FTP server…
lftp -u FTP_USERNAME,FTP_PASSWORD FTP_SITE -e ” lcd $ipdir; put $i$
echo Writing log…
echo “$datestring IP changed to $wanip” >> $logfile
echo Log written!
echo My IP is the same!
echo Sleeping for 5 mins…
sleep 300s

Automatic External IP Reporting from Windows

Its become very annoying, since most dynamic hostname services have changed to paid-for services, to keep loosing connectivity with satellite sites because their IP has changed.

As a work-around, I’ve set my windows web server (which already runs PHP) to report back to my paid hosting provider, what its current IP is. This linked with cron jobs with the hosting provider, should be able to update my satellite site IPs in DNS without any human intervention.

The following PHP resolves the IP from a text to browser IP recognition site (similar to googling “what is my IP”, but here is returned as a plain text file), checks for changes since the last time the script was run, then uploads the new IP to the root DNS site. It checks every 5 minutes, but this delay can be adjusted, and also reports what it has been doing to a local log file.

$i = 1;
while($i == 1){
$datestring = date('c');
$ipfile = "c:\manage\myip.txt";
$logfile = "c:\manage\myiplog.txt";
$remotefile = "myip.txt";
$oldip = file_get_contents($ipfile);
echo "Getting IP... \n";
$externalContent = file_get_contents('INSERT IP RESOLVER HERE');
preg_match('/Current IP Address: \[?([:.0-9a-fA-F]+)\]?/', $externalContent, $m);
if($oldip != $m[1]){
echo "My IP has changed! Saving Change to file... \n";
file_put_contents($ipfile, $m[1]);
echo "Connecting to FTP server... \n";
$conn_id = ftp_connect("MY FTP SERVER");
echo "Authenticating... \n";
$login_result = ftp_login($conn_id, "FTP USERNAME", "FTP PASSWORD");
echo "Uploading... \n";
if (ftp_put($conn_id, $remotefile, $ipfile, FTP_ASCII)) {
echo "Successfully Uploaded File... \n";
$ftpresult = " upload OK";
echo "Writing Log... ";
$longstring = $datestring." IP changed to ".$m[1].$ftpresult;
file_put_contents($logfile, $longstring, FILE_APPEND | LOCK_EX);
} else {
echo"My IP is the same! \nSleeping for 5 mins... \n";

Setting up dhcpd for TFTP

I need to tell my TFTP enabled clients about the TFTP server hosted on another site. Without this I wont be able to continue working on my SIP on Cisco handsets project (Not yet mentioned on here).

TFTPD can do this, although you have to declare the variable in the config file before you can reference it – unlike the standard options which do not require declaring. The following is at the top of the config file.


option tftp150 code 150 = array of ip-address; 
option tftp66 code 66 = array of ip-address;

Unlike the declarations used in some examples, I’m using an array, in the hope that my devices can automatically work-around a failure of the VPN. The next extract is from within the subnet declaration.


option tftp150, [other site fqdn];

option tftp66, [other site fqdn];

Station Departure Board for the office

So, at about 5:15 each day, about everyone who works in our office start looking for the departures from the local TFL overground station. Via the National Rail website, this information can be found, although gives you a lot of options which wont be relevant to the regular commutor

National Rail Live Departures on a PC screen. No, I don’t want to know about traintracker, or register for an account!

Via national rail, the actual information occupies probably less than half of the screen space. If you are viewing this on a mobile device its very small. If you are viewing this on any device, and suspect you are about to miss a train this is also very inconvenient!


National Rail Live Departures on an emulated mobile screen

When you arrive at the train station however, they seem to have got (usually) the array of information about right. Although our station has a low canopy and little platform space (for the patronage), you aren’t offered endless options on-screen for services you don’t want. Therefore:

Why cant we have a simple display in the office?

Maybe… Something like this?

Ok, so I’ve answered this question for myself already, with the live departure board I setup for my old house, however the application remains the same – How can I get live departure information displayed in a custom format?

Fortunately National Rail have already thought about this. They provide a number of ways to access their live running information, in an API nobody knows much about. Railalefan has created a class to attempt to simplify calls to the API, this is extremely useful. However doesn’t solve the issue of field keys changing dynamically, without any documentation. This makes any UI written look extremely buggy over time, with most errors occurring either at the beginning or end of the day (When there are less trains around), or when there are delays and cancellations (When additional fields appear, or disappear).

The process of identifying which fields appear and disappear has therefore been mainly trial and error, most of which was done whilst making the predecessor system to this one, which was used at home.

Adding in TFL Updates

Unfortunately, for whatever political reason (probably) the live running information at Gunnersbury seems to be a little unreliable

Next Upminster service in 1128 minutes?
Disruption between XX and YY?

So, for our departure board in the office to be any use, it also needs to show TFL’s live running information to stand any chance of showing line suspensions when DARWIN hasn’t been updated.

TFL provide a variety of information via their API, which is a little better documented here. The Line Status response which we are interested in is provided in XML, and include some useful fields which can be used in conjunction with CSS to change how the page is displayed based upon how tube lines are performing.

So the final part is to compile each of the different displays into divs, then use the  zIndex property combined with some javascript to switch round the displays based on a timed rotation.  Trying to get javascript to pause for a while, in the same way PHP can has proven to be a bit of a pain. Basically, the function doesn’t exist, so there are ample work-arounds, but the closest I found of any use was “setTimeout(Action, Delay (ms))”.



Menus but no pictures or sound on Virgin Media box

I’ve never had the joy of using a Virgin Media home setup before, but was surprised when setting up a Virgin Media TIVO box with a new TV.

Traditionally if there was a fault with your video cable, the TV simply wouldn’t show any picture, as below, however HDMI with HDCP makes this a little more complicated.


HDMI is a bi-directional communication protocol, and any device using High Definition Content Protection (HDCP) is required to check the suitability of the device at the far end before sending protected material. Under normal circumstances something similar to the following happens


Thus, with your TIVO box and TV you get pictures. Unfortunately, in my case the HDMI cable was faulty. I was a little reluctant to believe initially is was the cable which was faulty, as I could see and open menus on-screen from the TIVO box, however couldn’t get any actual television channels to play. Something similar to this was happening.


After reading online about other Virgin Media customers who have had similar problems, I was intrigued by people posting suggestions such as

“Turn your TV on first, then the TIVO box, and it works fine”


“I use a SCART lead, and it works now. Although its annoying I cant see HD pictures”

So after a little while trying to find a ‘sweet spot’ for the cable to sit, the TV flickered a little, then Eastenders came on. A little bemused, I wonder how many other people are struggling with the same issue?