Debugging network connectivity issues using telnet


Ah, the joys and simplicity of the humble telnet utility when it comes to debugging networking connectivity issues. Ever-present in any Unix-based operating system worth it’s salt but sorely missed in Windows systems post-XP (although it can be manually installed).

It has long since been superseded by it’s more secure cousin SSH but did you know that it can still be used to great effect to help determine the most likely reason you are unable to connect to another server in your network, or on the wider Internet.

What does success look like?

What many people don’t realise is that by specifying an additional parameter when using it, you can instruct the program to try to establish a connection on a specific port number (rather than the default port of 23). Take the following example which shows a successful connection to a fairly standard web server:

$ telnet 80
Connected to
Escape character is '^]'.

The key thing to note here is the presence of the message, “Connected to” and the fact the the session remains connected (i.e. you don’t get bumped back to the command prompt immediately). This is telling you that you have successfully established a valid connection to the required port on the server you’re interested in, which also (and most importantly) confirms that:

  1. You are not being blocked by a firewall.
  2. The service you’re trying to connect to is alive and well, listing on port 80.
  3. There are no software-based access rules preventing you from accessing the service on that port.

Help, it didn’t work!

In my experience, the above list represents the three most common reasons why things may not be working the way you hoped or expected. The neat thing about the telnet command is that it usually hints at this in the response it gives you, consistently so across the wide range of operating systems it runs on. The following table summarises the meaning of each such response from telnet:

Response Meaning
Trying… Firewall issue
Unable to connect to remote host Service not running
Connection closed by foreign host Software-based access rule

Keep reading for a more detailed explanation of each scenario:

1. You are blocked by a firewall

If the response to your telnet command is simply a “Trying x.x.x.x…” message (which eventually times out) then there is most likely a firewall rule (somewhere along the route to the remote server) blocking you:

$ telnet 80

Resolving this normally requires the services of a network engineer to grant the correct access through the firewall that is blocking you.

2. Nothing is running on the specified port

If the response to your telnet command ends swiftly with, “Unable to connect to remote host”, then you can be confident that you are not being blocked by a firewall but the server (you’ve managed to connect to) does not appear to have a process running that’s listening the port you specified:

$ telnet 80
telnet: connect to address Connection refused
telnet: Unable to connect to remote host
Resolving this normally requires the services of the server administrator (normally having them start the offending service for you).

3. You’re not allowed to talk to the service anyway

If your telnet command appears to connect successfully but immediately returns to the command prompt with a “Connection closed by foreign host” message, then you can be confident that you are not being blocked by a firewall, there is a valid service listening on the specified port but there is some form of software-specific access rule preventing you from communicating with that service:

$ telnet 80
Connected to
Escape character is '^]'.
Connection closed by foreign host.

Resolving this normally requires the services of the support team that manages the service you are trying to connect to (and having them add a rule allowing traffic from your network).


There are of course many other connectivity debugging tools (e.g. netcat) and indeed telnet is only suited to TCP-based protocols. However, the presence of this command on almost every operating system out there, along with the fact that it’s syntax and responses have not changed for so long, make it well suited for use in multi-platform environments and multi-layered networks.

Git basics for Subversion command-line users

For anyone that has used the Subversion version control system and wants to consider the switch to Git instead, here is a simple comparison of the more common tasks you’re likely to need to get started.

Please excuse the somewhat simplistic narrative in some items. This article is intended to get users accustomed to the basic Git commands without being too specific about the terminology of either world. Some items also show more than one Git command for the equivalent Subversion command (not uncommon in Git) and there are of course lots of shortcut ways to do some of the items (but for simplicity I’ve not covered them here).


1. Check out a repository
i.e. Fetch a copy of the files in a repository that I’ve never fetched before…

$ svn checkout <url>
$ git clone <url>


2. What files have I changed?
i.e. Which of my locally checked out files have changed since I last checked them out?

$ svn status
$ git status


3. What’s changed on the server?
i.e. Has someone else committed changes that I don’t yet have locally?

$ svn status -u
$ git fetch origin
$ git diff <branch> origin/<branch>


4. Show my changes
i.e. What are the changes I’ve made to my files?

$ svn diff
$ git diff


5. Fetch latest files
i.e. Fetch the very latest copy of my repository from the server

$ svn update
$ git pull origin <branch>


6. Commit my changes
i.e. Push all my changes back to the server

$ svn commit -m "A comment describing your changes"
$ git add <files>
$ git commit -m "A comment describing your changes"
$ git push origin <branch>


7. Change logs
i.e. View a list of my most recent changes

$ svn log
$ git log


Some other useful Git commands to note
Show all available branches

$ git branch -a

Show differences made in last commits

$ git log -p -<n>

Prune any local copies of branches that have been removed from master copy of repo

$ git remote prune origin

Free Mobile apps for LEGO fans

