Routing protocols are used to discover routes to a destination. Only one routing protocol at one time determines the optimal route to a destination.
What happens if we have different routes to the same destination learnt by different routing protocols?
When multiple routing information sources coexist on the same router, the router with the highest preference is selected as the optimal route.
Below you can find the default route preferences by each routing protocol (the smaller the value, the higher the preference is):
Of course you can change these default values manually.
But what happens if different routing protocols are configured with the same preference?
Huawei routers define external and internal preferences. Default external preferences are showed in the above table and can be set manually by users, whereas internal preferences are fixed and cannot be changed. For example, two routes, static and OSPF, which have the same route preference 5, set by command, can reach the destination 2.2.2.2/32. According to the internal preferences listed below, route discovered by OSPF will be selected as an optimal route:
# interface Ethernet0/0/0 undo shutdown ip address 10.0.0.1 255.255.255.252 # interface LoopBack0 ip address 1.1.1.1 255.255.255.255 # ip route-static 2.2.2.2 255.255.255.255 10.0.0.2 preference 5 # ospf 1 preference 5 area 0.0.0.0 network 1.1.1.1 0.0.0.0 network 10.0.0.0 0.0.0.3 [labnario]display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 6 Routes : 6 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0 2.2.2.2/32 OSPF 5 1 D 10.0.0.2 Ethernet0/0/0 10.0.0.0/30 Direct 0 0 D 10.0.0.1 Ethernet0/0/0 10.0.0.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0