1. A non-transitory machine readable medium storing a program which when executed by at least one processing unit configures first and second managed forwarding elements to perform logical L2 switching and L3 routing, the program comprising sets of instructions for: generating a first set of flow entries for configuring the first managed forwarding element to perform (i) a first logical L2 processing for a first logical L2 domain, (ii) a logical L3 processing, (iii) a network address translation (NAT) processing on packets to be sent to the second managed forwarding element, and (iv) a logical ingress L2 processing for a second logical L2 domain on the packets; and generating a second set of flow entries for configuring the second managed forwarding element to perform a logical egress L2 processing for the second logical L2 domain on the packets.