Pages

Showing posts with label routing. Show all posts
Showing posts with label routing. Show all posts

2/21/2020

Multiple mutual redistribution OSPF<>BGP config

Below are router configuration fragments for redistribution between OSPF network and BGP network.


PRI-P2P

!
router ospf 1
 router-id 10.35.1.254
 area 0 authentication
 redistribute bgp 65210 subnets route-map B2O-IN
 network 10.35.1.96 0.0.0.7 area 0
 network 10.35.1.104 0.0.0.7 area 0
 network 192.168.249.254 0.0.0.0 area 0
!
router bgp 65210
 bgp log-neighbor-changes
 network 10.35.1.252 mask 255.255.255.252
 network 192.168.249.254 mask 255.255.255.255
 redistribute ospf 1 route-map O2B-OUT
 neighbor 10.35.1.253 remote-as 65211
 neighbor 10.35.1.253 password 7 xxxxxxxxxxxxxxxx
 neighbor 10.35.1.253 send-community
 neighbor 10.35.1.253 soft-reconfiguration inbound
 neighbor 10.35.1.253 route-map P2P-IN in
 neighbor 10.35.1.253 route-map P2P-OUT out
!
!IP Ranges on BGP network side.  
!
ip prefix-list B2O seq 10 permit 97.0.0.0/11 ge 16
ip prefix-list B2O seq 20 permit 10.64.0.0/11 ge 12
ip prefix-list B2O seq 30 permit 192.168.97.0/24 ge 29
!
!IP Ranges on OSPF network side
!
ip prefix-list O2B seq 10 permit 192.168.249.254/32
ip prefix-list O2B seq 20 permit 10.0.0.0/10 ge 11
ip prefix-list O2B seq 30 permit 10.96.0.0/11 ge 12
ip prefix-list O2B seq 40 permit 10.128.0.0/9 ge 10
!
!Inbound filter - only accept advertisements of networks to be distributed.
!
ip prefix-list P2P-IN-LIST seq 5 deny 0.0.0.0/0
ip prefix-list P2P-IN-LIST seq 10 permit 97.0.0.0/11 ge 16
ip prefix-list P2P-IN-LIST seq 20 permit 10.64.0.0/11 ge 12
ip prefix-list P2P-IN-LIST seq 30 permit 192.168.97.0/24 ge 29
!
!Outbound filter - do not advertise DMVPN endpoint IPs, do not advertise default, permit anything else.
!
ip prefix-list P2P-OUT-LIST seq 10 deny 192.168.255.0/24 ge 25
ip prefix-list P2P-OUT-LIST seq 15 deny 0.0.0.0/0
ip prefix-list P2P-OUT-LIST seq 20 permit 0.0.0.0/0 le 32
!
!
!
route-map B2O-IN deny 5
 match community 400  <== do not distribute BGP routes that have already been distributed.
!
route-map B2O-IN permit 7
 set tag 300   <== tag traffic that will be distributed into OSPF.

!

!
route-map B2O-IN permit 10
 match ip address prefix-list B2O
!
!
!Inbound filter - do not accept advertisements that this router will not redistribute.

!

!
route-map P2P-IN deny 5
 match community 400
!
route-map P2P-IN permit 10
 match ip address prefix-list P2P-IN-LIST
!
route-map P2P-OUT permit 10
 match ip address prefix-list P2P-OUT-LIST
!
route-map O2B-OUT deny 5
 match tag 300
!
route-map O2B-OUT permit 7
 set community 400
!
route-map O2B-OUT permit 10
 match ip address prefix-list O2B
!

PH-L3

!
router ospf 1
 router-id 172.17.1.20
 log-adjacency-changes
 area 0 authentication
 redistribute bgp 65020 metric-type 1 subnets route-map B2O-IN
 network 10.35.244.0 0.0.0.3 area 0
 network 172.17.1.0 0.0.0.255 area 0
