Know Network Packets – Crazyrouters

Author Archives: Know Network Packets – Crazyrouters

XML

XML – Extensible Markup Langauage

Its more suitable as data representation choice when software element need to communicate with each other.

Let review the XML basics with an example

anurudh@anurudh:~/newfolder$ cat ex1_xm.xml 
<device>
  <vendor>Cisco</vendor>
  <model>7600</model>
  <version>IOS 15.6</version>
</device>


Here <device>  is root , which is present in outermost XML tag of document , also referred as parent of the element <vendor>,<mode> and <version> , whereas <vendor>,<mode> and <version>  is known as children of the parent element <device>.

Namespace : Its part of XML Specification to differentiate between different XML blocks having same names

  let’s take an example  , if I have one more xml document as below

<device>
  <vendor>Cisco</vendor>
  <model>9600</model>
  <version>IOS 15.6</version>
</device>

Here , the only difference between earlier XML doc and this one  is one element i.e  model  number changed from 7600 to 9600 ,but parent element is same in both XML doc i.e <device> So there should be method to avoid conflict , there comes NAMESPACE which prevent element naming conflict

The namespace can be defined by an xmlns attribute in the start tag of an element.

The namespace declaration has the following syntax. xmlns:prefix=”URI”.

<root>
  <a:device xmlns:c="http://example.org/7600devices">
      <a:vendor>Cisco</a:vendor>
      <a:model>7600</a:model>
      <a:version>IOS 15. Continue reading

YAML

Yaml- YAML Ain’t markup langauge

The devices need a standard  protocol to communicate between each other , similarly there  is requirement of specific standard data format to communicate between application .YAML is one of the data format and is best known to be human friendly  means it’s easier to understand and write  for human compare to other well know data format such as JSON and XML

YAML document starts with 3 hyphen ‘—‘ at top ,it indicate beginning of YAML  document .

We can have mix data types in YAML, let’s see with an yaml example

ex1_ya.yaml

---
IOS: CISCO
JNOS: JUNIPER
CISCO:
  - Router
  - 7600
  - True
  - ['interface','ip address']

 First and second item i.e IOS: CISCO  and JNOS: JUNIPER is dictionary where ‘IOS’ and ‘JNOS’ is key and ‘CISCO’ and ‘JUNIPER’ is respective values

Third Item too is dictionary which comprises of list having different data type as below:

    ‘Router’ is string type.

     ‘7600’  is integer type

    ‘True’ is Boolean type

    Fourth item [‘interface’,’ip address’] is list  containing strings

Working with YAML using Python

The first and foremost thing to use YAML is to install PyYAML  , it’s  a YAML parser .

anurudh@anurudh:~/newfolder$  Continue reading

GIT – Version Control for Network Engineers

Is GIT any way related to Network Guys ?  What is GIT and how a network engineers can benefit from It. Most of the network engineer might have not came across GIT and even not used in their work environment,But as mentioned in  earlier posts that inclusion of DevOps in Networking has made network engineer to learn about automation and related technologies.

GIT is a distributed version control software that keeps track of every modification to the code. If any change or mistake is made , we can look back and compare with  earlier version of code and find for any mistake.

So how GIT can be useful for Network Engineers ? Network Engineer can use GIT to see the config,how and when it got changed and who made the change ,all the changes in a file  can be  tracked easily.

Git can be easily installed by following the steps provided in link https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

What is Git Version Control , Lets understand it in more simple way .. As per https://stackoverflow.com/questions/1408450/why-should-i-use-version-control/1408464#1408464

Have you ever:

  • Made a change to code, realized it was a mistake and wanted to revert back?
  • Lost code or had a backup that was too old?
  • Had Continue reading

VAGRANT FOR NETWORK ENGINEERS

Vagrant is an alien word for network engineers ,we as network engineer are more close to windows environment than Linux and always try to avoid linux . But time has changed now and with introduction of automation ,SDN ,Devops  in networks professional  life has made him to come out of windows environment and  try Linux for multiple reasons as below:

  • Mostly open source projects (open stack, Docker etc. )tools are based on Linux which we as network engineers have to use.
  • Network devices are now having Linux as underlying shell.
  • Most of the software which are directly or indirectly related to networks are using development environment as Linux.

So when ever we plan to work on linux environment , we just start downloading ubantu on our windows laptop with VM box ..install both and start working.

But there is an environment known as Vagrant that will not help you do all the Linux related task but also provide an environment that helps reduce setup time and allows you to virtualize configurations for various projects.We can set up  up a virtual network environment for testing purposes, or setting up a lab,  work with python , ansible ,devops tools and much more .

You Continue reading

Technology often thought of as SDN !!!