In my endless pursuit of different ways to enjoy LEGO products, I found the following free mobile apps in the Android app store (a.k.a. Google Play).

  • LEGO Creationary – Excellent series of build and guess games, created by the LEGO Group themselves. A bit heavyweight in terms of performance though.
  • myBrickset: LEGO Set Guide – Allows you to search for LEGO sets by number and create a catalog of the ones you own (or want to own).
  • LEGO Instructions – Lots of simple LEGO sets for younger children, complete with interactive step-by-step instructions.
  • LEGO Scans – Quickly peruse through over 4,000 LEGO sets by name or theme (but no instructions included though).
  • LEGO Minifig Collector – Search and browse through the full series of Minifigure collections. You can also tell the app which ones you have and it’ll then tell you which ones you’re missing (a potentially expensive feature).
  • Lego Mini Figure Identifier – Very clever app for helping you identify which minifigure in inside the package before you buys it. However, LEGO have made it a lot harder to use this app since Minifigure Series 5 onwards so bring a microscope with you if you intend to use this app.
There are loads more, some of which are just mobile games inspired by the LEGO brand and others are for much younger children or for specific LEGO sets.

Simple JSON parsing from Bash using Python

Have a Bash command you like to use a lot but need to parse some JSON data from another script? Here’s a quick inline Python command you might find helpful:

COUNT=`|python -c "import json; import sys;
  data=json.load(sys.stdin); print data['count']"`

Just substitute the name of your other shell script ( and the JSON index (count) as appropriate and you’re all set!

Oh, and of course, join the 2 preformatted lines above also – these are just split because by WordPress theme was truncating the single-line version.

Capturing Screen Shots on Mac OS X

I’ve had reason to capture rather a lot of screen shots in recent weeks and find the following Mac keyboard shortcuts very useful:

Shortcut Description
Command-Shift-3 Captures entire desktop (saved as PNG file on desktop)
Command-Ctrl-Shift-3 Copies entire desktop (saved to your paste buffer)
Command-Shift-4 Captures portion of desktop (saved as PNG file on desktop)
Command-Shift-4 + Spacebar Captures current window (saved as PNG file on desktop

There are lots of other variations on the above, which are described nicely  here.

How to reduce the size of a PDF file on a Mac

This one’s been bugging me for several weeks so finally got around to finding a proper solution. Basically, if someone sends you a PDF file with some photos in it, the chances are they didn’t think of reducing the picture quality (in the original document) before creating the PDF. As a result, the PDF file can end up being enormous, for no obvious reason to the reader.

While I managed to find out how to tackle the problem from inside the likes of Microsoft Word (better options in Office 2011), I am often without the original document, so what to do there (on a Mac)?

Well, as it happens, Mac Preview does have a way of doing this which I found out about here, and while it worked well for me (PDF files were mostly text with 2-3 pictures anyway), I have seen comments on the above article questioning the quality of the resulting file. Still, it may work for you too.

Food & Wine Tasting Evening

If you’re around the Waterford area on Wednesday, 14 December 2011, why not come along to the annual Food & Wine Tasting Evening at the Grand Hotel and sample a wide variety of beers, wine and local food – all for just €8.

This is a fundraiser in aid of two local schools (Gaelscoil Philib Barún and Holy Cross National School) and is sponsored by Hickson’s Centra, Tramore.

Remember: Grand Hotel, Tramore – Wednesday, 14 December 2011 – 7:30pm – 10pm – €8 per person

Hope to see you there.

Oracle and Sun’s third generation ZFS-based storage appliance

My first job in the IT sector was as Technical Support Engineer at Eurologic Systems, an Irish-owned data storage company, back in 1992. I can still recall working with a SEAGATE ST512N (a 5.25″ hard disk with a whopping 12MB capacity) and later on taking delivery of our very first 3.5″ 1GB hard disk (the now famous SEAGATE Barracuda).

However, I also recall some of the former Mentec/DEC guys lamenting about how they used to clean some 300MB DEC drives (one platter at a time) that took up most of the room (way before my time of course).

And so earlier this week, almost 20 years later, I read with interest about Oracle and Sun’s new third-generation storage appliance (based on their 128-bit ZFS file system) which once again takes the form of a huge cabinet-like disk drive that looks like it would easily take up an entire room (ok, the rooms are much bigger now too but you get the point).

Of course the 20-year time gap isn’t the only difference as the new Sun ZFS Storage 7420 Appliance boasts a staggering raw capacity of 1.15PB (that’s 1,234,799,616 MB) along with a host of other equally impressive numbers.

This enormous growth in storage capacity easily trumps Moore’s Law (CPU capacity doubles every 18 months) and is more like a three-fold increase every 12 months. Nice ….. very nice!

Over 915 million ways to combine just 6 LEGO bricks

It’s been a while since I’ve posted anything about my favourite toy, LEGO, so I thought I’d correct that with a crazy LEGO fact that stuck in my mind this weekend while watching National Geographic’s special MegaFactories: LEGO. So here it is:

The number of unique ways you can combine 6 classic (2×4 stud) LEGO bricks of the same colour is an incredible 915,103,765

That’s over 915 million different ways! So, if like me, you had to find out how they came up with this number, there’s a great story behind it here, along with some great numbers regarding combining of larger numbers of bricks.

Other great facts from this same programme were:

  • Over 50% of LEGO’s entire annual sales take place in the 2 months before Christmas each year
  • The LEGO factory in Billund, Denmark is technically the largest manufacturer of tyres in the world (great table quiz question!)
  • Worldwide, 7 LEGO products are sold every second