Archive

Category Archives for "Daniels networking blog"

Python Script Pulling AWS IP Prefixes – Part 3

The two previous posts described what the script does and modules used as well as how the script leverages YAML.

This time, we will go through the function that generates the access-list name. The code for this is below:

def generate_acl_name(interface_name: str) -> str:
    """Generate unique ACL name to avoid conflicts with any existing ACLs
    by appending a random number to the outside interface name"""
    # Create a random number between 1 and 999
    random_number = random.randint(1, 999)
    acl_name = f"{interface_name}_{random_number}"
    return acl_name

The goal with this code is to generate a new access-list with a unique name. Note that the script doesn’t do any check if this access-list already exists which is something I will look into in an improved version of the script. I wanted to first start with something that works and take you through the process together with myself as I learn and improve on the existing code.

The function takes an interface_name which is a string. This is provided by the YAML data that we stored in the yaml_dict earlier. The function is then called like this:

acl_name = generate_acl_name(yaml_dict["outside_interface"])

The name is stored in the yaml_dict under the outside_interface mapping:

In [6]: yaml_dict  Continue reading

Python Script Pulling AWS IP Prefixes – Part 2

In the previous post I described some of the design considerations for this script and what modules I use. In this post, we will look at using YAML to collect data and use it in Python in the form of a dictionary. Why YAML? YAML is commonly used as a readable way of storing configuration data and there are modules for Python to read that data.

The YAML file is a very basic one containing these mappings:

---
outside_interface: outside
aws_service: s3
aws_region: eu-north-1
asa_ip: 192.168.255.241
...

The three dashes indicate the start of the file and the three dots indicate the end of the file. We have configured what service we are interested in (S3) and in what region (eu-north-1). The outside interface in our Cisco ASA is named outside.

The natural fit to work with mappings in Python is a dictionary. We need to get the data from the file named aws_prefix.yml into a dictionary. To do that, we will use the following code:

def get_yaml_data() -> dict:
    """Gets the interface name, ASA IP address AWS service, and region 
    from the YAML file and returns a dictionary"""
    try:
        with open("aws_prefix.yml")  Continue reading

Python Script Pulling AWS IP Prefixes – Part 1

I have been playing around with Python lately with the goal of building basic skills in it. I have found that to make good progress what works best for me is:

  • Have a project that I find interesting to work on
  • Spend a little time every day on the project

The project I decided on was to get the IP addresses that AWS uses for their services, build an access-list based on these prefixes, and then configure a Cisco ASA with that access-list. The final result looks like this:

Python AWS prefix getter

In a series of blog posts, I will cover how I built this script. Keep in mind that my focus was to get a script that works and then improve on it. I have some plans for getting an experienced Python coder to go through the code with me and to work on improvements. Stay tuned for that!

