Thursday, March 31, 2016

OSPF Redistribution Tutorial


This tutorial shows how to redistribute connected routes into OSPF. On R2 we will start up a few loopback interfaces and redistribute the connected routes.Lets take a lab of 2 routers and do some basic OSPF configuration:














Both routers just have the interface serial 1/0 and the interface loopback 0 configured. If you use the basic configuration and start the routers you can ping the other router.

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 100
R1(config-router)#network 192.168.100.1 0.0.0.0 area 0
R1(config-router)#end

R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router ospf 100
R2(config-router)#network 192.168.100.2 0.0.0.0 area 0
R2(config-router)#end
The routers now have a basic OSPF neighborship an can exchance routes. There are no OSPF routes yet, because OSPF is only spoken on the serial line.
Now two loopback interfaces on R2 are configured:

R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface loopback 1
R2(config-if)#ip address 10.1.1.1 255.255.255.0
R2(config-if)#exit
R2(config)#interface loopback 2
R2(config-if)#ip address 10.2.2.2 255.255.255.0
R2(config-if)#end

R2#show running-config | begin Loop
interface Loopback0
 ip address 172.17.0.2 255.255.255.255
!
interface Loopback1
 ip address 10.1.1.1 255.255.255.128
!
interface Loopback2
 ip address 10.2.2.2 255.255.255.0

R2#show ip route | include Loop
C       172.17.0.2 is directly connected, Loopback0
C       10.2.2.0/24 is directly connected, Loopback2
C       10.1.1.0/25 is directly connected, Loopback1
The interfaces are created and active. Now we redistribute this interfaces into OSPF. OSPF treats redistributed routes as external routers, that are not part of an area. OSPF know two types of external routes: E1 and E2. They differ in the metric and how the metric is calculated.
Loopback0 : External 2
Loopback1 : External 2 metric 50
Loopback2 : External 1
For this kind of redistribution we need a route map that defines which interfaces are to be redistributed and how the routes should be redistributed.

R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#route-map C-OSPF permit 10
R2(config-route-map)#match interface loopback 0
R2(config-route-map)#exit
R2(config)#route-map C-OSPF permit 20
R2(config-route-map)#match interface Loopback 1
R2(config-route-map)#set metric 50
R2(config-route-map)#exit
R2(config)#route-map C-OSPF permit 30
R2(config-route-map)#match interface Loopback 2
R2(config-route-map)#set metric-type type-1
R2(config-route-map)#exit

R2(config)#router ospf 100
R2(config-router)#redistribute connected route-map C-OSPF subnets
R2(config-router)#end
R2#
On Router R1 the routing table has three new entries, marked with E1 and E2:
R1#show ip route
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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.17.0.0/32 is subnetted, 2 subnets
C       172.17.0.1 is directly connected, Loopback0
O E2    172.17.0.2 [110/20] via 192.168.100.2, 00:00:59, Serial1/0
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O E1    10.2.2.0/24 [110/84] via 192.168.100.2, 00:00:59, Serial1/0
O E2    10.1.1.0/25 [110/50] via 192.168.100.2, 00:00:59, Serial1/0
     192.168.100.0/30 is subnetted, 1 subnets
C       192.168.100.0 is directly connected, Serial1/0
172.17.0.2: External type E2 route with metric 20, the default for redistribution
10.1.1.1: External type E2 route with the set metric of 50
10.2.2.2: External type E1 route with metric 20 + 64 = 84.
E2 routes get a metric of 20, if no other value is specified, and keep this metric regardless of the interface costs on their way. E1 routes do add this metric to the starting metric of 20. The 64 comes from the serial line, see the "Cost 64" in the last line.
R1#show ip ospf interface serial 1/0
Serial1/0 is up, line protocol is up
  Internet Address 192.168.100.1/30, Area 0
  Process ID 100, Router ID 172.17.0.1, Network Type POINT_TO_POINT, Cost: 64


Route table before redistribution:

R1#sh ip route
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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.17.0.0/32 is subnetted, 1 subnets
C       172.17.0.1 is directly connected, Loopback0
     192.168.100.0/30 is subnetted, 1 subnets
C       192.168.100.0 is directly connected, Serial2/0





Route table after redistribution:



R1#sh ip route
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
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.17.0.0/32 is subnetted, 2 subnets
C       172.17.0.1 is directly connected, Loopback0
O E2    172.17.0.2 [110/20] via 192.168.100.2, 00:00:01, Serial2/0
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O E1    10.2.2.0/24 [110/84] via 192.168.100.2, 00:00:01, Serial2/0
O E2    10.1.1.0/25 [110/50] via 192.168.100.2, 00:00:01, Serial2/0
     192.168.100.0/30 is subnetted, 1 subnets
C       192.168.100.0 is directly connected, Serial2/0

No comments:

Post a Comment