OSPF/Summarization and redistribution complex example

From MikroTik Wiki
Jump to: navigation, search

OSPF routes redistribution, summarization and stub area complex example

Packages required: routing

Let's look at the network topology shown below. We have three routers connected to each other via ethernet. Routers R0 and R1 are MikroTik RouterBOARDs running RouterOS 3.25 and router R2 is Cisco 2611. R3 can be any other router, so cisco is taken just for example. Loopback interface on R0 also is just for example because I do not have ether3 on this router.


OSPF summary.jpeg

Basic OSPF configuration

OSPF areas configuration is introduced below:

OSPF summarization 2.png

Router R1 is Area Border Router. We will make summarization here.

First of all let's configure basic parametrs on our routers.

R0 without external routes summarization

/ip address
add address=192.168.88.2/25 broadcast=192.168.88.127 comment="" disabled=no \
    interface=ether1 network=192.168.88.0
add address=192.168.88.129/25 broadcast=192.168.88.255 comment="" disabled=no \
    interface=ether2 network=192.168.88.128
add address=192.168.85.1/24 broadcast=192.168.85.255 comment="" disabled=no \
    interface=loopback0 network=192.168.85.0

This blackhole route will emulate remote network 192.168.84.0/24, which is reachable via static route:

/ip route
add disabled=no distance=1 dst-address=192.168.84.0/24 type=blackhole

Here we will start OSPF process on router R0 and change default parameters to enable redistribution of connected and static routes. Also we will add 192.168.88.0/24 network to OSPF routing process:

/routing ospf area
set backbone area-id=0.0.0.0 authentication=none disabled=no name=backbone \
   type=default
/routing ospf
set distribute-default=never metric-bgp=20 metric-connected=20 \
    metric-default=1 metric-rip=20 metric-static=20 mpls-te-area=unspecified \
    mpls-te-router-id=unspecified redistribute-bgp=no redistribute-connected=\
    as-type-1 redistribute-rip=no redistribute-static=as-type-1 router-id=0.0.0.0
/routing ospf network
add area=backbone disabled=no network=192.168.88.0/24

Lets's look at R0 routing table:

[admin@R0] > /ip route print
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY-STATE GATEWAY               DISTANCE INTERFACE
 1 A SB 192.168.84.0/24                                                        1
 2 ADC  192.168.85.0/24    192.168.85.1                                        0        loopback0
 3 ADC  192.168.88.0/25    192.168.88.2                                        0        ether1
 4 ADC  192.168.88.128/25  192.168.88.129                                      0        ether2
 5 ADo  192.168.89.64/26                   reachable     192.168.88.3          110      ether1

R1 without inter-area summarization

/ip address
add address=192.168.88.3/25 broadcast=192.168.88.127 comment="" disabled=no \
    interface=ether1 network=192.168.88.0
add address=192.168.89.66/26 broadcast=192.168.89.127 comment="" disabled=no \
    interface=ether2 network=192.168.89.64

In the same way we will start OSPF process on router R1 as on R0. Similarly, we will add 192.168.89.64/26 and 192.168.88.0/25 networks to OSPF routing process:

/routing ospf area
set backbone area-id=0.0.0.0 authentication=none disabled=no name=backbone \
    type=default
add area-id=0.0.0.1 authentication=none default-cost=1 disabled=no \
    inject-summary-lsa=no name=area1 type=default
/routing ospf
set distribute-default=never metric-bgp=20 metric-connected=20 \
    metric-default=1 metric-rip=20 metric-static=20 mpls-te-area=unspecified \
    mpls-te-router-id=unspecified redistribute-bgp=no redistribute-connected=\
    no redistribute-rip=no redistribute-static=no router-id=0.0.0.0
/routing ospf network
add area=area1 disabled=no network=192.168.89.64/26
add area=backbone disabled=no network=192.168.88.0/25

Lets's look at R1 routing table:

Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY-STATE GATEWAY               DISTANCE INTERFACE
 0 ADo  192.168.84.0/24                    reachable     192.168.88.2          110      ether1
 1 ADo  192.168.85.0/24                    reachable     192.168.88.2          110      ether1
 2 ADC  192.168.88.0/25    192.168.88.3                                        0        ether1
 3 ADo  192.168.88.128/25                  reachable     192.168.88.2          110      ether1
 4 ADC  192.168.89.64/26   192.168.89.66                                       0        ether2

R2 configuration

R2 configuration is very simple even if you don't know the syntax of Cisco IOS configuration:

interface Ethernet0/0
 ip address 192.168.89.65 255.255.255.192
!
interface Ethernet0/1
 ip address 192.168.89.1 255.255.255.192
!
router ospf 1
 network 192.168.89.64 0.0.0.63 area 1
!

