Archive for the ‘Routing’ Category


Posted: June 12, 2017 in BGP, Routing, SDN

BGP SDN enables central control over distributed routing.
This is based on routing protocol BGP and its ability to signal third party next hop using policy based routing.

We are using standard community to set next-hop which will define path to reach destination

This approach is kind of similar to Fibbing: OSPF and SDN (Hybrid model) where we set third party next hop with help of LSA5

All devices are running EBGP with each other via directly connected interface and controller will speak IBGP with every router
Controller can be any device which is capable of speaking BGP . I am using Cisco router and local-as feature to form IBGP with all routers as controller. In below diagram R5 is contoller


When we try to reach IP 100.100.100.l00 from IP we have 1 path available via path R4-R2-R1(marked with blue line)
R1 before

R2 before

R3 before

R4 before

Before Trace

Now with help of controller R5 I am sending prefix to all routers with community set to {4:2 2:3 3:1} and local preference set to 120
we can move the traffic from IP to IP via path R4-R2-R3-R1(marked with red line).

These communities are user defined and locally significant to the router mapped with next hop value
e.g if you want move packet from AS4 to AS2 set community 4:2 (this community is local to R4) in controller and next hop will be set to once R4 receives the update.
similarly to move packet frmo AS2 to AS3 set community 2:3 in controller and next hop will be set to once R4 receives the update.

R1 after

R2 after

R3 after

R4 after

After trace

Please check below link for more information


In VRF-lite situation multiple customers are connected to the same CE (each customer belongs to different vrf)
Now in this design wan circuit is moving from old PE to new PE.

During this bulk migration we need to replace static route pointing to OLD PE and with static route pointing to new PE for every customer

This migration related Pre and Post data such as vrf,CE wan ip,customer name,PE name etc. is recorded in excel sheet

With help of library xlrd , ciscoconfparse we can automate the script generation for static route which can be used during migration

we are reading all info for each VRF such as (VRF,OLD_WAN_IP,NEW_WAN_INT) by running FOR Loop on excel and storing it in dictionary

e.g Below 2 static routes needs to be replaced with new wan interface and new wan IP

ip route vrf ABC Serial1/0.10
ip route vrf ABC Serial1/0.10

Logic for the python code is
1. Get the static routes from router config for each vrf (one by one) using OLD wan IP (regular expression)
2. Take one IP route at a time and create list using split method so we will get 8 elements in list from 0-7
3. Pop the elements from the list till list contains only 6 elements from 0-5 (remove old interface and old wan ip)
4. Append new wan interface and then new wan PE IP to the list
5. Prepend no to the old static route and print it
6. Using join method on the list create new static route pointing to new wan IP and interface and print it

output is

no ip route vrf ABC Serial1/0.10
ip route vrf ABC FastEthernet0/1.10

no ip route vrf ABC Serial1/0.10
ip route vrf ABC FastEthernet0/1.10

python code for static route script for bulk migration.

import xlrd
from ciscoconfparse import CiscoConfParse

# provide config file path
routerconfig = CiscoConfParse(configfilepath)
wanip = c[‘OLD_WAN_IP’].split(“.”)

# result [192,168,1,1]
wanipregex = “\.”.join(wanip)
# result 192\.168\.1\.1
a = “^ip route vrf ” + c[‘VRF’] +”(.+?)” + wanipregex
# result ^ip route vrf ABC(.+?)192\.168\.1\.1

# running for loop over list of static routes for vrf ABC 2 routes in this case
for staticroute in routerconfig.find_objects(a):
line = staticroute.text

sroute = line.split(” “)
# result [ip, route, vrf, ABC,,, Serial1/0.10,]

while len(sroute) > 6:

# result [ip, route, vrf, ABC,,]

# result [ip, route, vrf, ABC,,,FastEthernet0/1.10,]
#result [ip, route, vrf, ABC,,, FastEthernet0/1.10,]
print “no ” + line
# result no ip route vrf ABC Serial1/0.10
print ” “.join(sroute)
# result ip route vrf ABC FastEthernet0/1.10
print “!”

Best route selection process

Posted: February 13, 2016 in Routing

How best route is selected when there are multiple route available for same destination

1. Longest prefix match (more specific route)

e.g. destination is and route available are nexthop Se1/0 nexthop Se1/1
in this case route via nexthop Se1/0 will be preferred
2. Compare AD value (lower AD value is better)

3. Compare the metric (lower metric is better)

if AD is same and route is learned via same routing protocol then
selection is done by comparing metric.
4. Compare routing protocol preference

(AD value is same and but route are learned via different routing protocol)
connected > static > BGP > eigrp > ospf > isis

e.g. First condition if we have route learned via ospf (110)and eigrp(90) (AD value is not modified for both protocol) route via eigrp will be selected

Second condition if we have route learned via ospf (90)and eigrp(90) (AD value is modified for ospf and its equal to eigrp AD value 90) still route via eigrp will be preferred based on predefined routing protocol preference

Third condition if we have route learned via ospf (89)and eigrp(90) (AD value is modified for ospf and its less than eigrp AD value) route via ospf will be selected based on lowest AD value