To answer your first question: The most practical and probably widely used method to set an OSPF router priority is to configure a loopback address. This is because the "ospf priority" command is a Cisco-proprietary command and other router-vendors won't honor this. Also, loopback addresses have been around for a much longer than explicitly setting the OSPF priority on Cisco routers/multi-layer switches. Therefore, if you backtrack to previous IOS versions, you'll get to one that doesn't support explicit OSPF priority.

To answer your second question: A Cisco router running OSPF will honor the explicit OSPF priority first, then loopback configuration second, then highest configured IP address third. I'm not sure what you mean by "setup for the sack of DR and BDR election".

I have been labbing on gns3. not sure if this happens on real equipment yet but I have noticed something interesting.

refer to picture. I have 1 router with a loopback 11.11.11.11 connected to another routers e1/0 interface on a broadcast segment. By default it choosees R3 with the 192.168.1.2 router as the DR. If i clear ip ospf process on R1 the same thing happens. I go to clear ip ospf process on R3 and now R1 is DR like i would expect it to be as it has the loopback address.

The reason this happens is R3 started election process without R1 (R3 could come online earlier, or start its ospf process earlier). With no competitors R3 naturally became the DR. Clearing OSPF processes on R1 doesn't make any difference, as there is already a DR on the broadcast segment. So even if R1 had RID of 255.255.255.255, it could not become the DR.

Now when R3 clears its ospf process, the broadcast segment loses its DR and the election starts again. R1 wins it because its ospf process is already on, whereas R3 is only starting it.

Oh, by the way, the loopback address has nothing to do with DR/BDR election. It is used for Router-ID election before the DR/BDR election.

ah yeh thanks i get ya. I enabled the ospf process on R3 and had a look under show ip ospf int e1/0 without enabling ospf on R1 and indeed R3 gets elected DR without anyone else in the picture. makes perfect sense.

Oh yes. so loopback picks the RID before election. I have that down in my notes. I also have that for the DR / BDR election the router with the highest priority wins. If its a tie the router with the highest RID wins. wouldnt this mean the same thing anyway. if loopback on R1 was 11.11.11.11 that it would be the DR seems thats R1's RID now in the case of a tie.

It seems more to me its more dependant on when you press the enter key on who becomes DR and BDR.

I had all the commands in pressed R1 and R3 ospf processes at about the same time. R3 i pressed about 1 sec later which meant R1 was DR. If i did it the opposite R3 was DR etc...

The most logical way to set these DR/BDR routers would be to manually put the router priorities in wouldnt it ? I know the logic behind it now but its a little bit of a gotcha for ccna study people as the books dont really say its dependant on what order and what router you put the commands in first regardless of the highest RID winning.

that is correct i just tested that. if you do the ospf network command a router waits the 40 sec deadtime before announcing itself as DR on a broadcast segment. So this would be the election time period for broadcast

I think I have found a potential snag I have which has been giving me these results.

refer to picture.

I have 2 routers on ethernet. I just want to simplify it to see what's happening first. I have a loopback on R1 which means it should always win the election within the 40 second deadtime period. But my debugs never pick it as the DR. When i press R2 within the election period R2 always wins it.

Its not like its noticing I have a loopback interface on it as its just saying R1 BID 1.1.1.1 which is competing with 192.168.10.2 which is the higher IP. My notes say highest RID wins if priorities arent equal.

would this mean the election is actually doing what it is suppose to do ? because the R2 RID is clearly higher than 1.1.1.1. when i configure another loopback on R1 which is higher than R3.

on the second picture I have the election works fine in any order with R1 always winning which proves I must be missing a point here with the way DR's are chosen. I even put a higher loopback interface on and it always did the election fine

Have I been looking at this in the wrong way. The loopback has to be higher than the physical interface for the DR to be elected. Just by the way its documented in the books i have been reading any old loopback ip wins to be DR regardless of if its a lower IP than the routers it is competing with in the election.

Have I been looking at this in the wrong way. The loopback has to be higher than the physical interface for the DR to be elected. Just by the way its documented in the books i have been reading any old loopback ip wins to be DR regardless of if its a lower IP than the routers it is competing with in the election.

I think you are misinterpreting what you have read.

When OSPF process starts on a router, the Router ID (RID) is chosen.

The router picks the explicitly defined router-id.

If it's not present, it picks the highest loopback address configured on the router.

If one is not present, it picks the highest address on the physical interfaces which are up.

If one is not present, the OSPF process fails to start.

Please note that choosing a RID has nothing to do with a DR/BDR election process!

Now that the OSPF process is started and R1 has the RID of 1.1.1.1, and R2 chose its RID of 192.168.10.2 (as it has no explicit RID configured nor any loopback interfaces), routers start to elect a DR and a BDR on each broadcast (such as Ethernet) or nonbroadcast (such as Frame Relay) segment. Point-to-point and point-to-multipoint segments don't need those.

192.168.10.2 is higher than 1.1.1.1. That's why R2 wins the DR election. It doesn't matter that R2's RID was derived from a physical interface, whereas R1's RID is a loopback address. DR/BDR election process does not care! They are simply RIDs now, the origin has no influence.

The above is true only if election is fair, i.e. both routers started the DR/BDR election at the same time. Now suppose that we have ten routers on an Ethernet segment, and one of them started its OSPF process earlier. It will become the DR and stay in this position as long as it's not reloaded (or OSPF process is cleared, or connectivity problem occurs). In this case, the RIDs don't matter at all: whoever is the first wins. That's what non-preemptive means.

loopback interface has got nothing to with DR/BDR election for DR/BDR election we use Priority for all router's on which you enable OSPF have a priority of 1 this can be changed under the interface by giving the ip ospf priority <> the value can be from <0-255> if the priority is set to 0 the router cant participate election first. If you dont set priority by default the router that boots up first with frist in the network becomes the DR