OSPF network vs redistribute

Announcing networks in OSPF can be done in 2 ways:

  • Using the “network X.X.X Y.Y.Y.Y area Z” command, where X.X.X.X is the network, Y.Y.Y.Y is the wildcard mask (inverse of the subnet mask) and Z is the area ID
  • Using redisitribute

We’ll show the difference using 2 Cisco IOS routes in GNS3. More info about GNS3 can be found in this post.

Example

In this example, R1 and R2 are OSPF neighbours. They have their interfaces configured as following:

R1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.0.1     YES NVRAM  up                    up
Loopback0                  10.0.0.1        YES NVRAM  up                    up


R2#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
Ethernet0/0                192.168.0.2     YES NVRAM  up                    up
Loopback0                  10.0.1.1        YES NVRAM  up                    up

Suppose we want to announce the directly connected routes (the loopback interface) in OSPF, so the neighbour can reach the remote loopback interface. We’ll use the network command to announce Lo0 on R1, and we’ll use the redistribute command to announce Lo0 on R2:

R1#conf t
R1(config)#router ospf 1
R1(config-router)#router-id 192.168.0.1
R1(config-router)#network 10.0.0.1 0.0.0.0 area 0
R1(config-router)#network 192.168.0.0 0.0.0.3 area 0

R2#conf t
R2(config)#router ospf 1
R2(config-router)#router-id 192.168.0.1
R2(config-router)#network 192.168.0.0 0.0.0.3 area 0
R2(config-router)#redistribute connected

Let’s check the results:

R1#show ip route 10.0.1.1
Routing entry for 10.0.1.1/32
  Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
  Last update from 192.168.0.2 on Ethernet0/0, 00:01:44 ago
  Routing Descriptor Blocks:
  * 192.168.0.2, from 192.168.0.2, 00:01:44 ago, via Ethernet0/0
      Route metric is 20, traffic share count is 1


R2#show ip route 10.0.0.1
Routing entry for 10.0.0.1/32
  Known via "ospf 1", distance 110, metric 11, type intra area
  Last update from 192.168.0.1 on Ethernet0/0, 00:00:09 ago
  Routing Descriptor Blocks:
  * 192.168.0.1, from 192.168.0.1, 00:00:09 ago, via Ethernet0/0
      Route metric is 11, traffic share count is 1

As you can see, R1 announces 10.0.0.1 as an OSPF intra area route, due to the “network” command. R2 announces it’s 10.0.1.1 as OSPF external type 2, due to the redistribute.

Leave a Reply

Your email address will not be published. Required fields are marked *