1. A method comprising: determining that a dynamic routing protocol is enabled for a centralized routing component of a logical router; when a router identifier was previously stored for the centralized routing component, assigning the stored router identifier as a router identifier for the centralized routing component only when the stored router identifier matches one of a set of valid addresses for the centralized routing component; and when the centralized routing component does not have a previously stored router identifier that matches one of the set of valid addresses, assigning one of the set of valid addresses as the router identifier for the centralized routing component according to a hierarchy among the set of valid addresses.