Cisco-TCL first steps… Hello world

70px-Tcl-powered.svgFor some time Cisco offers TCL shell on their equipment. This is awesome, because sometimes you need a single command to retrieve information whereas IOS demands you to enter one or more commands.

But before we get lots in possibilities and impossibilities. Lets create a tiny script to say “Hello world”.   First we will write the script afterwards I explain the tricky parts.

R1#tclsh
R1(tcl)#puts [ open "nvram:hworld.tcl" w+ ] {
+>(tcl)#puts "Hello world..."
+>(tcl)#}
R1(tcl)#exit

First I run trough the commands;

Puts is short for PUT String. Output is ‘echoed’ on screen (stdout) unless defined otherwise. Definition is done in brackets. In the first instance a file is opened to which the output is written.

Open opens a file, w+ describes that a file is opened for write AND if no file of that name is found one must be created.

Script can executed by;

R1#tclsh nvram:hworld.tcl
Hello world...

R1#

If you want to call TCL script more like a IOS command you can create an alias.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#alias exec hello tclsh nvram:hworld.tcl
R1(config)#exit
R1#

An alias name “hello” is created. Once executed you will get the following result.

R1#hello
Hello world...

R1#

Okay, writing a tiny tclshell “hello world” script is no rocket-science.
Once you explore more and more you’ll get the hang of it and can do really fun stuff.

Posted in cisco | Tagged , | Leave a comment

Anki – Spaced Repetition

While studying, I am seeking for ways to study more efficient. In the beginning I stumbled upon a method called ‘spaced repetition’. This method is wildly popular in the U.S. Unfortunately when I attended high school my home country this method was not used. I guess when if I knew about this method earlier in life my career would have looked much different.

Since I am network professional, a computer is never far away. The computer hardware uses Windows, Ubuntu and Android as an OS.  I want the study progress to be available on all hardware. First I used different software, unfortunately the variety of  OS’s proved difficult.