As with any coding project, you need to come up with some general guidelines on how to get data and what is good enough. These are some of the considerations I had:

  • I will get the configuration needed from a YAML file rather than a CLI (good enough for Continue reading

Route Replication the Easy Way

Easy Virtual Network (EVN) was a technology Cisco came up with back in the days to make it easier to implement VRFs without the pain of running VRF lite or the complexity of running a full MPLS + BGP network. It was actually a pretty cool technology but never became mainstream. However, as part of this technology, Cisco also made it easier to replicate, or in other words leak, routes between VRFs. You don’t need the rest of EVN to do this and this simplified way of replicating routes have kind of been forgotten by the industry. I thought I would share with you the ease of replicating routes with this feature even without BGP.

We have a straight forward topology like the one below:

The USERS switch is a L2 switch and all the L3 configuration is in the CORE router. We have implemented segmentation in the network so we have a USERS VRF and then we have a SERVICES VRF for shared services such as DNS and DHCP. Because these services are in a separate VRF, we will not have reachability to them from the USERS VRF. This lab will use the following IP addresses:

User – 10. Continue reading

11 Tips on Gaining Experience in Network Design

For people that want to pursue a career in network design, it can be tough getting the experience needed for such a role. How do you get design experience if your current role does not involve design? There are still many things you can do and I will give you tips on gaining that experience.

Network fundamentals – I always bring this up because it’s easy to overlook the need for network fundamentals. Being an Architect you still need to have technical chops and hopefully some operational experience as well. How can you design for something you are not familiar with? You can’t! You need to know OSPF, ISIS, BGP, etc. to understand when you should use each protocol. Spend a lot of time building these fundamentals before you move into design. How do you do that? Ivan Pepelnjak has training in this area. There is also the Computer Networking Problems and Solutions book by Russ White and Ethan Banks.

Books – There are several excellent books on network design. Some of them are geared towards network design certifications but they are great reads even if you are not pursuing any certification. One of my favourite books is The Art Continue reading

Networking Interviews – How to Ask Good Questions

I’m not sure if it’s just us in networking/IT, or people leading interviews in general (probably the latter), but we have a tendency to ask really bad questions in interviews. Often the questions revolve around factoids or things that need to be memorized. Some interviewers will even intentionally try to “trick” you. This is a really bad way of conducting an interview and will guaranteed lead to poor results. Instead of asking someone to quote an RFC, you should focus on asking open-ended questions and even guide the candidate if they are getting stuck on something. Why?

Reasoning – You want to see how people reason their way to answering a question. What is their thought process? Asking the administrative distance of BGP will just give you back a one-sentence answer or no answer at all. You can learn much more about someone’s skill level if you give them some clues and see if they can take the discussion forward. Are they comfortable asking you for input? Are they comfortable saying that they don’t know something?

Remove tension – Most, if not all, people are somewhat nervous when being interviewed. You want get an accurate representation of their skill so Continue reading

My Journey Towards the Cisco Certified DevNet Specialist – DevOps – By Nick Russo

On 19 January 2021, I took and passed the Implementing DevOps Solutions and Practices (DEVOPS) exam on my first attempt. This is the sixth DevNet exam I’ve passed … and probably the last! Much like my experience with enterprise and service provider automation, I have years of real-life experience solving a diverse set of business problems using DevOps skills. I’ve spoken about the topic on various podcasts and professional training courses many times. Even given that experience, the exam blueprint introduced me to new technologies such as Cisco AppDynamics and Prometheus, to name a few.

I found DEVOPS to be more difficult than the product-specific concentration exams like ENAUTO, SPAUTO, and SAUTO. Because the exam has very little Cisco-specific content (AppDynamics is about the extent of it), you’ll need extensive hands-on, detail-oriented experience with many third-party products. To name a few: Ansible, Terraform, Docker, Kubernetes, Prometheus, ELK, git/GitHub, Travis CI, Jenkins, and Drone. Like most Cisco specialties, it isn’t enough just to watch video training to learn the details of these technologies; labbing and self-learning are both essential to pass this challenging exam.

Unlike DEVASC, DEVCOR, ENAUTO, and SAUTO, I did not Continue reading

AAA Deep Dive on Cisco Devices

I’ve been working on some AAA configuration lately and I went through some of my older templates and realized that I didn’t want to simply use them without verifying first if I still believed that this was the best way of configuring AAA. I started by reading some of the official docs but quickly realized they were a bit shallow and lacked any real detail of some different scenarios such as what happens when the AAA server is not available. I then realized that there also is a lack of blogs that dive into this into any detail. Being curious, I thought I would lab it out as I have recently built an ISE lab.

The goal of this post is to start with a very simple AAA configuration, expand on it, verify each step what happens when the AAA server is available and when it is not. I will give you relevant debug outputs as well as my thoughts on different parameters in the configuration. Buckle up! because this is going to be a super deep dive!

We start out by applying a simple AAA configuration, where I have specified my ISE server, which is at 192.168.128. Continue reading

Finding Ways of Teaching

Some days ago I tweeted about that when you are trying to master a topic, you should both find different sources to learn from, as well as different mediums, such as reading, listening, watching videos, but also not to forget labbing. I also wrote that teaching someone else is a great way of learning and retaining information yourself. You might be familiar with the saying that “You remember 10% of what we read, 20% of what we hear, 30% of what we see, 80% of what we personally experience, and 95% of what we teach others”. How truthful this statement is, is up for debate, but I think we can all agree that you will recall more of what you have learned if you are teaching the topic to someone, as opposed to just reading about something.

How do you find a place to teach, though?

Thankfully, there are a lot of options today to teach, even some that may not seem obvious at first. Let’s go through a few of them.

Blogging – As you’re reading this blog, hopefully you are learning something. It may not seem like teaching, considering that it’s not a realtime event, but it is Continue reading

Getting DevNet Associate (200-901) Certified

Earlier this week I got DevNet Associate certified, using the online testing offering. The TL DR of this post is going to be this:

I have no affiliation with Pluralsight or anyone else, by the way. It’s just that it happens that Nick’s content is there. This may sound like a very simple plan but it has worked for me and many before me. If you follow his plan, you will be prepared to take the test and have an excellent chance of passing.

Now, for the longer version of this post. As with any certification, you need to check the blueprint and assess your current skill level pertaining to those topics. The DevNet Associate has these major areas of topics:

  • Software development and design (15%)
  • Understanding and using APIs (20%)
  • Cisco platforms and development (15%)
  • Application deployment and security (15%)
  • Infrastructure and automation (20%)
  • Network fundamentals (15%)

With my background as a networking expert, this means that I don’t need to spend much time on network fundamentals. For the rest of the blueprint, Continue reading

No Rush

Intro

We often treat our careers like it’s a race. With only a winner. We setup goals where we want to get a degree by a certain age. Get that certification at another age. Get that job at a certain age and we judge our success by if we make more than say 100k per year. Because that’s what we’ve been told.

However, building a successful career in IT is nothing like that.

Stress

I’ve been there myself and felt the stress. I started my university studies when I was 22. I felt old at the time when I was surrounded by people that were 18-19 years old. I know that people where I lived before my university studies had started asking questions of the kind if I wasn’t to become anything. To do something with my life. I needed a few years break from school before going to university studies , and it turns out that was a great decision. I was able to study in a matter I had never done before.

One of the goals I setup in my career was to become a CCIE by 30. I’m not sure why. It just seemed like getting it Continue reading

My Journey Towards the Cisco Certified DevNet Specialist – Service Provider by Nick Russo

On 14 October 2020, I took and passed the Automating Cisco Service Provider Solutions (SPAUTO) exam on my first attempt. This is the fifth DevNet exam I’ve passed and was a topic area in which I was already strong. Many people know me for my CCIE Service Provider Comprehensive Guide where I cover advanced SP technology. Others know me for my Pluralsight Ansible and Python network automation courses that implement an “infrastructure as code” solution to manage MPLS L3VPN route-targets. Suffice it to say that I’ve been doing SP stuff for a while.

Compared to the other concentration exams I’ve passed (ENAUTO and SAUTO), SPAUTO was about the same level of difficulty. The exam has a fair amount of carryover from DEVASC, DEVCOR, and ENAUTO, given the similarities of their blueprints, but is still quite heavy on SP products. Fortunately, there are only a few key products listed on the blueprint, making it narrower than SAUTO (which tested about 15 different APIs). Like ENAUTO, strong Python and network automation skills are important for this exam, and I’d strongly recommend having real-life SP design, implementation, and operations experience before attempting it.

Unlike DEVASC, DEVCOR, ENAUTO, and Continue reading

My Journey Towards the Cisco Certified DevNet Specialist – Security by Nick Russo

On 10 August 2020, I took and passed the Automating Cisco Security Solutions (SAUTO) exam on my first attempt. In February of the same year, I passed DEVASC, DEVCOR, and ENAUTO to earn both the CCDevA and CCDevP certifications. You might be wondering why I decided to take another concentration exam. I won’t use this blog to talk about myself too much, but know this: learning is a life-long journey that doesn’t end when you earn your degree, certification, or other victory trinket. I saw SAUTO as an opportunity to challenge myself by leaving my “comfort zone” … and trust me, it was very difficult.

One of the hardest aspects of SAUTO is that it encompasses 12 different APIs spread across an enormous collection of products covering the full spectrum of cyber defense. Learning any new API is difficult as you’ll have to familiarize yourself with new API documentations, authentication/authorization schemes, request/response formats, and various other product nuances. For that reason along, the scope of SAUTO when compared to ENAUTO makes it a formidable exam.

Network automation skills are less relevant in this exam than in DEVASC, DEVCOR, or ENAUTO, as they only account for 10% Continue reading

DevAsc – List Consisting of Dictonaries

I was going through Nick Russo’s course Getting Started with Software Development Using Cisco DevNet at Pluralsight and one thing he went through was interacting with the DNA Center API. Using a call to /intent/api/v1/network-device, DNA-C will return a JSON object consisting of an array of objects, or in Python speak, a list of dictionaries. This looks something like below, snipped for brevity:

{
    "response": [
        {
            "memorySize": "3735220224",
            "family": "Wireless Controller",
            "type": "Cisco 3504 Wireless LAN Controller",
            "macAddress": "50:61:bf:57:2f:00",
            "softwareType": "Cisco Controller",
            "softwareVersion": "8.8.111.0",
            "deviceSupportLevel": "Supported",
            "platformId": "AIR-CT3504-K9",
            "reachabilityFailureReason": "",
            "series": "Cisco 3500 Series Wireless LAN Controller",
            "serialNumber": "FCW2218M0B1",
            "inventoryStatusDetail": "<status><general code=\"SUCCESS\"/></status>",
            "hostname": "3504_WLC",
            "lastUpdateTime": 1596457941780,
            "errorDescription": null,
            "interfaceCount": "0",
            "lastUpdated": "2020-08-03 12:32:21",
            "lineCardCount": "0",
            "lineCardId": "",
            "locationName": null,
            "managementIpAddress": "10.10.20.51",
            "reachabilityStatus": "Reachable",
            "snmpContact": "",
            "snmpLocation": "",
            "tagCount": "0",
            "tunnelUdpPort": "16666",
            "waasDeviceMode": null,
            "apManagerInterfaceIp": "",
            "associatedWlcIp": "",
            "bootDateTime": "2020-03-12 16:08:21",
            "collectionStatus": "Managed",
            "errorCode": null,
            "roleSource": "AUTO",
            "upTime": "143 days, 20:24:58.00",
            "location": null,
            "role": "ACCESS",
            "collectionInterval": "Global Default",
            "instanceTenantId": "5e5a432575161200cc4ac95c",
            "instanceUuid": "72dc1f0a-e4da-4ec3-a055-822416894dd5",
            "id": "72dc1f0a-e4da-4ec3-a055-822416894dd5"
        },
        {
            "memorySize": "NA",
            "family": "Switches and Hubs",
            "type": "Cisco Catalyst 9300 Switch",
            "macAddress": "00:72:78:54:d1:00",
            "softwareType": "IOS-XE",
            "softwareVersion": "16.6.4a",
            "deviceSupportLevel": "Supported",
            "platformId": "C9300-48U",
            "reachabilityFailureReason": "",
             Continue reading

EIGRP Behavior with IP Unnumbered

Carl Zellers asked an excellent question on how EIGRP works when run over FlexVPN with IP unnumbered, considering that routers will not be on a common subnet. I thought this was a great question so I took some help from my great friend, the EIGRP guru, Peter Palúch.

First, let’s examine behavior when EIGRP is run on numbered interface. I have built a very simple lab consisting of three routers, R1, R2, and R3, where R1 and R3 are separated by R2. To demonstrate that EIGRP checks that incoming hellos are received on a common subnet, the following simple configurations were applied to R1 and R2:

R1:

interface GigabitEthernet1
 ip address 10.0.0.1 255.255.255.0
!
router eigrp LAB
 !
 address-family ipv4 unicast autonomous-system 64512
  !
  topology base
  exit-af-topology
  network 10.0.0.0 0.0.0.255
 exit-address-family

R2:

interface GigabitEthernet1
 ip address 10.0.1.1 255.255.255.0
!
router eigrp LAB
 !
 address-family ipv4 unicast autonomous-system 64512
  !
  topology base
  exit-af-topology
  network 10.0.1.0 0.0.0.255
 exit-address-family

This results in the well familiar messages on the console:

*Jul 15 08:53:20.966: %DUAL-6-NBRINFO: EIGRP-IPv4 64512: Neighbor 10.0.0.1 (GigabitEthernet1) is blocked: not  Continue reading

Happy 10-year Anniversary Lostintransit

Wow! I can’t believe it. I’ve been blogging for 10 years! Where did time go? July 16th 2010 is when I posted the first time to this blog. It was a post saying “I’m game” and I included Radia Perlman’s Algorhyme.

August 27th 2010, I wrote that I wanted to pass the CCIE lab within two years. Turns out I wasn’t too far from the truth. I passed late October 2012. Greg Ferro himself popped in to wish me good luck:

January 2011, I passed the written. I had a little different approach to many where I spent a considerate amount of time, around 200h if I remember correctly, to build a strong foundation before moving on to labbing. Today you would take the ENCOR exams, of course. But I still think this is a valid strategy.

It took me a little more than 6 months to get my first 5000 views. It’s good to remember that. Especially for those of you just starting out. This site has now had more than a million views but it took some time to get there. It doesn’t get as many views as you probably think, either.

I took my first stab at Continue reading

DevAsc – Python Script To Collect Show Commands Output

A colleague needed to connect to several Cisco devices, run some show commands, and save the output. I decided it would be good to practice my Python skills so I coded something together.

Why didn’t do you do this in Ansible, Nornir, or other tool of choice? Because the goal was to learn Python, not minimize amount of work to solve the task.

This work was highly inspired by others such as Debi, John, and wouldn’t be possible without the work from Kirk. Also thanks to Patrick, and Nick for giving me pointers on the code.

From a high level, the script will perform the following tasks:

  • Read commands from a text file “commands.txt”
  • Read devices from a text file “devices.txt”
  • Ask the user for credentials
  • Log in to the devices
  • Perform show commands
  • Save the output to a text file per device

In order to perform the tasks, the script relies on several modules:

Colorama – Used to color code terminal output
Netmiko – Used to setup SSH connection to device and parse the output
Datetime – Used to create a timestamp
Getpass – To get password from user without displaying it to the Continue reading

DevAsc – Python Classes

Python classes are very useful when you need to create objects with the same characteristics. This is often referred to as Object Oriented Programming (OOP). Not having much of a programming background, I found classes to be a bit confusing, and I wasn’t fully understanding the use of __init__ and self. Thanks to the Twitter community, my friend Peter Palúch , and the videos of Cory Schafer, I know feel I have a better understanding, and wanted to share my findings, from a networking person’s perspective.

First, let’s look at why classes are needed in the first case. Let’s say that we want to keep track of our network devices. The attributes we are interested in are:

  • Hostname
  • Vendor
  • Device type
  • Model
  • Loopback

We can of course create this information manually, without classes, like this:

daniel@devasc:~/DevAsc$ python3
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> device1_hostname = "r1"
>>> device1_vendor = "Cisco"
>>> device1_type = "router"
>>> device1_model = "ISR4331"
>>> device1_loopback = "192.0.2.1"
>>> device2_hostname = "sw1"
>>> device2_vendor = "Cisco"
>>> device2_type = "switch"
>>> device2_model =  Continue reading

DevAsc – Python Palindrome Challenge

Time for another Python challenge. This time it’s the palindrome challenge. What is a palindrome? A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward. Some examples are level, radar, stats.

The goal is to take a string the user inputs, reverse the string and see if it’s identical backward as forward. I will divide my code into two functions:

  • get_string
  • check_palindrome

The first function simply takes the string that is input. The second function checks if it’s a palindrome and prints the result.

As always, let’s first start with a docstring:

"""Program to check if string is a palindrome"""

Then we create a function to get the string from the user. This code should look familiar if you went through the divisors challenge.

def get_string():
    """Get a string from user to be used in function to check for palindrome"""
    # Get string from user with input() and return result 
    user_string = input("Please enter a string to check if it's a palindrome: ")
    return user_string

Now for the more interesting part, to check if a string is a palindrome. To do that, we need to reverse the string. How can we Continue reading

DevAsc – Python Divisors Challenge

As part of Nick Russo’s DevAsc study plan, he recommends doing a few Python challenges to check your existing knowledge of Python. One of these is the Divisors challenge. The goal of of this exercise is to take a number, such as 12, and then find all the divisors, that is the numbers that you can divide 12 with and have no remainder. This would 1, 2, 3, 4, 6, and finally 12 itself.

Now, solving this doesn’t take a lot of code. However, I decided that gold plating is allowed in my studies of code. That is, I would rather practice writing functions from the get go rather than just quickly moving from exercises.

To find divisors, we need a little basic math. We can use the Modulo operation to find the reminder of a division. For example, if you divide 5 by 2, the remainder is 1. We call this 5 modulo 2. Because there is a remainder of 1, this means that 2 is not a divisor for 5. If we however use 9 and 3 instead, with 9 modulo 3, the remainder is 0. This means that 3 is a divisor for 9. We then Continue reading