In link state protocols each participating router knows the whole topology of a network, which is stored in the link state database. Using the link state database each router will calculate the best path to the destination. The easiest way to think about it is as if with a link state routing protocol is that you give all your friends a map (the LSDB) and you tell them to find the shortest path based on mileage (bandwidth in the case of OSPF, not 100% about ISIS) to a given city. As long as you all follow the map and the formula, you don't really need to worry about loops.
According to your first question, the answer is not as easy as you might think.
When there are multiple routing protocols configured, all of them will run and form adjacencies to their next hop routers and exchange routing information. Most if not each routing protocol has a routing protocol specific information database, containing routes exchanged by this routing protocol. On cisco gear you can view them for example with sh ip ospf database
or sh ip rip database
.
Now, the router has to decide which routes are placed in his actual routing information base (also called RIB or routing table). Here, the most important factor is the "precision" of a route. That is: the higher the prefix length is, the more exact is the route and the more preferred. Only if there are two identical routes, that is same subnet address and same subnet mask or prefix length, the administrative distance comes into play.
Suppose the following example (note that ADs are default values from Cisco):
- 192.168.100.0/24 learned by OSPF, AD is 110
- 192.168.100.128/25 learned by RIP, AD is 120
- 192.168.200.0/24 directly connected, AD is 0
- 192.168.200.0/24 static route, AD is 1
In this example, the first route learned by OSPF will be placed in the routing table. As the second one is more specific (25 bit prefix instead of 24) it is also added to the routing table. Note that while the second route is included in the first one, they are not equal due to the different prefix length. The third and fourth routes are identical, but the AD of directly connected routes is always 0 and hence this route is preferred.
So basically you can influence routing decision in at least three ways:
- In each routing protocol, you can tweak metrics
- Change the AD of routing protocols
- Advertise more specific routes which are always preferred.
Changing the AD
For Cisco gear, you can change the AD of routing protocols like this:
! static routes - the last optional value (50) is the AD
ip route 192.168.100.0 255.255.255.0 1.2.3.4 50
! OSPF - can be changed in the OSPF routing process, is slightly more complicated
! The generic command is: distance <AD> <source addr> <wildcard-mask> <ACL>
! AD is configured per source router, and an additional ACL is required
! To change AD of all routes to 85 (instead of default 110)
access-list 10 permit any
router ospf 1
distance 85 0.0.0.0 255.255.255.255 10
! RIP
! For RIP, the command is:
! distance admin-distance [ prefix prefix-length | prefix mask ]
! The command needs to be entered inside the routing process, where the last
! elements are not required but can be used to conditionally change the distance
router rip
distance 50
Beware that you can never change the AD to be lower than or equal to 0, hence routing protocols cannot compete with directly connected routes using the administrative distance. If you need a routing protocol to override directly connected routes you should ask yourself why you need the direct connection. Technically however you could advertise more specific routes.
Best Answer
Distributed Bellman-Ford (BF) and Dijkstra work in opposite directions: BF builds path starting at the source of the routing information (the data sink), while Dijkstra starts at the data sender.
Since distance vector protocols work incrementally starting at the source, they cannot use Dijkstra, and hence use distributed BF. There is nothing in principle that would prevent a link-state protocol from using BF, but (non-distributed) BF has cubic complexity, while Dijkstra (if implemented correctly) is O(n² log n).
(Because of the different directions, BF and Dijkstra will build different paths with some very weird metrics — metrics that fail Sobrinho's isotonicity condition —, but the difference is unlikely to be relevant in practice.)