For a network controller that manages a logical network spanning a plurality of datacenters , a method comprising: for each datacenter hosting data compute nodes 'DCNs' (125-140) belonging to the logical network : defining a centralized routing component for processing data messages between the DCNs (125-140) hosted at the datacenter and networks external to the logical network; assigning an active instance of the centralized routing component to execute on a first gateway DCN that operates on a first host computer at the datacenter ; and assigning a standby instance of the centralized routing component to execute on a second gateway DCN that operates on a second host computer at one of the other datacenters spanned by the logical network, wherein the DCNs operate forwarding elements that implement the logical network , the forwarding elements operating on the DCNs at a particular datacenter forwarding data messages to the gateway DCNs 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 hosting data compute nodes 'DCNs' (125-140) belonging to the logical network : defining a centralized routing component for processing data messages between the DCNs (125-140) hosted at the datacenter and networks external to the logical network; assigning an active instance of the centralized routing component to execute on a first gateway DCN that operates on a first host computer at the datacenter ; and assigning a standby instance of the centralized routing component to execute on a second gateway DCN that operates on a second host computer at one of the other datacenters spanned by the logical network, defining a centralized routing component for processing data messages between the DCNs (125-140) hosted at the datacenter and networks external to the logical network; assigning an active instance of the centralized routing component to execute on a first gateway DCN that operates on a first host computer at the datacenter ; and assigning a standby instance of the centralized routing component to execute on a second gateway DCN that operates on a second host computer at one of the other datacenters spanned by the logical network, wherein the DCNs operate forwarding elements that implement the logical network , the forwarding elements operating on the DCNs at a particular datacenter forwarding data messages to the gateway DCNs 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. <EOS>