!
router bgp 65020
 no synchronization
 bgp router-id 10.35.1.241
 bgp log-neighbor-changes
 network 10.35.1.40 mask 255.255.255.252
 network 192.168.255.20 mask 255.255.255.255
 redistribute ospf 1 route-map O2B-OUT
 neighbor 10.35.1.42 remote-as 10
 neighbor 10.35.1.42 send-community
 neighbor 10.35.1.42 soft-reconfiguration inbound
 neighbor 10.35.1.42 route-map CORE-IN in
 neighbor 10.35.1.42 route-map B2O-DENY out
 neighbor 10.35.1.245 remote-as 3549
 neighbor 10.35.1.245 password 7 XXXXXXXXXXXXXXXXXXX
 neighbor 10.35.1.245 route-map MPLS-FILTER-OUT out
 no auto-summary
!
ip prefix-list B2O seq 10 permit 97.0.0.0/11 ge 16
ip prefix-list B2O seq 90 permit 192.168.97.0/24 ge 29
ip prefix-list B2O seq 100 permit 10.64.0.0/11 ge 12
!
ip prefix-list B2O-DENY seq 10 deny 192.168.255.0/24 ge 25
ip prefix-list B2O-DENY seq 15 deny 0.0.0.0/0
ip prefix-list B2O-DENY seq 20 permit 0.0.0.0/0 le 32
!
ip prefix-list B2O-DENY2 seq 10 permit 192.168.255.0/24 ge 25
ip prefix-list B2O-DENY2 seq 20 permit 0.0.0.0/0
!
ip prefix-list MPLS-OUT seq 10 permit 192.168.255.0/24 ge 25
!
ip prefix-list O2B seq 10 permit 10.10.0.0/16
ip prefix-list O2B seq 20 permit 10.1.0.0/16
ip prefix-list O2B seq 30 permit 10.6.1.0/24
!
!
!
!
route-map B2O-DENY permit 10
 match ip address prefix-list B2O-DENY
!
route-map B2O-IN deny 5
 match community 400
!
route-map B2O-IN deny 6
 match ip address prefix-list B2O-DENY2
!
route-map B2O-IN permit 7
 set tag 300
!
route-map B2O-IN permit 10
 match ip address prefix-list B2O
!
route-map CORE-IN deny 5
 match community 400
!
route-map CORE-IN permit 10
 match ip address prefix-list B2O
!
route-map MPLS-FILTER-OUT deny 10
 match community 400
!
route-map MPLS-FILTER-OUT deny 20
 match ip address prefix-list B2O
!
route-map MPLS-FILTER-OUT permit 30
 match ip address prefix-list MPLS-OUT
!
route-map O2B-OUT deny 5
 match tag 300
!
route-map O2B-OUT permit 7
 set community 400
!
route-map O2B-OUT permit 10
 match ip address prefix-list O2B
!
route-map DENY-OUT deny 5
 match community 400
!

Multiple Mutual Redistribution OSPF <> BGP

Nearing the close of a big project.  Connectivity for two nearly equal sized networks:
First is OSPF overlay on dual service provider MPLS WANs advertising a single IP via BGP.  These IP's are used to establish DMVPN connectivity to hub sites.
The other has a very simplified remote office with just a couple VLANs defaulting to a core switch.  That core switch is a BGP neighbor with the single MPLS service provider router. 

Design Goals

1.     Add point to point connection between new routers PRI-P2P and PH-P2P
2.     Add MPLS to Philadelphia site connected to new router PH-L3
3.     Route user traffic primarily over MPLS
4.     Use point to point connection for communication between specific datacenter systems with policy routing.
5.     If MPLS path fails, user traffic should be routed over point to point circuit automatically.
6.     Redistribute OSPF into BGP on:  PRI-P2P & PH-L3.
7.     Redistribute BGP into OSPF on:  PRI-P2P & PH-L3.
8.     Do not redistribute BGP into OSPF for subnets only used for DMVPN.
9.     Prevent redistribution from creating routing loops.  That is, do not allow redistribution of routes that have been redistributed already by the same or another router.
10.  Avoid asynchronous routes between hosts
11.  Do not redistribute default routes

