Command
Distance OSPF
Use
This command changes the administrative distance for OSPF routes.
Syntax
Router(config-router)#distanceospf
Example

In this example, we will change OSPF administrative distance to 150 for internal routes and 220 for external. Currently, we see OSPF is at its default administrative distance of 110.
Copy
R1(config-router)#do show ip route ospf
33.0.0.0/32 is subnetted, 1 subnets
O 33.33.33.33 [110/65] via 192.168.13.2, 00:01:05, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/65] via 192.168.13.2, 00:01:05, Serial1/1
10.0.0.0/24 is subnetted, 3 subnets
O 10.2.2.0 [110/65] via 192.168.13.2, 00:01:05, Serial1/1
133.133.0.0/32 is subnetted, 1 subnets
O 133.133.133.133 [110/65] via 192.168.13.2, 00:01:05, Serial1/1
Here, we change the distance with thedistance ospf command.
Copy
R1(config)#router ospf 1
R1(config-router)#distance ospf intra-area 150 inter
R1(config-router)#distance ospf intra-area 150 inter-area 150 ex
R1(config-router)#distance ospf intra-area 150 inter-area 150 external 220
R1(config-router)#exit
Now, we can see the change is reflected in the routing table.
Copy
R1(config)#do show ip route ospf
33.0.0.0/32 is subnetted, 1 subnets
O 33.33.33.33 [150/65] via 192.168.13.2, 00:00:06, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [150/65] via 192.168.13.2, 00:00:06, Serial1/1
10.0.0.0/24 is subnetted, 3 subnets
O 10.2.2.0 [150/65] via 192.168.13.2, 00:00:06, Serial1/1
133.133.0.0/32 is subnetted, 1 subnets
O 133.133.133.133 [150/65] via 192.168.13.2, 00:00:06, Serial1/1