For a network controller that manages a logical network spanning a plurality of datacenters (205, 210), a method comprising: for each datacenter (205, 210) hosting data compute nodes 'DCNs' belonging to the logical network: defining a centralized routing component for processing data messages between the DCNs hosted at the datacenter (205, 210) and networks external to the logical network; assigning an active instance (520, 525, 530) of the centralized routing component to execute on a first gateway DCN (505, 510, 515) that operates on a first host computer at the datacenter (205, 210); and assigning a standby instance (535, 540, 545) of the centralized routing component to execute on a second gateway DCN (515, 505, 510) that operates on a second host computer at one of the other datacenters (205, 210) spanned by the logical network, wherein the DCNs (125, 135) operate forwarding elements that implement the logical network, the forwarding elements operating on the DCNs (125, 135) at a particular datacenter forwarding data messages to the gateway DCNs (505, 510, 515) on the basis of: i) a first route having a first priority that specifies the active instance of the centralized routing component for the particular datacenter as a next hop, and ii) a second route having a second, lower priority that specifies the standby instance of the centralized routing component for the particular datacenter as a next hop. for each datacenter (205, 210) hosting data compute nodes 'DCNs' belonging to the logical network: defining a centralized routing component for processing data messages between the DCNs hosted at the datacenter (205, 210) and networks external to the logical network; assigning an active instance (520, 525, 530) of the centralized routing component to execute on a first gateway DCN (505, 510, 515) that operates on a first host computer at the datacenter (205, 210); and assigning a standby instance (535, 540, 545) of the centralized routing component to execute on a second gateway DCN (515, 505, 510) that operates on a second host computer at one of the other datacenters (205, 210) spanned by the logical network, defining a centralized routing component for processing data messages between the DCNs hosted at the datacenter (205, 210) and networks external to the logical network; assigning an active instance (520, 525, 530) of the centralized routing component to execute on a first gateway DCN (505, 510, 515) that operates on a first host computer at the datacenter (205, 210); and assigning a standby instance (535, 540, 545) of the centralized routing component to execute on a second gateway DCN (515, 505, 510) that operates on a second host computer at one of the other datacenters (205, 210) spanned by the logical network, wherein the DCNs (125, 135) operate forwarding elements that implement the logical network, the forwarding elements operating on the DCNs (125, 135) at a particular datacenter forwarding data messages to the gateway DCNs (505, 510, 515) on the basis of: i) a first route having a first priority that specifies the active instance of the centralized routing component for the particular datacenter as a next hop, and ii) a second route having a second, lower priority that specifies the standby instance of the centralized routing component for the particular datacenter as a next hop. i) a first route having a first priority that specifies the active instance of the centralized routing component for the particular datacenter as a next hop, and ii) a second route having a second, lower priority that specifies the standby instance of the centralized routing component for the particular datacenter as a next hop.