Things I have learned

I have a fair amount of experience but have never done much redistribution.  I had to learn a lot in order to make this work.  I got help from vendor(s) and colleagues.  Did a lot of googling and reading.  The following is an unorganized list of things that I noticed or that helped me once I realized them.
  • Route redistribution might be better called route import because redistribution into a routing protocol is done in the configuration of the protocol intended to receive routes.  That is, ospf configuration would be added to redistribute "into OSPF".
  • Route redistribution does not put routes into the routing table on the router doing the redistribution.
  • Redistribution isn't really the hard part.  It is about figuring out the routing protocols for troubleshooting and manipulating them to avoid loops and so forth.
    • Route filtering
    • Route tagging
    • In addition to routing table, there will be a database of potential routes--only one of which will go into the routing table.  (show ip bgp)
    • Metric
    • I also assume that redistribution behavior has different rules/behaviors according to what routing protocol is pulling in the routes.
    • BGP commands to show route advertisements sent and received
    • timer adjustments.
  • I cannot found an example on internet of mutual redistribution between OSPF & BGP.
  • BGP doesn't have TAGs.  Uses COMMUNITY.  But the idea is the same.
  • Everything seems to work as desired when a state is achieved where, on the router doing redistribution, the routing table holds OSPF routes for all the "native" OSPF locations and BGP routes for all the "native" BGP routes.
  • To prevent routing loops and achieve the state described above it is important to filter route advertisements in/out in addition to applying tagging to the redistribution config.
  • Use traffic steering to determine primary paths.  i.e. OSPF cost & BGP path length.  Remember that OSPF cost required to make this happen could affect the overall design of the network if costs are involved and some existing OSPF configuration may need adjusted on existing more routers.  In TS case, a bigger OSPF cost is needed for sites that are manually configured with higher cost to prefer the TW path.
  • The routes for the BGP MPLS IP's used for DMVPN must not get into the "overlay" routing table.  That is, if BGP routes for the loopbacks used to establish the DMVPN tunnels get into OSPF then OSPF stops working.  "mid-chain attempting to stack…."
  • BGP
show ip bgp neighbors [IP of neighbor] advertised-routes
show ip bgp neighbors [IP of neighbor] received-routes
show ip bgp

10/15/2013

BGP

Great article:
http://www.netcraftsmen.net/resources/archived-articles/382.html
UPDATE:  It appears netcraftsmen.net is no longer there!  http://web.archive.org/web/20121219075610/http://www.netcraftsmen.net/resources/archived-articles/382.html



This entire site looks very good.

7/19/2013

BGP Route Convergence on the Internet

BGP Internet Route Convergence

If your network is multihomed -- How long does it take routes TO you to converge? These slides are very informative.  Wish I was in the classroom during this talk....

http://www.cs.northwestern.edu/~ychen/classes/cs450-05/lectures/BGP_Convergence.ppt

7/12/2013

Redundant Datacenter Connectivity

Datacenter Connectivity

Goals
  • Create redundant datacenters. For now, 2 of them.
  • Redundant, diverse, physical circuits/paths
  • Allow simple movement of services between datacenters => support the same IP address ranges in either location
An example:  http://connect.iltanet.org/ILTANET/Go.aspx?c=BlogViewer&BlogKey=d671b21d-b20a-4b07-84d5-3d4357723f0a

Issues/Discussion Items
Layer 2
to allow the same IP address ranges
  • Circuits are different vendors taking very different paths with unknown infrastructure in between the datacenters. A failure could occur within the service provider, but all my ports show "up." 
  • So, Spanning Tree and Port Channels will not work for "in between" failures
  • UDLD, Unidirectional Link Detection, doesn't seem work on a "virtual circuit" over a provider network like Metro Ethernet.
  • Cisco's OTV is supposed to accomplish a big part of this, but it seems that a much less overblown solution could at least provide the Layer 2 redundancy.

