Site icon David Ramsden

Should Network Engineers Also Be Programmers?

Short answer: Yes.

Maybe not a programmer in the sense that you need to be proficient in C++, .NET, assembler, know UML etc but having some general programming knowledge is very useful. In my opinion and experience the most important programming skill to have is a fairly in-depth knowledge of a scripting language. Be that shell, Perl, Powershell or even batch scripts. A week doesn’t go by where I don’t write a script to help me with my day to day tasks. Either to automate a process or format some logs or debug output I’ve collected.

Personally my scripting language of choice is either shell or Perl. Shell for easy repetitive tasks and Perl for formatting data or even creating configurations. Here’s a very simple example of a Perl script I wrote recently:

#!/usr/bin/perl -w
#

use strict;

my $po = 10;

for (my $int = 1; $int <= 29; $int++) {
        print "int po$po\n";
        print " switchport\n";
        print " switchport trunk encaps dot1q\n";
        print " switchport mode trunk\n";
        print " spanning-tree portfast disable\n";
        print " no shut\n";
        print "!\n";
        print "int rang gi1/1/$int, gi2/1/$int\n";
        print " switchport\n";
        print " switchport trunk encaps dot1q\n";
        print " switchport mode trunk\n";
        print " spanning-tree portfast disable\n";
        print " channel-group $po mode active\n";
        print " no shut\n";
        print "!\n";
        $po++;
}

What does this do, apart from make my life simpler? It generates a Cisco IOS config with 29 LACP port channels and configures the physical interfaces. Then it’s a case of running the script and copying/pasting the result in to the device. It also eliminates any human error. If you were having to create 29 port channels and configure 58 physical interfaces, the chances are you’ll make a mistake. Such as forgetting to configure the interface as a trunk, setting the wrong channel group ID on the interface or generally getting in to a bit of a mess.

I’m going to post a few other blogs containing some scripts I’ve recently used to help automate tasks. Time to sharpen your scripting skills!