0.0.0.63 is wildcard mask for network mask 255.255.255.192. Corresponding RouterOS configuration should look like this:

/routing ospf network
 add area=area1 disabled=no network=192.168.89.64/26

Lets's look at R2 routing table (output omitted):

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2    
       ia - IS-IS inter area, * - candidate default, U - per-user static route
...
     192.168.89.0/26 is subnetted, 2 subnets
C       192.168.89.0 is directly connected, Ethernet0/1
C       192.168.89.64 is directly connected, Ethernet0/0
     192.168.88.0/25 is subnetted, 2 subnets
O IA    192.168.88.0 [110/20] via 192.168.89.66, 00:10:10, Ethernet0/0
O IA    192.168.88.128 [110/30] via 192.168.89.66, 00:10:14, Ethernet0/0
O E1 192.168.85.0/24 [110/40] via 192.168.89.66, 00:09:28, Ethernet0/0
O E1 192.168.84.0/24 [110/40] via 192.168.89.66, 00:09:57, Ethernet0/0

Redistributing static routes and summarization

It's time to start inter-area routes and external routes summarization.

R0

Let's add blackhole summary route for static route 192.168.84.0/24 and connected route 192.168.85.0/24:

/ip route
add comment="" disabled=no distance=254 dst-address=192.168.84.0/23 type=\
    blackhole

With help of routing filter we will allow only summary route advertisement:

/routing filter
add action=accept chain=ospf-out comment="" disabled=no invert-match=no \
    prefix=192.168.84.0/23
add action=discard chain=ospf-out comment="" disabled=no invert-match=no

Let's look at the routing table of R0 again:

[admin@R0] > /ip route print
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY-STATE GATEWAY               DISTANCE INTERFACE
 0 A SB 192.168.84.0/23                                                        254
 1 A SB 192.168.84.0/24                                                        1
 2 ADC  192.168.85.0/24    192.168.85.1                                        0        loopback0
 3 ADC  192.168.88.0/25    192.168.88.2                                        0        ether1
 4 ADC  192.168.88.128/25  192.168.88.129                                      0        ether2
 5 ADo  192.168.89.0/24                   reachable     192.168.88.3          110      ether1

Notice that route number 0 was added.

R1

R1 is Area Border Router. Here we can make inter-area summarization. Inter-area summarization was made with help of area ranges. Networks 192.168.88.0/25 and 192.168.88.128/25 are combined in 192.168.88.0/24. Network 192.168.89.64/26 is summarized in 192.168.89.0/24 (f.e. for future use):

/routing ospf area range
add advertise=yes area=backbone cost=default disabled=no range=192.168.88.0/24
add advertise=yes area=area1 cost=default disabled=no range=192.168.89.0/24

Let's look at the routing table after aggregation and summarization:

Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY-STATE GATEWAY               DISTANCE INTERFACE
 0 ADo  192.168.84.0/23                    reachable     192.168.88.2          110      ether1
 1 ADC  192.168.88.0/25    192.168.88.3                                        0        ether1
 2 ADo  192.168.88.128/25                  reachable     192.168.88.2          110      ether1
 3 ADoU 192.168.89.0/24                                                        110
 4 ADC  192.168.89.64/26   192.168.89.66                                       0        ether2

Notice that route number 3 for 192.168.89.0/24 is presented as unreachable. This route is created automatically by routing process because it can't announce network until it have not any route to it (this is similarly to cisco ios behavior which creats automatic route to Null0 interface for such purpose).

R2

New routing table on router R2 will look as follows:

    192.168.89.0/26 is subnetted, 2 subnets
C       192.168.89.0 is directly connected, Ethernet0/1
C       192.168.89.64 is directly connected, Ethernet0/0
O IA 192.168.88.0/24 [110/30] via 192.168.89.66, 00:00:02, Ethernet0/0
O E1 192.168.84.0/23 [110/40] via 192.168.89.66, 00:00:02, Ethernet0/0

Area 1 in stub configuration

Finally let's configure area1 as a stub area. For this purpose we will configure area type as stub on both R1 and R2. In other case routers will not agree the Stub Area Flag and will not form the adjacency (like then authentication parameters did not match).


R1

/routing ospf area
add area-id=0.0.0.1 authentication=none disabled=no name=area1 type=stub

R2

router ospf 1
 area 1 stub
 network 192.168.89.64 0.0.0.63 area 1


Routing from the stub area is made via default route:

     192.168.89.0/26 is subnetted, 2 subnets
C       192.168.89.0 is directly connected, Ethernet0/1
C       192.168.89.64 is directly connected, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.168.89.66, 00:06:33, Ethernet0/0

Russian version: http://wiki.mikrotik.com/wiki/Russian/Суммирование_и_перераспределение_маршрутов_OSPF

--shados 11:07, 17 June 2009 (EEST)