Networking and Unix

IP Subnet Lookup using TemplateFx

 November 15th, 2013Nov 15th, 2013      

Let’s think of a scenario where you have a list of IP subnets and within a TemplateFx template you want to find out which subnet a certain IP address is within. There are numerous IP calculators out there that will tell you the first and last IP address of a subnet, but few which allow you to find a matching subnet.

In this scenario we have some regional pop sites that are serving customers around the country. Each of these pop sites has a pool of IP addresses that are being used by customers. By creating a simple template using JavaScript we can provide a simple lookup functionality – this could be used within a template to provision different configuration depending on a customer’s pop location:

  var db = {
    "":" - UKPOP-BE-001",
    "":" - UKPOP-WG-001",
    "":" - UKPOP-OW-001",
    "":" - UKPOP-NW-001",
    "":" - UKPOP-GD-001",
    "":" - UKPOP-GD-002"
  function lookup (ip) {
    for (var k in db) {
      if (insubnet(k, ip)) {
        return db[k];
    return null;

<<IP>> is in <?= lookup("<<IP>>") ?>

We can then provide a list of IP addresses within our source data as follows:


Once you click on “Generate Output” you will be presented with the following: is in - UKPOP-GD-002 is in - UKPOP-OW-001 is in - UKPOP-BE-001

This is just one of the many powerful features of TemplateFx – for more information please see the TemplateFx page.

General TemplateFx

IP QoS Lookup Table

 November 6th, 2013Nov 6th, 2013      

Every now and again I need to lookup an IP ToS or DSCP value and I spend a good couple of minutes hunting for a table that contains all the different values. In some situations the ToS field might have an ECN (Explicit Congestion Notification) flag set which will alter the ToS value but keep the DSCP value unchanged. Instead of looking everytime, I decided to put together a table and keep it online for future reference.


General QoS

TemplateFx v2.32

 October 20th, 2013Oct 20th, 2013      

I am pleased to announce the release of Template v2.32 – a dynamic templating tool that enables you to write configuration templates once and deploy multiple times – never do the same thing twice.

Download links and instructions can be found on the TemplateFx page.

The changes in this release are summarised below:

  • Major performance improvement with syntax highlighting the template pane – from 1.5s to less than 50ms for a 500K file.
  • Added support for the “Console” tab to aid in template troubleshooting.
  • Introduced the “clog()” function to output messages to the console log from templates – use in combination with the “Console”.
  • Introduced the “insubnet()” function to verify if an IP address is within a subnet.
  • Introduced the “timestamp()” function to output a timestamp in templates.
  • Added support for “Clear All” on the popup menu to easily delete all contents.
  • Fixed a bug with single column data sets where we used a comma or tab within subsequent rows.
  • Changed the background colour of the output pane to differentiate it from the DataTemplate pane.
  • Removed DataTemplate version check otherwise it will break backwards compatibility in the future.
  • Added support for intelligent Redo and Undo buffers that group similar events together.
  • Fixed an issue where focus was being reset to the data pane when you switched back to the DataTemplate tab.
  • Added support for an “In Browser” button for HTML templates that launches the default browser with the output.
  • Implemented a workaround for Java on Mac OS where the tab titles were going wrong when you tried to rename them.
  • “Find and Replace” dialog automatically hides when it loses the focus.
  • Output tabs now use a title of “null” if title is omitted.
  • Added an “Options” item to the “File” menu to enable the toggling of persistent options.
  • Fixed an issue with the JProgressBar when generating output that caused it to pause too long at 0%.
  • Fixed an issue with an ever increasing build number as it was being regenerated on Jar extraction.
  • Added the current Java Runtime Environment version to the About screen.
  • Fixed a bug which permitted template fields to span across lines.
  • Added an improvement to highlight the header row in the data pane.
  • Enhancements to make it look more “Mac” like if run on a Mac based on Apple’s recommendations.
  • Various code cleanups to adhere to best practices and to remove legacy constructs.
  • Added support for Redo to go hand in hand with Undo.
General TemplateFx

The Long Road to IPv6

 September 22nd, 2013Sep 22nd, 2013      

There is a transition happening, albeit slowly, from IPv4 to IPv6, that is going to have an impact, but mostly on online gaming and other peer to peer services. Ever since the introduction of the Internet as we know it today, we have been using public IPv4 addresses to talk to people and to access content online. Unfortunately we have run out of IPv4 addresses as there weren’t enough to go around. An IPv4 address is a 32-bit number which is represented as 4 numbers separated by a dot (e.g. – this provides roughly 4.3 billion addresses. In comparison, an IPv6 address is a 128-bit number which is represented as 8 groups of 4 hexadecimal digits separated by a colon (e.g. 2001:0db8:85a3:0042:1000:8a2e:0370:7334) – this amounts to approximately 48,000 quadrillion addresses (4.8 x 10^28) for each of the seven billion people alive in 2011.


General IPv6 NAT

TemplateFx v2.31

 September 10th, 2013Sep 10th, 2013      

I am pleased to announce the release of version 2.31 of TemplateFx – a dynamic templating tool enabling you to write configuration templates once and deploy multiple times. Download links and instructions can be found on the TemplateFx page.

The changes in this release are summarised below:

  • Windows binary is now packed with UPX to reduce size by 66%.
  • Added support to filter the data using criteria when generating output.
  • Added support for an intelligent “Select Block” function on the right click menu to ease copying blocks based on indentation.
  • Added support for “Select Line” on the right click menu to ease copying lines.
  • Added support for “Select Paragraph” on the right click menu to ease copying paragraphs.
  • Redesigned the “Generate Output” dialog to be a single window.
  • Set a minimum width on all JButtons used in the same context.
  • Updated Find field to allow selection of previous entries.
  • Added “Options” button on Find dialogue to allow multiple options to be set (added support for “Match Case”).
  • Updated pattern match for template fields so they can’t contain just white space.
  • Fixed a NullPointerException when hitting <enter> on an empty Data pane.
  • Fixed an issue if there were empty lines at the beginning of the data pane.
  • Added red highlighting to “Template Fields” if they aren’t defined in the data pane.
General TemplateFx

1 - 4 5 6 7