OSPF - distance command

The distance command in OSPF is used to set the Administrative Distance (AD) within the OSPF process. The command is issued under the OSPF configuration mode.

It is possible to specify only an AD value like so:

R1(config)#router ospf 1 R1(config-router)#distance 90

The result is that all routes received from OSPF neighbors or redistributed into OSPF wlil have an AD of 90 assigned to them, but only if an explicit AD has not been set for a particular routing information source.

Alternatively, you can add a specific set of addresses like so:

R1(config)#router ospf 1 R1(config-router)#distance 90 10.10.0.0 0.0.255.255

In such a case, all routes received that match the particular range will be given an AD of 90.

In addition, you can add an access list like so:

R1(config)#router ospf 1 R1(config-router)#distance 90 10.10.0.0 0.0.255.255 My_Access_list

where My_Access_list can define the IP address of the router that is supplying the routing information.

Links:

https://forum.networklessons.com/t/troubleshooting-metric-redistribution/1171/23?u=lagapidis

https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/iproute_ospf/command/iro-cr-book/ospf-a1.html#wp3839574706