I am wondering what is the best way to define the router ID for OSPF.
I have read in CISCO books that the preffered way to control router ID is using loopback interface, but isn't it better to hardcode the router ID using the router-id command?
Which one should be a better choice?
What are the disadvantages of using the router-id command?
I have always read the same too. It seams to be a documentation history leftover back when the router-id command was not present (first introduced in IOS 12.2). At those times (and until now) Cisco routers took the ID as the highest loopback address, if none available it would take the highest physical address. The problem with physical addresses as you know is that the they may go down, but a loopback never goes down (if set so) since it's virtual.
Currently, as far as I know, you can use the router-id, just make sure all IDs you give are Unique. You could stick with loopbacks too. This might give more insight: