ddib

Author Archives: ddib

Python – Kirk Byers Course Week 2 Part 3

This post will describe the exercises and solutions for week two of Kirk Byers Python for Network Engineers.

The next excercise is to work with output from “show ip bgp”:

III. You have the following four lines from 'show ip bgp':

entry1 = "*  1.0.192.0/18   157.130.10.233        0 701 38040 9737 i"
entry2 = "*  1.1.1.0/24     157.130.10.233        0 701 1299 15169 i"
entry3 = "*  1.1.42.0/24    157.130.10.233        0 701 9505 17408 2.1465 i"
entry4 = "*  1.0.192.0/19   157.130.10.233        0 701 6762 6762 6762 6762 38040 9737 i"

Note, in each case the AS_PATH starts with '701'.

Using split() and a list slice, how could you process each of these such that--for each entry, you return an ip_prefix and the AS_PATH (the ip_prefix should be a string; the AS_PATH should be a list):

Your output should look like this:

ip_prefix             as_path                                           
1.0.192.0/18          ['701', '38040', '9737']                          
1.1.1.0/24            ['701', '1299', '15169']                          
1.1.42.0/24           ['701', '9505', '17408', '2.1465']                
1.0.192.0/19          ['701', '6762', '6762', '6762', '6762', '38040', '9737']

Ideally, your  Continue reading

Python – Kirk Byers Course Week 2 Part 2

This post will describe the exercises and solutions for week two of Kirk Byers Python for Network Engineers.

The second exercise of week two is the following:

II. Create an IP address converter (dotted decimal to binary):

    A. Prompt a user for an IP address in dotted decimal format.

    B. Convert this IP address to binary and display the binary result on the screen (a binary string for each octet).

    Example output:
    first_octet    second_octet     third_octet    fourth_octet
    0b1010         0b1011000        0b1010         0b10011

We already have the knowledge to achieve this and the previous post went through all of the concepts needed to finish this task so I won’t bee too verbose with the code here.

The first part is to ask the user for an IP address using the “input()” function.

ip_add = input("\n\nPlease enter an IP address: ")

The next step is to split the IP address into octets using “split()”.

octets = ip_add.split(".")

After that each octet is converted into binary with the following code:

first_octet_bin = bin(int(octets[0]))
second_octet_bin = bin(int(octets[1]))
third_octet_bin = bin(int(octets[2]))
fourth_octet_bin = bin(int(octets[3]))

Like in the previous post we have to convert the strings to integers before we can use “bin()” on them. We Continue reading

Python – Kirk Byers Course Week 2 Part 1

This post will describe the exercises and solutions for week two of Kirk Byers Python for Network Engineers.

This is the first exercise:

I. Create a script that does the following

    A. Prompts the user to input an IP network.

        Notes:
        1. For simplicity the network is always assumed to be a /24 network

        2. The network can be entered in using one of the following three formats 10.88.17.0, 10.88.17., or 10.88.17

    B. Regardless of which of the three formats is used, store this IP network as a list in the following format ['10', '88', '17', '0'] i.e. a list with four octets (all strings), the last octet is always zero (a string).

        Hint: There is a way you can accomplish this using a list slice.

        Hint2: If you can't solve this question with a list slice, then try using the below if statement (note, we haven't discussed if/else conditionals yet; we will talk about them in the next class).

>>>> CODE <<<<
if len(octets) == 3:
    octets.append('0')
elif len(octets) == 4:
    octets[3] = '0'
>>>> END <<<<


    C. Print the IP network out to the screen.

    D. Print a  Continue reading

Python – Kirk Byers Course Week 1 Part 2

In the second part of assignments for the first week of Kirk Byers Python for Network Engineers class we will be working with IPv6 addresses.

We start with the following IPv6 address: FE80:0000:0000:0000:0101:A3EF:EE1E:1719.

The goal is then to split this address into individual parts. The delimiter in an IPv6 address is a colon. For an IPv4 address we would have used a dot instead. Python has a built-in function for splitting strings. To split the address we use this function and tell Python that a colon is our delimiter.

print("IPv6 address split:")
print(ipv6_split)
print(type(ipv6_split))

This means that we have turned our string into a list, consisting of eight parts of the IPv6 address.

daniel@daniel-iperf3:~/python/Week1$ python3 ipv6.py 
IPv6 address split:
['FE80', '0000', '0000', '0000', '0101', 'A3EF', 'EE1E', '1719']
<class 'list'>

To rejoin the address again the built-in function “join()” will be used. The syntax for this function is a bit awkward besides that it’s easy to use.

ipv6_new = ":".join(ipv6_split) 

print("IPv6 address rejoined:") 
print(ipv6_new) 
print(type(ipv6_new))

First we tell Python to put a colon between all the parts we are joining. The output then looks like this:

daniel@daniel-iperf3:~/python/Week1$ python3 ipv6.py 
IPv6 address rejoined:
FE80:0000:0000:0000:0101:A3EF:EE1E:1719
<class 'str'>

Note that the Continue reading

Opinion – Vendors Please Stop the Mud Slinging!

I’m not known for going on rants but lately I’ve been seeing a lot of stupid tweets from vendors that have really bothered me. So today I’ll give my best Tom Hollingsworth “networkingnerd” impression and tell you what’s on my mind. To give you an example what the vendor marketing teams are putting out there I give you this piece of work:

NSX marketing tweet
NSX marketing tweet

At first it seems a bit cute and funny. Oh look! It’s Star Wars! All nerds love Star Wars! I do too, just to be clear. What this kind of marketing does though is to dumb down the customers. It insults my intelligence as a Network Architect. Hardware still matters. There still is a physical world. Almost all projects in networking has some kind of existing network so almost all deployments are going to be brownfield to some extent. Please show me the organization that does not have an existing network and is going to deploy something like NSX or ACI for their first network. Please show me the organization that has no legacy systems or applications. Please show me the organization that develops and owns all of their applications and they are all nicely Continue reading

Python – Kirk Byers Course Week 1 Part 1

This post is the first one going through the Kirk Byers Python for Network Engineers class.

In the first class Kirk shows how to pipe data into Python by using the module fileinput with the following code(modified for Python3):

import fileinput

for line in fileinput.input():
	print(line.split("."))

I’ll show what this script outputs and then we’ll look at the code.

daniel@daniel-iperf3:~/python/Week1$ echo "192.168.1.1" | python3 stdin.py
['192', '168', '1', '1\n']

How did we get data into Python? We used “echo” to send data to stdin (standard input). The function “fileinput.input()” can take either files as arguments or if no files are listed it will read from stdin.

It’s possible to use “fileinput” to read from several files and print out the content. We used the following code:

import fileinput

for line in fileinput.input():

Then we print out the text:

daniel@daniel-iperf3:~/python/Week1$ python3 stdin.py 1.txt 2.txt 
1

2

3

4

5

6

7

8

9

10

daniel@daniel-iperf3:~/python/Week1$ cat 1.txt
1
2
3
4
5
daniel@daniel-iperf3:~/python/Week1$ cat 2.txt
6
7
8
9
10

Here we printed the contents of two files by sending them to “fileinput” We can see what Continue reading

Python – Learning Python with Kirk Byers Python for Network Engineers

As you have seen lately on the blog I’ve been fiddling around in Python. One of the best resources out there to learn Python for Network Engineers is the free e-mail course by Kirk Byers. Kirk is a CCIE emeritus with extensive knowledge and experience of Python. He offers both free and paid courses over at his site. Kirk is very active in the community and the guy behind Netmiko and the IOS driver in NAPALM. He’s also an active member of the Network to Code Slack group. I recommend that you check out Kirk’s stuff!

I plan to go through all of his exercices and write about them on my blog. That will help me in my learning and hopefully it can help you as well. Kirk publishes the answers to the exercises at Github but my plan is to be a bit more verbose and explain the code. I plan to write my posts here and also put up my answers on Github to get some exposure to using Git. My code will likely not be elegant, the most effective or good looking but hopefully we can learn from each other as I put these posts up. I Continue reading

Python – Argparse Part II

In my previous post on Argparse I had some issues with validating values and printing help output for values that are out of range. I got some great suggestions from my smart colleagues Mikkel Troest and Patrick Ogenstad who are far more advanced in their Python knowledge.

We started out with the following code in the last post:

#!/usr/bin/env python
# import Argparse
import argparse
# import sys
import sys
# create main function
def main():
    # create ArgumentParser object
    parser = argparse.ArgumentParser(description="Daniel's ping script v0.1")
    # add arguments
    parser.add_argument("-version", "--version", action="version", version="%(prog)s 0.1")
    parser.add_argument("-c", "--c" , help="Number of packets", action="store", type=int, choices=xrange(1, 1000), metavar=("(1-1000)"))
    parser.add_argument("-s", "--s" , help="packetsize in bytes", action="store", type=int, choices=xrange(56, 1500), metavar=("(56-1500)"))
    parser.add_argument("-t", "--t" , help="ttl for icmp packets", action="store", type=int, choices=xrange(1, 255), metavar=("(1-255)"))
    parser.add_argument("-w", "--w" , help="timeout in seconds", action="store", type=int, choices=xrange(1, 10), metavar=("(1-10)"))
    parser.add_argument("-ip", "--ip", help="ip address", action="store", required=True)
    # parse command-line arguments
    parser.parse_args()

if __name__ == "__main__" and len(sys.argv) < 2:
    print "use the -h flag for help on this script"
else:
    main()

First let’s clean up this a bit since the length of the lines are more than 80 characters Continue reading

Python – For Loops

I’m learning the basics of Python and these are my publically available notes for my reference. Hopefully they are useful for my readers as well.

The For loop in Python is used to iterate through different objects such as lists or dictionaries. The power of the For loop is that it can run as many times as needed and then stop without having to define the number of times it should run. It can also be used to run n number of times where we define n ourselves.

I’ll give some examples related to networking to make it more interesting. Let’s say that we want to create a lot of loopbacks so that we can advertise routes in BGP to play around with prefix-lists. We will create 10 loopbacks. This means that the For loop should run 10 times, we can use the range command for this. The iterator will start at 0 and have a stepping by 1 by default which means that our first loopback will be loopback0 and our first network will be 10.0.0.1/32.

for loopback in range(10):
    print "interface loopback{}".format(loopback)
    print "ip address 10.0.{}.1 255.255.255.255".format(loopback)

Continue reading

CCDE – The CCDE Mindset

This post was written to help CCDE candidates get into the right mindset but is very applicable to network architects and network engineers in general.

We humans tend to have a lot of bias. Sometimes it’s based on experience but often it’s based on how pure a technology is or a bad implementation of a protocol. Often we don’t reevaluate our opinion so if we had a STP incident in the past, STP becomes inherently bad for all future.

Preparing for the CCDE from a technology standpoint is relatively easy compared to getting into the right mindset and getting enough exposure to network designs. Don’t get me wrong, it’s a technically difficult exam but the number of candidates taking the exam that have the right knowledge level of technology are far higher than the number of people actually passing the exam. I have seen this time and time again.

Because we have this bias we immediately base our feeling and design based on our feelings or previous experience without taking the business requirements and technical constraints into consideration.Yes, maybe MPLS was the best answer to the question from a technical standpoint but maybe there was a constraint that only Continue reading

Python – Introduction to Argparse

I’m fiddling around a bit with Python. I’m planning to write a little script that pings a host or hosts and logs it to a file. Should be pretty basic but it’s good practice for me to take user input, read from a file, write to a file and so on. I wanted to support having arguments in the script to do things like a continuous ping or ping with x number of packets and then stop. To help the user pick the arguments I planned to do a little help text that printed out the arguments. Something like:

# Import sys
import sys
# Function for printing help text
def help_text():
    print "Daniel's awesome ping script."
    print "\n"
    print "-c    The number of packets that should be sent(integer)"
    print "-t    Timeout in seconds to wait for ICMP Echo Reply"
    print "-i    Run continuous ping"

# Check if user has input any options otherwise print help text
if len(sys.argv) < 2:
    help_text()

