EIGRP
The EIGRP RID is a 32-bit number in dotted decimal format. In EIGRP, duplicate RIDs do not prevent routers from becoming neighbors and two EIGRP routers with the same router ID will still form a neighbor relationship. The only time the value of EIGRP RIDs consider is when injecting external (redistributed) routes into EIGRP. In this case, the routers injecting the external routes should have unique RIDs to avoid confusion.
To manually configures the router ID
R1(config)# router eigrp 10
R1(config-router)# eigrp router-id 1.1.1.1
OSPF
Every OSPF router within the network will have a 32-bit number router ID that uniquely identifies it to the other routers on the network. Unlike EIGRP, OSPF prevents neighborships between routers with duplicate RIDs. All OSPF RIDs in a domain should be unique. OSPF Router ID should not be changed after the OSPF process is started and the OSPF neighborships are established. If you change the OSPF router ID, we need to either reload the IOS or use "clear ip ospf process" command (restart the OSPF process) for changed RID to take effect.
To manually configure the router ID
R1(config)# router ospf 5
R1(config-router)# router-id 5.5.5.5
BGP
Like OSPF, BGP also prevents neighborship between routers with same router ID. The BGP router IDs of the two routers should not be same. Router ID also acts as a tie-breaker for BGP path selection. If all other attributes (weight, local preference, origin, AS path etc) till router ID are equal then the decision is made based on lowest router ID.
To manually configure the router ID
R1(config)# router bgp 100
R1(config-router)# bgp router-id 9.9.9.9
In all of the above routing protocols, the Router ID is determined according to the following general rules -
Step 1. Use the router ID defined in the router-id x.x.x.x OSPF router subcommand.
Step 2. Use the highest IP address of any up loopback interface.
Step 3. Use the highest IP address of any up physical interface.