Hello Martin.
Take a look at this topology:
Each router is connected to the multi-access segment and is advertising a loopback IP that is relevant to their router number (for ex: R1 - 1.1.1.1/32).
R1#show ip route ospf | begin Gateway
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 192.168.1.2, 00:00:44, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 192.168.1.3, 00:00:34, GigabitEthernet0/0
R1#
We can see that the default OSPF AD is 110. We can change the AD by using the distance command.
R1(config)#router ospf 1
R1(config-router)#distance 111
R1(config-router)#do show ip route ospf | begin Gateway
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [111/2] via 192.168.1.2, 00:00:43, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [111/2] via 192.168.1.3, 00:00:43, GigabitEthernet0/0
R1(config-router)#
Now the AD is set to 111 for all routes. What you can optionally enter is the router for whose routes you want to change the AD. For example,
R1(config-router)#distance 55 2.2.2.2 0.0.0.0
R1(config-router)#do show ip route ospf | begin Gateway
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [55/2] via 192.168.1.2, 00:00:09, GigabitEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 192.168.1.3, 00:00:09, GigabitEthernet0/0
R1(config-router)#
distance 55 2.2.2.2 0.0.0.0
will set the AD to 55 for any routes advertised by R2 (you enter the RID of the router here). You can also specify and modify the wildcard mask to match more routers, it’s like general OSPF network/ACL logic.
So what Rene’s example is saying is:
Set the AD to 255
distance 255
For any neighbor/any router that advertises the network
0.0.0.0 255.255.255.255
But only for networks matched by LOOPBACK_R1
LOOPBACK_R1
distance 255 0.0.0.0 255.255.255.255 LOOPBACK_R1
If you need any further help, let me know.
David