What is SDN ? SDN Definition varies  from Vendor to vendor ,commonly  the architecture of SDN defined by each vendor includes use of different technology to make  network automate, flexible, agile, dynamic ,scalable and most importantly cost effective.

I was going through Network automation article and found the different technology/trends which are some or other way often thought of  a SDN, or are important  part of SDN discussion .It’s good to go through it  :-

OpenFlow : Its low level protocol used to decouple the control plane from the data plane.

NFV Network function Virtualization: It refers to taking functions that have traditionally have been deployed as hardware ,instead deploy them as software.

Virtual Switching :They are software based  switches VDS(VMware Distributed switch ) ,AVS(cisco application virtual switch ),VSS(VMware Std. switch) etc.  that resides in hypervisor kernel providing local network connectivity b/w virtual  machines.

Network Virtualization: It refers to software-only overlay-based solution. A key characteristic of these solutions is that an overlay-based protocol such as Virtual eXtensible LAN (VxLAN) is used to build connectivity between hypervisor-based virtual switches.  This connectivity and tunneling approach provides Layer 2 adjacency between virtual machines that exist on different physical hosts independent of Continue reading

AWS Cloud – Part 1

Cloud networking has become buzz now days, Cloud networking is term use to define the group of network resources and services available which can be shared among various client and customers.This can be a private cloud or a public cloud .
The entire network is on cloud, which can be used to provide connectivity between application ,resources ,services deployed in the cloud.
There are multiple cloud provider in market today, some of the well known cloud provider are Amazon AWS,Microsoft  Azure,Google cloud Platform,IBM and multiple other vendors.
According to a recent Cloud Security Alliance (CSA) report ,Amazon Web Services is the most popular public cloud platform (41.5% ) .

Here we will go through the basics Amazon Virtual Private Cloud or VPC :Its virtually isolated networks ,they cannot communicate to each other ,to external world,internet ,to a VPN without explicitly granting that ability.we create VPC per account per region basis.Lets first understand about the few terms related to AWS  .

Amazon EC2 : :Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services (AWS) cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications Continue reading

Integration of GNS3 with VMWare Workstation

Integration Of GNS3 with VM

There has been multiple query regarding the integration of GNS3 with VMWare  , the  goal of this Post is to help to get the users know the easy steps to integrate GNS3 with VM  .  This will not only help the user to practice  CCNA,CCNP  lab in GNS  but also work with  with network automation scenarios.

Lets start with downloading the  GNS3 and corresponding GNS3 VM from GNS site.

Now you need to install VMWare Player ,  download the Vmware workstation Player 12 which i found to be compatible with GNS3 .The last item to download is VIX API , so in total we have downloaded 4 items as mentioned below with required links:

1)GNS3  èhttps://www.gns3.com/software 

2) GNS3 VM(.ovo file)èhttps://www.gns3.com/software 

3)Vmware workstation Player èhttps://filehippo.com/download_vmware-workstation-pro/68880/

4) VIX APi èhttps://www.vmware.com/support/developer/vix-api/

Once VM Player is downloaded , need to open the GNS3 VM .ovo  file and import it.

You can see GNS3 VM  on Workstation player page as below

If You want to tweek the VM Memory, cpu that can too be done .   

You can see the  IP address obtained Continue reading

Linux Must for Network Engineers !!!!

Linux once used to be strict NO for Network engineer, we as network engineer always preferred to be comfortable with windows. But time has changed now ,Linux is everywhere starting from mobile device ,computers, servers, Hypervisor, network switches . Most of the network devices operating system is based on Linux.

Few important reason for network engineers to Learns Linux :-

  • Mostly open source projects (open stack, Docker etc. )tools are based on Linux which we as network engineers have to use.
  • Network devices are now having Linux as underlying shell.
  • Most of the software which are directly or indirectly related to networks are using development environment as Linux.

So lets start with basics of Linux which can help us in our day to day task:-

 

