A method for implementing a logical router in a network, the method comprising: receiving a definition of a logical router to serve as an interface between a logical first network and a second network external to the logical first network, the logical router for processing packets exchanged between the first and second networks (100, 120); wherein the definition of the logical router comprises specifications of a plurality of routing components (405, 410, 415) to implement the logical router, the plurality of routing components (405, 410, 415) comprising: - a distributed routing component to be implemented on a first plurality of computers (505, 515, 520), and - a plurality of centralized routing components (405, 410) to be implemented on a second plurality of computers (515, 520) that comprises a subset of the first plurality of computers (505, 515, 520) but not all of the first plurality of computers (505, 515, 520), wherein the centralized routing components (405, 410) forward northbound packet flows from the logical first network to the second network and forward southbound packet flows from the second network to the logical first network, and wherein the distributed routing component routes east-west packets within the logical first network and southbound and northbound packets to and from the centralized routing components (405, 410); and generating and distributing data for configuring the first and second pluralities of computers (505, 515, 520) to implement the distributed routing component and the centralized routing components (405, 410). receiving a definition of a logical router to serve as an interface between a logical first network and a second network external to the logical first network, the logical router for processing packets exchanged between the first and second networks (100, 120); wherein the definition of the logical router comprises specifications of a plurality of routing components (405, 410, 415) to implement the logical router, the plurality of routing components (405, 410, 415) comprising: - a distributed routing component to be implemented on a first plurality of computers (505, 515, 520), and - a plurality of centralized routing components (405, 410) to be implemented on a second plurality of computers (515, 520) that comprises a subset of the first plurality of computers (505, 515, 520) but not all of the first plurality of computers (505, 515, 520), - a distributed routing component to be implemented on a first plurality of computers (505, 515, 520), and - a plurality of centralized routing components (405, 410) to be implemented on a second plurality of computers (515, 520) that comprises a subset of the first plurality of computers (505, 515, 520) but not all of the first plurality of computers (505, 515, 520), wherein the centralized routing components (405, 410) forward northbound packet flows from the logical first network to the second network and forward southbound packet flows from the second network to the logical first network, and wherein the distributed routing component routes east-west packets within the logical first network and southbound and northbound packets to and from the centralized routing components (405, 410); and generating and distributing data for configuring the first and second pluralities of computers (505, 515, 520) to implement the distributed routing component and the centralized routing components (405, 410).