weird ospf DR election oddity

mattaumattau Member Posts: 218
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 chooses R3 with the 192.168.1.2 router as the DR. ( not what id expect given loopback addresses have first pick for priority for 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.

Is there a reason for this ? It seems like a timing thing. what ever router you configure first has the DR. I will have to try on real equipment to double check but gns3 is pretty good..

many thanks
_____________________________________
CCNP ROUTE - passed 20/3/12
CCNP SWITCH - passed 25/10/12
CCNP TSHOOT - passed 11/12/12




Comments

  • mattaumattau Member Posts: 218
    actually i think i worked it out. It is dependent of what order the routers are turned on, as once the election occurs when the next router comes online it wont automatically update the DR/BDR like spanning tree does to the root bridge.

    I am still a tad confused though at the very beginning when i first configure the ospf network commands why the 2 routers cant pick the correct DR when they exchange this info in the hello packets.

    if there are only 2 routers like I have they should be able to choose the correct DR/BDR everytime?

    I get if I shutdown a router after the election has occured and bring it back up it will come back as a BDR if it was originally a DR as the other router would take over as DR
    _____________________________________
    CCNP ROUTE - passed 20/3/12
    CCNP SWITCH - passed 25/10/12
    CCNP TSHOOT - passed 11/12/12




  • networker050184networker050184 Mod Posts: 11,962 Mod
    Turn on the OSPF debugs and you can watch the DR elections. This will show you the whole process so there is no guessing involved. You might also want to check that the Loopback is actually being chosen as the router ID.
    An expert is a man who has made all the mistakes which can be made.
  • mattaumattau Member Posts: 218
    i have been talking to someone about it. I had a look at the debugs and the loopback RID is fine.

    my study notes have it as the DR/BDR election - the router with highest priority on a given segment is elected DR, if there is a tie the highest RID router wins and second becomes BDR.

    It seems more dependent on when you actually press the enter button to enable the ospf. For example

    I enable the ospf network command on R1 first = it becomes DR no matter what ip address and loopbacks it has.

    R2 will then be BDR.

    Apparently when you enable the ospf network command the router that did it first becomes the DR and then the second router you enable it becomes the BDR no matter what. The only way you can change the DR from there is to clear the ospf processes on the router you enabled the ospf network command on first.

    I have double checked this under the show ip ospf interface command and it does make sense seems when you enable the second router the DR is already elected which means it wont force a re - election when it comes back online.


    although I am a tad confused why there is no swapping of election data in the first place seems thats what all the books say..

    I am using gns3 so maybe its an issue. I will try on real equipment later i think.
    _____________________________________
    CCNP ROUTE - passed 20/3/12
    CCNP SWITCH - passed 25/10/12
    CCNP TSHOOT - passed 11/12/12




  • vinbuckvinbuck Member Posts: 785 ■■■■□□□□□□
    If you use the ip ospf priority 0-255 command on an interface, you can set the which routers get to be the DR/BDR - or if you use ip ospf priority 0, that router will never be a DR or BDR. In real world operations, this is usually how it is done. Some choose to use their IP scheme to sort out the DR/BDR election, but the priority is simpler and you don't have to worry about an unintentional change in DR/BDR if an IP pops up that you aren't expecting.
    Cisco was my first networking love, but my "other" router is a Mikrotik...
  • networker050184networker050184 Mod Posts: 11,962 Mod
    There is an election, but the router only waits a certain amount of time before declaring itself the DR. I can't remember the exact time, but if you watch the debugs you can see when the waiting expires. Once a router is declared the DR there is no election unless that router goes offline.
    An expert is a man who has made all the mistakes which can be made.
  • APAAPA Member Posts: 959
    If the OSPF routers, OSPF enabled interface is already in an 'Up' state then when it sends the first hellos, it will realize that no other neighbours exist, thus it becomes the elected DR.

    Therefore when the second router comes online... even if it has a higher priority, it learns that a DR has already been elected as the hellos between the first router and it will express this, therefore it becomes the BDR due to there being no pre-emption in OSPF.

    So theoretically timing at power on can have a 'unknown' part in DR election, on a multiaccess segment hellos are sent every 10 secs with a dead interval of four times the hello timer. When the first router sends a hello out, it sets the DR and BDR address to 0.0.0.0 and at the same time sets the 'wait interval' which is typically the default dead interval (four times the hello timer) before it declares itself as the DR for the segment.

    Obviously if the router doesn't have any 'active' interfaces to participate in OSPF then the election would not happen....

    CCNA | CCNA:Security | CCNP | CCIP
    JNCIA:JUNOS | JNCIA:EX | JNCIS:ENT | JNCIS:SEC
    JNCIS:SP | JNCIP:SP
  • mattaumattau Member Posts: 218
    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.
    _____________________________________
    CCNP ROUTE - passed 20/3/12
    CCNP SWITCH - passed 25/10/12
    CCNP TSHOOT - passed 11/12/12




  • networker050184networker050184 Mod Posts: 11,962 Mod
    So are you sure the RID is actually the loopback? Just putting a new loopback doesn't make the RID update automatically.

    EDIT: Just looked at your picture. If R2 doesn't have a loopback its going to use the the interface IP for its RID. 192.168.10.2 > 1.1.1.1 which is why it wins the election.
    An expert is a man who has made all the mistakes which can be made.
  • vinbuckvinbuck Member Posts: 785 ■■■■□□□□□□
    Are you trying to learn how OSPF DR/BDR Election works? If that's your endgame, then by all means go for it...but if you're just trying to resolve issues in your lab, I would enable ip ospf network point-to-point on your router to router interfaces and do away with the DR/BDR election. It isn't really needed unless you have multiple routers in the same subnet all connected to each other and part of OSPF.

    I've seen an entire service provider core network go down because of DR/BDR issues....it's a fun one to troubleshoot icon_smile.gif
    Cisco was my first networking love, but my "other" router is a Mikrotik...
  • mattaumattau Member Posts: 218
    i was trying to understand how the election works. sorry its all good i understand it now. I was just getting mixed up on not having everyone on loopbacks to give them an appropriate RID, vs having mixed physical interfaces + loopbacks trying to work together which clearly wont work as I have displayed :)

    Thanks
    _____________________________________
    CCNP ROUTE - passed 20/3/12
    CCNP SWITCH - passed 25/10/12
    CCNP TSHOOT - passed 11/12/12




  • networker050184networker050184 Mod Posts: 11,962 Mod
    mattau wrote: »
    i was trying to understand how the election works. sorry its all good i understand it now. I was just getting mixed up on not having everyone on loopbacks to give them an appropriate RID, vs having mixed physical interfaces + loopbacks trying to work together which clearly wont work as I have displayed :)

    Thanks


    What do you mean it doesn't work? Its working as designed from what you are saying. The router with the highest RID is winning the election which is whats supposed to happen.
    An expert is a man who has made all the mistakes which can be made.
  • hermeszdatahermeszdata Member Posts: 225
    What do you mean it doesn't work? Its working as designed from what you are saying. The router with the highest RID is winning the election which is whats supposed to happen.

    and to expound a little further (this was mentioned in another post)

    a device's RID is either:
    The highest Loopback Address
    or
    the Highest IP adress assigned to an interface on the router.

    Nothing in the DR/BDR specs state that a Loopback IP address based RID will be chosen as DR over an interface IP address based RID. The DR is chosen by the highest RID regardless of whether the RID is loopback or Interface based.
    John
    Current Progress:
    Studying:
    CCNA Security - 60%, CCNA Wireless - 80%, ROUTE - 10% (Way behind due to major Wireless Project)
    Exams Passed:
    CCNA - 640-802 - 17 Jan 2011 -- CVOICE v6 - 642-436 - 28 Feb 2011
    2011 Goals
    CCNP/CCNP:Voice
  • mattaumattau Member Posts: 218
    and to expound a little further (this was mentioned in another post)

    a device's RID is either:
    The highest Loopback Address
    or
    the Highest IP adress assigned to an interface on the router.

    Nothing in the DR/BDR specs state that a Loopback IP address based RID will be chosen as DR over an interface IP address based RID. The DR is chosen by the highest RID regardless of whether the RID is loopback or Interface based.

    thanks for clearing that up. this is what i was getting confused on. understood now though.
    _____________________________________
    CCNP ROUTE - passed 20/3/12
    CCNP SWITCH - passed 25/10/12
    CCNP TSHOOT - passed 11/12/12




  • APAAPA Member Posts: 959
    The RID only comes into play for DR/BDR elections if you have routers with equal priority... so thus it becomes a tie-breaker.

    Honestly though... if you were architecting a multi-access OSPF segment and you were leaving the DR/BDR election up to a tie-breaker.... I would be asking questions.... :/

    CCNA | CCNA:Security | CCNP | CCIP
    JNCIA:JUNOS | JNCIA:EX | JNCIS:ENT | JNCIS:SEC
    JNCIS:SP | JNCIP:SP
Sign In or Register to comment.