Sudo 

  • “Super user do” command is used to gain root privilege.Dollar sign($) signifies user does not have root privilege.Hash sign(#) signifies user have root privilege.

Pwd

  • Print working directory.

ls

  • List content of directory.

Man  <Command>

  • List manual pages of command

Cd..

  • Change current directory to parent directory

cd

  • Back to home directory

Cd ../..

  • Back two directory

Cd..

  • Moves back to previous working directory

Mkdir

  • makes new director

Mkdir -p

First Python App-Read and Configure Cisco Devices -Test Enviornment GNS

It’s first version of python app where we have number of devices loopback0 ip address stored in device.txt file.Program will read the file ,fatch  loopback0 address and ssh into the respective device.

Program will  push the command “sh ip int brief”   in second step and  display output on screen .We have taken example of 3 devices to test the code.If there are more number of devices ,just need to add the loopback0 of additional device in device.txt file

Python code is written to  configure the loopback10 with IP addresss into each respective devices (mentioned in devices.txt file)  by reading the required device config file stored as respective device Loopback0.txt file.( if need to add more configuration ,just need to add the config in that respective device loopback0.txt file.)

I have used GNS environment  to test the python program.

topology

 

We have Used Netmiko Library to access cisco devices to get the required output and also configure the device

import_netmiko.PNG

Below are the functions defined in Python code :

  • Function get_devices_info() will read the file and get the device loopback0 detailsget_devices_info.PNG
  •  Function connect() will connect the devices using ssh (ConnectHandler used from library Netmiko)connect.PNG
  • Continue reading

Install Netmiko on Windows

Netmiko develop by kirk Byers is open source python library  based on Paramiko which simplifies SSH management to network devices .

Netmiko library  makes task to automate . Its very tedious to find out the procedure to install Netmiko in Windows enviornment.Let’s make out task simple :-

Steps:

  • Install Anaconda ( https://www.anaconda.com/download/)
  • From the Anaconda shell, run “conda install paramiko”.a
  • From the Anaconda shell, run “pip install scp”.b
  • Install git for windows (https://www.git-scm.com/downloads)
  • Clone Netmiko from Git Bash Window (https://github.com/ktbyers/netmiko).1
  • Change directory to netmiko.2
  • Run  python setup.py install from Git Bash Window3
  • Check on Python console to confirm the availabilty of paramiko and netmiko libraryresult

Its done.. Enjoy automating tasks !!!!

 

 

Regular Expression for Network Engineer Part-2

This post is continuation of the  Regular Expression for Network Engineer Part-1 , here  we  have a look for the different methods to find out the pattern in string.

Findall() – returns  list of all the  matches the pattern in a string  without overlapping

  • EXAMPLE

[code language = “Python”]

re.findall(pattern, string[, flags])

In [118]: ip
Out[118]: ‘10.10.1.10,29.10.1.10,10.10.1.20,192.168.1.0,172.16.10.1,10.10.10.121’

In [119]: out= re.findall(r'(10.10.10.\d+)’ ,ip)
In [120]: out
Out[120]: [‘10,10.10.1’, ‘10.10.10.121’]

#Above example help us to find out all the IP’s of subnet 10.10.10.0/24 from group of ip’s.

[/code]

Match()-return a match object when pattern is found at the beginning of string, if no pattern is found ,result in None.

  • EXAMPLE

[code language = “Python”]

In [189]: text
Out[189]: ‘Cisco IOS Software, 7200 Software (C7200-SPSERVICESK9-M), Version 12.2(33)SRE, RELEASE SOFTWARE (fc1)’

In [190]: out = re.match(r”Cisco”,text)
In [191]: out
Out[191]: <_sre.SRE_Match object; span=(0, 5), match=’Cisco’>
In [192]: out = re.match(r” Software”,text)
In [193]: out
In [194]: out = re.search(r” Software”,text)
In [195]: out
Out[195]: <_sre.SRE_Match object; span=(9, 18), Continue reading

Regular Expression for Network Engineer Part-1

A regular expression is set of pattern used to define certain amount of text. An powerful  tool in any scripting language to match any pattern.

Lets have a look , how regular expression can be used in Python to solves the problem. Module “re’ is imported in python to support regular expression .

<< import re >>

[  ] – its for specifying character class, individual char or range of character can be mached .

 

  • [123] will match any of the character ‘1’,’2′,’3′
  • [1-3] will match any of the character  ‘1’,’2′,’3′
  • [a-d] will match any of the character a,b,c,d
  • [a-z] will match lowercase
  • [A-Z] will match uppercase
  • [^6] will match any character except 6
  • [a-zA-Z0-9] will match any alphanumeric character
  • [^a-zA-Z0-9] will not match any alphanumeric character
  •  [a-zA-Z0-9] is equivalent to \w
  •  [^a-zA-Z0-9] is equivalent to \W
  • [0-9] is equivalent to \d
  • [^0-9] is equivalent to \D
  • [  \t\n\r\f\v] is equivalent to \s
  • [ ^ \t\n\r\f\v] is equivalent to \S

 

. – Period character ,use for matching any single charcter

  • EXAMPLE :

 

[code language=”python”]

In [225]: ip =’10.20.30.40′
In [226]: re.search(r”.”,ip)
Out[226]:&lt;_sre.SRE_Match object; span=(0, 1), match=’1’_>
In [227]: re.search(r”.”,ip).group(0)
Out[227]: ‘1’

Continue reading