The problem with doing this manually is that you have to parse the arguments and build the logic yourself. For example the script should not allow someone to input both -c and -i since those arguments should be mutually Continue reading

General – Happy New Year!

Happy new year to all the readers of the blog!

I’ve been lacking the time to update the blog lately which I’m sorry for. Work is keeping me busy with some interesting projects. I hope to get a bit more frequent with the updates and maybe do smaller posts than my traditional larger ones.

For 2017 I’m going to focus on a few different areas to stay sharp and broaden my skillset a bit.

Wireless – I haven’t worked much with wireless and I’m going to upskill in this area to be able to understand the wireless requirements better when designing enterprise networks.

Datacenter – There are a lot of DC projects right now. Many companies are at the end of their Catalyst 6500 lifecycle and are looking for new solutions in the datacenter. Cisco’s Application Centric Infrastructure (ACI) is a hot topic right now. I’ll probably be working more on DC projects and ACI in 2017.

Python – In my role as a network architect I don’t really have the need to do a lot of programming but I want to keep the brain sharp and know the basics of Python. I can use it to automate boring things Continue reading

Career – The Value Of a Degree

I often get asked for career advice and the value of certifications. We live in a rapid pace world and people often look for the shortest path to success. They are trying to use the Dijkstra algorithm on their careers ?

This post is not a “People with degrees are better than others” post and is written from my perspective as a network architect. I do believe though that the skills I will describe here are applicable to all networking/IT jobs and will be even more relevant further down the road. Here is some of the value I see in a degree based on that you get a degree in a relevant discipline at a good university and that you have the willingness to learn.

Consume information – Working in IT means you need to consume a lot of information. For topics that you aren’t familiar with you need to be able to know where to look for information, what to do with the information and be able to draw a conclusion based on this information. IT is moving at a more rapid pace than ever and people that can’t consume a lot of information will struggle stay relevant in the Continue reading

CCDE – CCDE Practical Studies – Practice Lab 1 by Martin Duggan

One of the most challenging aspects when studying for the CCDE practical is to find scenarios to practice with. It’s difficult to find a scenario that has enough background information, requirements and constraints to emulate the experience of the real practical. Writing a full scale scenario is very time consuming and challenging. You have to find a good story, make it believable and challenging enough. The scenario must also be somewhat realistic.

I’m happy to announce that my friend Martin Duggan has released a new scenario for the CCDE practical. Martin and I studied for the CCDE together and passed on the same day. Martin is well known in the industry and holds a CCIE in RS and works as a network architect at AT&T. He is a Cisco Press author and has authored the CCIE RS Practice Labs Bundle. I have been a technical reviewer for this scenario and based on my experience this is one of the best quality scenarios I’ve seen.

These are some of the things that I think Martin has done really well to make this scenario as realistic as possible.

Background information – The scenario contains more background information than some of the other Continue reading

General – Why Are Certification Exams Not Higher Quality?

I was reading Ivan’s blog as I often do when I came across this post about why certifications suck.

The author Robert Graham had a sample question from the GIAC Penetration Tester (GPEN) exam. The question looked like this:

By default, which protocol do Linux systems use to transmit packets for tracing a network path?

a) UDP
b) TCP
c) ICMP
d) TTL
e) ECHO

Obviously being a networking expert I have my networking glasses on but I have to respectfully disagree with these gentlemen that I don’t think this is such a bad question at all. Trust me, I’ve seen much worse.

So traceroute works differently on different operating systems. If you work with penetration testing I would argue that you need to have a good understanding of different operating systems. You should know how they behave, what their characteristics are and how you can fingerprint them. The correct answer here is UDP. Linux systems and Cisco devices normally use UDP to send packets for a traceroute while Windows systems use ICMP when doing a traceroute. The answer is of course not TCP because TCP would require the three-way handshake and why would a device want to start a Continue reading

QoS – Quick Post on Low Latency Queuing

A friend was looking for some input on low latency queuing yesterday. I thought the exchange we had could be useful for others so I decided to write a quick post.

The query was where the rule about the priority queue being limited to 33% came from. The follow up question is how you handle dual priority queues.

