Thursday, 14 April 2011

The OSPF domain-id.

With MPLS technology, the ospf-area hierarchy was reorganized. Namely, Super-Backbone OSPF Area was introduced, which is now on the top level. With this concept, one fact is very interesting and unusual (as compared with 'normal' OSPF behaviour).

Before I will tell you, what I have in mind, just remember few things:
  • In fact, in OSPF Super-Backbone Area there might not be OSPF! Here packets are carried using MP-BGP rather than OSPF. OSPF can run in background, as a separate routing protocol and can be used to reach the BGP next-hop.
  • On PE routers there is a mutual distribution between MP-BGP and PE-CE routing protocols.
  • Under normal circumstances, when redistribute command is used under OSPF routing process, all redistributed routes automatically become external routes (E1 or E2).
So what is here interesting, when routes are redistributed on a PE router (using redistribute command), these routes may or not be propagate as external routes. We can use domain-id command to control the type of routes that are redistributed into CE-PE OSPF routing protocol. When the configured domain-id is equal to OSPF routing process, routes are redistributed as inter-area routes (IA). When this two values are not equal, routes are redistributed as external routes (E1 or E2). However, there is one small thing that can be confused: in which direction exactly this command works?



On the picture (click to enlarge) we see a simple situation, where customer 'bank' has three sites. These sites are connected to each other using MPLS and MP-BGP. R1, R3 and R4 are PE routers, whereas R5-7 are CE routers and OSPF was chosen as CE-PE routing protocol for each sites. However there are different OSPF processes and different areas:
  • R1-R5: process-id 1, area-id 0
  • R3-R7: process-id 1, area-id 1
  • R4-R6: process-id 2, area-id 0 
Now, let's look into R7, R5 and R6 routing table:

R7#show ip route ospf
     154.0.0.0/32 is subnetted, 1 subnets
O E2    154.0.0.1 [110/65] via 101.0.0.1, 00:04:03, Serial0/0
     175.0.0.0/32 is subnetted, 1 subnets
O IA    175.0.0.1 [110/129] via 101.0.0.1, 00:55:19, Serial0/0


Route from R6 is marked as external, and route from R5 is marked as inter-area.

R5#show ip route ospf
     154.0.0.0/32 is subnetted, 1 subnets
O E2    154.0.0.1 [110/65] via 100.0.0.1, 00:06:51, Serial0/0
     167.0.0.0/32 is subnetted, 1 subnets
O IA    167.0.0.1 [110/129] via 100.0.0.1, 00:53:49, Serial0/0


Route from R6 is marked as external, and route from R7 is marked as inter-area.

R6#show ip route ospf
     175.0.0.0/32 is subnetted, 1 subnets
O E2    175.0.0.1 [110/65] via 102.0.0.1, 00:27:30, Serial0/0
     167.0.0.0/32 is subnetted, 1 subnets
O E2    167.0.0.1 [110/65] via 102.0.0.1, 00:27:30, Serial0/0


Here we can see, that area-id is completely ignored (R5 and R6 are both in area 0,  but routes between them are marked as external). However if the process-id match (R5 and R7), routes are marked as inter-area.

With the domain-id command, we can influence, how routes are redistributed. However with this post I would like to answer the question, in which direction this command works. For example, when we change domain-id on the R3 router, which routes will have this domain-id: these learned from MP-BGP (so learned from R1 and R4) or these learned from R7?

Basically, we can see the domain-id of the route using the following command:

R3#show ip bgp vpnv4 all 167.0.0.1
BGP routing table entry for 1:1:167.0.0.1/32, version 5

! some lines omitted
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000010200
        OSPF RT:0.0.0.1:2:0 OSPF ROUTER ID:101.0.0.1:0
R3#show ip bgp vpnv4 all 154.0.0.1
BGP routing table entry for 1:1:154.0.0.1/32, version 19
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:102.0.0.1:0
R3#show ip bgp vpnv4 all 175.0.0.1
BGP routing table entry for 1:1:175.0.0.1/32, version 13
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000010200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:100.0.0.1:0


Now, let's change the domain-id on R3 and examine again routing tables from CE routers:

R3#configure t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router ospf 1 vrf bank
R3(config-router)#domain-id 0.0.0.2


R5#show ip route ospf
     154.0.0.0/32 is subnetted, 1 subnets
O E2    154.0.0.1 [110/65] via 100.0.0.1, 00:30:43, Serial0/0
     167.0.0.0/32 is subnetted, 1 subnets
O E2    167.0.0.1 [110/65] via 100.0.0.1, 00:01:01, Serial0/0

R7#show ip route ospf
     154.0.0.0/32 is subnetted, 1 subnets
O IA    154.0.0.1 [110/129] via 101.0.0.1, 00:01:51, Serial0/0
     175.0.0.0/32 is subnetted, 1 subnets
O E2    175.0.0.1 [110/65] via 101.0.0.1, 00:01:51, Serial0/0

R6#show ip route ospf
     175.0.0.0/32 is subnetted, 1 subnets
O E2    175.0.0.1 [110/65] via 102.0.0.1, 00:31:48, Serial0/0
     167.0.0.0/32 is subnetted, 1 subnets
O IA    167.0.0.1 [110/129] via 102.0.0.1, 00:02:03, Serial0/0

And the output from R3:

R3#show ip bgp vpnv4 all 167.0.0.1
! some lines omitted
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.1:2:0 OSPF ROUTER ID:101.0.0.1:0
R3#show ip bgp vpnv4 all 154.0.0.1
BGP routing table entry for 1:1:154.0.0.1/32, version 19
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000020200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:102.0.0.1:0
R3#show ip bgp vpnv4 all 175.0.0.1
      Extended Community: RT:1:1 OSPF DOMAIN ID:0x0005:0x000000010200
        OSPF RT:0.0.0.0:2:0 OSPF ROUTER ID:100.0.0.1:0 


Here we can see, that after domain-id was changed on R3, this new domain-id was changed only for updates received from R7 (167.0.0.1) via CE-PE OSPF. The domain-id of updates received from MP-BGP was not altered. This means, that domain-id influences on updates that are redistributed from VPN site (so from CE-PE routing process) to MP-BGP. In other words, if we want to have on R5 routes from R6 marked as inter-area, we have to change the domain-id on R4 router, not on R1. Changing domain-id on R1, we will influence on the routes that are sent to R6.