A method for implementing a logical router in a network, the method comprising: receiving a definition of a logical router of a logical network for implementation by a plurality of network elements, the definition of the logical router comprising specification of a plurality of interfaces for connecting to an external network; defining a plurality of routing components for the logical router, each of the defined routing components comprising a separate set of routes and separate set of logical interfaces, wherein defining the plurality of routing components comprises: defining a distributed routing component that interfaces with other logical forwarding elements (105, 110) of the logical network; and defining at least two centralized routing components (405, 410) to which the plurality of interfaces for connecting with the external network are assigned, each centralized routing component (i) for implementation on a different gateway machine (515, 520) and (ii) comprising at least one interface connecting the centralized routing component (405, 410) to the external network and at least one interface for connecting the centralized routing component (405, 410) to the distributed routing component; and generating data for the implementation of the plurality of routing components of the logical router in the network. receiving a definition of a logical router of a logical network for implementation by a plurality of network elements, the definition of the logical router comprising specification of a plurality of interfaces for connecting to an external network; defining a plurality of routing components for the logical router, each of the defined routing components comprising a separate set of routes and separate set of logical interfaces, wherein defining the plurality of routing components comprises: defining a distributed routing component that interfaces with other logical forwarding elements (105, 110) of the logical network; and defining at least two centralized routing components (405, 410) to which the plurality of interfaces for connecting with the external network are assigned, each centralized routing component (i) for implementation on a different gateway machine (515, 520) and (ii) comprising at least one interface connecting the centralized routing component (405, 410) to the external network and at least one interface for connecting the centralized routing component (405, 410) to the distributed routing component; and defining a distributed routing component that interfaces with other logical forwarding elements (105, 110) of the logical network; and defining at least two centralized routing components (405, 410) to which the plurality of interfaces for connecting with the external network are assigned, each centralized routing component (i) for implementation on a different gateway machine (515, 520) and (ii) comprising at least one interface connecting the centralized routing component (405, 410) to the external network and at least one interface for connecting the centralized routing component (405, 410) to the distributed routing component; and generating data for the implementation of the plurality of routing components of the logical router in the network.