Routing Redundancy
  • For routing to work, the (outbound)default route must be configured to go out through the same datacenter where the inbound traffic will be arriving. 
  • So any kind of automatic redundancy that fails the inbound route to the secondary datacenter needs to also initiate a change to the default route of all machines in the "shared" networks.
  • A compromise would be a "one button push" method to switch inbound and outbound routing to change between datacenters.
  • Does OTV address this?
Nuts & Bolts

  • A traditional solution would possibly involve 2 circuits each with a router at each end.  L3 redundancy between the 2 links using HSRP/GLBP, some kind of IP tracking to expose a service provider outage, and somehow create L2 tunnels over each one and use them via a port aggregation at the core switch.  The question remains whether this solution can be designed to show a link as down even if the failure is in between.
  • There seems to be little in the way of configuration help or reference material for GRE/MGRE tunnels.  Even less for L2 tunneling.  I suppose the motivation for helping users do that is even less now that there is a nebulous thing called OTV that involves a big spend on monster Nexus 7K core switches.
  • I haven't been able to get into the guts of this and do any testing.  Thinking it through on paper I always get bogged down with the L2 tunnel.  A possible example L2TP configuration is:

Router A:

pseudowire-class test
encapsulation l2tpv3
protocol none
ip local interface Loopback0
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
interface FastEthernet0/1
description LAN
no ip address
speed 100
full-duplex
xconnect 2.2.2.2 1 encapsulation l2tpv3 manual pw-class test
l2tp id 1 2


Router B:

pseudowire-class test
encapsulation l2tpv3
protocol none
ip local interface Loopback0
!
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!interface FastEthernet0/1
no ip address
duplex auto
speed auto
xconnect 1.1.1.1 1 encapsulation l2tpv3 manual pw-class test
l2tp id 2 1

7/14/2009

LOOKING GLASS
Example script to check several telnet route servers and create html file of AS-PATH


use Net::Telnet ();

my $outdir = "\\inetpub\\wwwroot\\look\\data";
my $idxdir = "\\inetpub\\wwwroot\\look";
my $url = "data";
mkdir ($idxdir);
mkdir ($outdir);
#list of public routers accepting telnet with no logon
my @list2 = (
"route-views.optus.net.au" ,
"route-server.videotron.net" ,
"route-server.ipilink.net" ,
"route-server.host.net" ,
"public-route-server.is.co.za" ,
"route-server-east.gt.ca" ,
"route-server-west.gt.ca" ,
"route-server.gt.ca" ,
"route-views.on.bb.telus.com" ,
"route-views.ab.bb.telus.com" ,
"routeserver.sunrise.ch" ,
"route-server.belwue.de" ,
"route-server.ip.tiscali.net" ,
"route-server.eu.gblx.net" ,
"route-server.cerf.net" ,
"route-server.gblx.net" ,
"route-server.host.net" ,
"route-server.he.net" ,
"route-server.twtelecom.net" ,
"public-route-server.is.co.za" ,
"route-server.central.allstream.com" ,
"route-server.east.allstream.com" ,
"route-server.west.allstream.com" ,
"route-server.vtl.net" ,
"route-server.eastlink.ca" ,
);

#date
my ($sec,$min,$hour,$mday,$mon,$year,
$wday,$yday,$isdst) = localtime time;
$year = $year+1900;
$mon = $mon+1;
$mon = sprintf("%02d", $mon);
$mday = sprintf("%02d", $mday);
$hour = sprintf("%02d", $hour);
$min = sprintf("%02d", $min);
my $date = "$mon\-$mday\-$year $hour:$min";

#Build report

my $file = "$outdir\\$year\-$mon\-$mday\-$hour$min.html";
open FIL , ">$file";