This is one of those rules that are known as a best practice and doesn’t really get challenged. The rule is based on Cisco internal testing within technical marketing. Their testing showed that data applications suffered when the LLQ was assigned a to large portion of the available bandwidth. The background to this rule is that you have a converged network running voice, video and data. It is possibly to break this rule if you are delivering a pure voice or pure video transport where the other traffic in place is not business critical. Other applications are likely to suffer if the LLQ gets too big and if everything is priority then essentially nothing is priority. I have seen implementations using around 50-55% LLQ for VoIP circuits which is a reasonable amount.

How should dual LLQs be deployed? The rule still applies. Continue reading

General – The Future of Networking – Pete Lumbis

The next person I interviewed about the future of networking is my friend Pete Lumbis. Pete used to be the routing escalations TAC leader at Cisco and now he is working at Cumulus as a SE. Pete holds both a CCIE and a CCDE.

Daniel: The networking world is changing. What are the major changes coming up in the next few years that you think we will see?

Pete: Automation is the big thing these days. Either through APIs or abstraction tools like Ansible or Puppet. I think there will be more embracing of automation, but as a side effect I think we will have to start building networks that are more automation friendly by creating fewer exceptions and one-offs. This also touches on a larger point which is the need to build systems and networks that are less fragile. Automation is less scary when you have an architecture that can tolerate some level of failure.

Daniel: What are the major skills that people in networking need to learn to stay ahead of the curve?

Pete: Fundamentals don’t change. ARP is ARP. MAC addresses still have 48-bits. Understanding fundamentals will always be key. Beyond that it’s going to be about Continue reading

General – The Future of Networking – Russ White

Hello my friends,

Lately I have been thinking a lot about the future of networking and the career paths in this domain. As you probably know I like to guide and mentor people and with everything going on in the industry it can be confusing to find your way and to know what skills to work on to stay ahead of the curve.

I decided to reach out to some of my friends to ask them of their vision of the role of the future networking engineer and how to prepare for the changes that we are now seeing. First out is my friend Russ White who is also the co-author of the book Unintended Features that we wrote together.

Daniel: What are the major skills that people in networking need to learn to stay ahead of the curve?

Russ: Some of these have never changed — for instance, communication and abstraction. Some skills have been more important forever, such as people skills and project manage, but they never seem to really rise to the top in terms of actual demand. I don’t think this is going to change much; companies say they want people skills, and then recruit based Continue reading

General – Network Engineering vs Coding

Introduction

There has been a lot of talking about the future of the network engineer for the last couple of years. Many articles have declared that we MUST learn to program or we will be banished from the world by the programming overlords! I definitely do not agree with this bold statement but lately I have started to learn Python. Why?

Why Learn Programming?

As a network architect I probably won’t ever write a line of code or at least very rarely so. So why bother learning?

I didn’t learn a lot of programming back in my days of school. I fiddled around a bit with Basic, some Pascal and then at the university I tried some C# and C++. I never felt connected with programming. I never felt that I was good at it. This surprised me a bit because I’ve always been good at learning things. I’m good at analyzing things, troubleshooting things and I have a strong background in maths and science in general. I had all the skills that good programmers normally have so why couldn’t I learn programming? Because I struggled I didn’t enjoy doing it so I never pushed through until it “clicked”.

Later Continue reading

Book – Unintended Features

Hi everyone,

I have some exciting news to share with you. I’ve been working on a book lately together with Russ White. It’s called Unintended Features – Thoughts on thinking and life as a network engineer. The book is partly based on blog post we have written in the past but also some unique content for the book. The outline of the book is as follows:

So you’ve decided you want to be a network engineer—or you’re already you a network engineer, and you want to be a better engineer, to rise to the top, to be among the best, to… Well, you get the idea. The question is, how do you get from where you are now to where you want to be? This short volume is designed to answer just that question.

This book tries to teach concepts not found in other writings such as thinking more about architecture and seeing patterns in technology and how to stay current in the networking industry. With the rapid pace of the networking industry it seems like we are sipping from the fire hose. How can we prevent this? Isn’t every new technology pretty much an old one with some new Continue reading