Recently I found a tool automate spaced repetition and which enabled syncing between the computers and tablets. The tool is called Anki. ( https://apps.ankiweb.net/ ). At this point I have only checked syncing between Ubuntu and Android.

It works like a charm.

Posted in Lifehacking

First Hop Redundancy Protocol – HSRP

Cisco proprietary HSRP protocol is a protocol for enabling a first hop fault tolerant router. Enabling your default gateway ip address to ‘live’ on more than one router. Back in the old days you had one router to exit a lan.
Once the router died or was out of service due to maintenance hosts in the LAN were not able to communicate out of the lan.

Cisco created a protocol which enabled two (or more) routers to listen to one ip address (layer 3) and one mac-address (layer 2).
Both layer 2 and 3 addresses have used in the redundancy setup otherwise you have to wait for arp entries to time-out.

While configuring you need to set the standby priority. Priority can be set between 0 and 255. Default value is 100.
When the HSRP Active interface has become unavailable, priority is decremented by 10. Choose you HSRP priorities smart.

In the topologies I have seen, the priorities chosen were 100 and 105 or 95 and 100. In all cases that were two router set-ups.
Of course you can be creative and create a three router set-up.

Communication between participating router is done through multicast ip’s HSRP v1 224.0.0.2:1985(UDP) and HSRP v2 224.0.0.102:1985(UDP).

Important use “preemt” : to get the router with the highest priority to recover to Active after an outage.

 R1#sh run int e1/1
 !
 interface Ethernet1/1
 description lan-1
 ip address 172.16.10.2 255.255.255.0
 ip helper-address 172.16.99.254
 standby 1 ip 172.16.10.1
 standby 1 priority 105
 standby 1 preempt
 R2#sh run int e1/1
 !
 interface Ethernet1/1
 description lan-1
 ip address 172.16.10.3 255.255.255.0
 ip helper-address 172.16.99.254
 standby 2 ip 172.16.10.1
 standby 2 priority 100
 standby 2 preempt

The configuration of the DHCP server is not very complicated.

 ip dhcp excluded-address 172.16.10.1 172.16.10.10
 ip dhcp excluded-address 172.16.10.254
 !
 ip dhcp pool lan-1
  network 172.16.10.0 255.255.255.0
  default-router 172.16.10.1 
 !

Be sure to set the default gateway to the HSRP address, otherwise you have a very neat solution which does not give you the fail save you need.

Posted in CCNP

Access-list mask or wildcard

G’day all, today I was messing around with access-list.  And after getting my head around the weird subnets of rfc1918. Weird as in an A-class (/8) is reserved in A-space, B-class (/16) in reserved in C-space, and for the B-space has a /12 is reserved. Nothing is standard in the world of standards.

But that on a side-note. The whole rfc1918 got me distracted. So when I started creating the access-list, I mistakenly used the subnet mask instead of the wildcard.

First I made the access-list using subnet masks.

ISP1-R1(config)#ip access-list extended rfc1918-wrong
ISP1-R1(config-ext-nacl)#permit ip 10.0.0.0 255.0.0.0 any
ISP1-R1(config-ext-nacl)#permit ip 172.16.0.0 255.240.0.0 any
ISP1-R1(config-ext-nacl)#permit ip 192.168.0.0 255.255.255.0 any
ISP1-R1(config-ext-nacl)#deny ip any any
ISP1-R1(config-ext-nacl)#exit

Next I made the access-list using wild cards.

ISP1-R1(config)#ip access-list ex rfc1918-right
ISP1-R1(config-ext-nacl)#permit ip 10.0.0.0 0.255.255.255 any
ISP1-R1(config-ext-nacl)#permit ip 172.16.0.0 0.15.255.255 any
ISP1-R1(config-ext-nacl)#permit ip 192.168.0.0 0.0.255.255 any
ISP1-R1(config-ext-nacl)#deny ip any any

I check the things that I do in a network. I think its a good habit and somebodies health might depend on it.

ISP1-R1#sh access-lists
Extended IP access list rfc1918-wrong
10 permit ip 0.0.0.0 255.0.0.0 any
20 permit ip 0.0.0.0 255.240.0.0 any
30 permit ip 0.0.0.0 255.255.255.0 any
40 deny ip any any
Extended IP access list rfc1918-right
10 permit ip 10.0.0.0 0.255.255.255 any
20 permit ip 172.16.0.0 0.15.255.255 any
30 permit ip 192.168.0.0 0.0.255.255 any
40 deny ip any any

You see that the access-list made using subnet mask are completely borked.

The moral of the story is as follows;

  • always check what you have configured.
  • Use subnet mask to assign ip addresses to interfaces ans wildcards for accesslists.

 

Posted in CCNP | Tagged , , , ,

Juniper filters

In the networking world a multitude of vendors are present. And each of them have their magnificent features  but also their quirks. And one of the quirks, for the network vendors in general, is that terminology is not uniform.

Where Cisco likes to talk about Access-Control List or ACL for short Juniper likes to talk about filters. Juniper filters are awesome. Juniper likes to arrange information a tree-like structure. This enables Juniper for future changes in software approach.

Cisco has standard access-list, the down-side; modification can not be done. Deletion of one ACE is not possible.  The entire ACL has to be removed.

A slight improvement are extended access-lists. Every ACE has a number associated with it. And using some ip access-list resequence magic you can make some room to insert ACE’s.

This hassle is not known to Juniper engineers.

Simply create a access-list ehm …. filter

set firewall family inet filter generic-filter term discard then discard

This filter simply, forwards every packet to the great bit-bucket in the sky.

If you want to allow traffic from you lan towards webservers you add the following;

set firewall family inet filter generic-filter term web_lan from source-address 10.0.0.0/8
set firewall family inet filter generic-filter term web_lan from protocol tcp
set firewall family inet filter generic-filter term web_lan from destination-port 80
set firewall family inet filter generic-filter term web_lan then accept

Now you have two terms within the “generic-filter”

show configuration firewall
family inet {
    filter generic-filter {    
        term discard {
            then {
                discard;
            }
        }
        term web_lan {
            from {
                source-address {
                    10.0.0.0/8;   
                }
                protocol tcp;
                destination-port 80;
            }
            then accept;
        }
    }

If you leave it this way traffic to the webservers are discarded instead of allowed. This is where Juniper added some pretty awesome magic;just shuffle the term to a place where is fits best.

insert firewall family inet filter generic-filter term web_lan before term discard

Of course you need to address some more issues like established traffic etc.

But this is how Juniper addresses filters. And there are a whole lot more things you can manage with filters. You can create a variables , and when a condition is met the counter is raised by the value you like.  Variable is readable in the context of show firewall.

Today my first steps in Juniper filtering. An awesome experience.

Posted in Juniper

Be micro-ambitious

I love to read.  And one of my favorite topics is how information is stored in the brain.  How the brain learns.  What interval of learning is most effective an how goal setting works. 

A couple of books clearly state.  Do not set your goal too high.  But better set a lot of smaller goals.  In this way you can tick off many boxes whilst reaching your ultimate goal.  So be micro-ambitious instead of being ambitious.  

Posted in Lifehacking | Tagged , ,

Juniper SRX 110

This week I bought an Juniper SRX 110. This device will help me to get more acquainted with the Junos cli structure.  From a Cisco perspective this box is slightly wider than a Cisco 8xx series router. But maintaining 1U height.

IMG_20170706_010630This box will sit in the utilities closet when I find time to tinker around with this new toy.

 

 

Posted in Juniper | Tagged , ,