print FIL <<ENDHEADER;
<HTML>
<HEAD>
<TITLE>Looking Glass Results</TITLE>
<META HTTP-EQUIV="Refresh" CONTENT="300">
<META HTTP-EQUIV="Cache-Control" content="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="Mon, 16 May 2005 13:59:00 GMT">
<style type="text/css">
H1 {font-family:serif; border-width: 0; border-bottom: solid; text-align: left}
H3 {font-family:serif; padding-top:0px;color:#000000;padding-bottom:0px;margin-bottom:0px;}
body {font-family:monospace;font-size:.75em;margin:3%;padding:0px;background:#aabbcc;color:#000000;}
</style>
</HEAD>

<BODY bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">

<H1>AS-PATH to 4.4.4.0/24</H1>
<H4>$date</H4>
<HR>
ENDHEADER
;
#telnet to each router and query for info
foreach $router (@list2) {
print ".";
my (@result, $t);
print FIL "<H2>$router</H2>\n";
$t = new Net::Telnet (Timeout => 20, Errmode => "return");
$t->open("$router");

## Wait for prompt and enter command.
$t->waitfor('/>/') or print "X";
$t->print("show ip bgp 4.4.4.0/24");
($result) = $t->waitfor('/>/');

#Filter results for lines containing (AS) 32166
@result = split(/\n/, $result);
my $prev = "prior line\n";
print ".";
foreach $line (@result) {
if ($line eq $prev) {
next
};
if ($line =~ /32166/) {
push (@output, "$line<br>\n");
$prev = $line;
}
print ".";
}

print FIL "<p>@output</p>\n";
print FIL "<HR>\n";
@output="";
$result="";
@result="";
print ".";
}

print "\n";
print FIL <<ENDTAIL;
</TABLE>

</BODY>
</HTML>

ENDTAIL
;

close FIL;

#Build index of reports

open IDX , ">$idxdir\\look.html";

print IDX <<IDXHEADER;
<HTML>
<HEAD>
<TITLE>Looking Glass Results</TITLE>
<META HTTP-EQUIV="Refresh" CONTENT="300">
<META HTTP-EQUIV="Cache-Control" content="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="Mon, 16 May 2005 13:59:00 GMT">
<style type="text/css">
H1 {font-family:serif; border-width: 0; border-bottom: solid; text-align: left}
H3 {font-family:serif; padding-top:0px;color:#000000;padding-bottom:0px;margin-bottom:0px;}
body {font-family:monospace;font-size:.75em;margin:3%;padding:0px;background:#aabbcc;color:#000000;}
</style>
</HEAD>

<BODY bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000" alink="#000000">

<H1>INDEX</H1>
<H3>AS-PATH to 4.4.4.0/24</H3><BR>
IDXHEADER
;

my ($path, $file, @files, $file_full_path);
opendir (SOURCE, $outdir) or die "Cannot open the source folder for reading: $!\n";
my @sorted_files =
map $_->[1],
sort { $a->[0] <=> $b->[0] }
map -f "$outdir/$_" ? [ ( stat _ )[9], $_ ] : (),
readdir SOURCE;


closedir (SOURCE);
for (@sorted_files){
$file_full_path = "$url/$_";
print IDX qq(<a href="$file_full_path" target="_blank">$_</a>     \n);
} #end for






print IDX <<IDXTAIL;
</TABLE>

</BODY>
</HTML>

IDXTAIL
;

close IDX

6/17/2009

Cisco::VRF::Routing


Segregating WAN traffic to provide public internet access from a central location

We provide wireless internet in public areas in every office. For this purpose we provide cable internet, DSL, or dedicated T1 circuits. To save money and better control this traffic, we want to direct that traffic back through our headquarters' internet circuits. To do this we need a way to segregate this traffic on our WAN links for security and to keep it from overutilizing our WAN.
VRF and tunnels seems to be the answer.

Cisco Design Guide
Good Overview

1/18/2007

Multicast Routing


http://www.cymru.com/Documents/Cisco/multicast-router.txt


@(#)multicast routing howto 04 AUG 1997 Rob Thomas robt@cymru.com
How to setup a router to route multicast packets
Multicast is a UDP-based protocol which literally delivers packets from one
host to many. If abused, it can be made to deliver from many hosts to
many hosts to many hosts to many hosts... This is why it's important to
setup multicasting routing on the routers in a sane manner.
1. First, enable the global multicast routing parameter by:
!
ip multicast-routing
!
This can be disabled, if you so choose, by doing:
!
no ip multicast-routing
!
2. Next, select your style of multicasting. I chose PIM (Protocol-
Independent Multicast) for the following reasons:
- PIM works with all existing multicast routing protocols.
- PIM has two modes (dense & sparse) which gives me some freedom at
configuration time.
You could also choose from IGMP (Internet Group Management Protocol,
which is good for large WANs) or DVMRP (Distance Vector Multicast
Routing Protocol, which is slightly unsupported). However, be aware
that Cisco only tacitly supports DVMRP. To use DVMRP with a Cisco
router, you need to point your Cisco to a router that DOES support
DVMRP directly.
Of the two PIM choices, I went with dense mode. Here are the differences:
- Dense mode: When the router receives a multicast packet, the router
sends the packet out of all interfaces except for the interface from
whence the packet originated. If the router discovers that a certain
interface has no multicast recipients, it sends a "prune" message back
to the sender stating that there is no need to send messages to that
interface/subnet/link/host.
- Sparse mode: In sparse mode, it is assumed that no host wants multi-
cast packets unless the host specifically asks for it. So, instead
of the shotgun approach of dense mode, one router becomes the central
hub. This central hub logs all hosts that wish to receive multicast.
Further multicast packets are sent only to those hosts.
Seeing as how we only have two routers, I did not want one router to be
burdened with the list of multicast hosts (especially since practically
ALL of our hosts "want" multicast). Additionally, I did not want to
spend time fudging entries in the multicast recipient list.
So, to configure for PIM dense mode multicast routing:
!
interface ethernet 0
ip pim dense-mode
!
interface ethernet 1
ip pim dense-mode
!
Obviously, all involved routers should be speaking the same lingo. Thus,
routerA is configured the same as routerB.
3. Next, you need to set the multicast threshold. This is the BIG TRICK[tm]
to multicast routing. In a nutshell, every multicast packet has a TTL.
That's basic to all IP. By setting the multicast threshold on a given
router interface, you create a hurdle. If the packet's TTL is higher
than the multicast threshold, the packet may pass. If the packet's TTL
is LOWER than the multicast threshold, the packet is stopped (actually,
it is bounced with an ICMP message, but that's for another "howto" ;-).
This is how one prevents multicast packets from careening out into the
great 'Net. The range for multicast threshold is 0 to 255, with 0
meaning all packets may pass (well, *almost* all) and 255 meaning
virtually no packets may pass. On the routerB router, I set up the
multicast threshold at a comfortable 1 (because this is an internal
router). The multicast threshold on the interface leading to the
Internet on routerA should be set at 255 (if, in fact, multicast is
enabled on the interface at all).
!
interface ethernet 0
ip multicast-threshold 1
!
interface ethernet 1
ip multicast-threshold 1
!
And you're set!
4. It's probably a VERY good idea at this point to save your config. I
choose to save off to tftp (in case my NVRAM gets scrammed), but you
can choose your own danger here. At the least, you should copy your
running-config to your saved config.
router#copy running-config startup-config
Enjoy!
Questions/comments/bugs to: robt@cymru.com
Famous Unix quotes: "You are not expected to understand this."
-- From the original comments in the source code for Version 7's
process scheduling algorithm.
Rob Thomas, robt@cymru.com
http://www.enteract.com/~robt