A method for implementing communication between virtual machines, applied to a system comprising at least a first virtual machine and a second virtual machine, wherein the first virtual machine is located in a first subnet of a first data center and communicates with a first switch, and the second virtual machine is located in a second subnet and communicates with a second switch located in a second data center, wherein a Media Access Control, MAC, address of a gateway of the first subnet in the first data center and a MAC address of a gateway of the first subnet in the second data center are the same and an IP address of the gateway of the first subnet in the first data center and an IP address of the gateway of the first subnet in the second data center are the same; the method comprises: receiving, by the first switch, an Address Resolution Protocol, ARP, request from the first virtual machine, wherein the ARP request carries an IP address of a destination gateway; forwarding, by the first switch, the ARP request to a software defined network, SDN, controller of the first data center; receiving, by the first switch, an ARP response from the SDN controller, wherein the ARP response carries a MAC address of the destination gateway; acquiring, by the first switch according to the MAC address of the destination gateway, virtual extensible local area network tunnel end point, VTEP, information corresponding to the MAC address of the destination gateway, wherein a router corresponding to the VTEP information is located in the first data center; and sending, by the first switch according to the VTEP information, an IP packet to the router corresponding to the VTEP information, so that the router corresponding to the VTEP information sends the IP packet to the second virtual machine through a tunnel between the router and the second switch; wherein the acquiring, by the first switch according to the MAC address of the destination gateway, VTEP information corresponding to the MAC address of the destination gateway comprises: sending, by the first switch, a request to the SDN controller to request to acquire the VTEP information corresponding to the MAC address of the destination gateway; and when the SDN controller queries the locally stored flow table according to the MAC address of the destination gateway and acquires two or more pieces of VTEP information, using VTEP information of the router located in the first data center as the VTEP information corresponding to the MAC address of the destination gateway; receiving the VTEP information that is acquired by the SDN controller and is corresponding to the MAC address of the destination gateway. receiving, by the first switch, an Address Resolution Protocol, ARP, request from the first virtual machine, wherein the ARP request carries an IP address of a destination gateway; forwarding, by the first switch, the ARP request to a software defined network, SDN, controller of the first data center; receiving, by the first switch, an ARP response from the SDN controller, wherein the ARP response carries a MAC address of the destination gateway; acquiring, by the first switch according to the MAC address of the destination gateway, virtual extensible local area network tunnel end point, VTEP, information corresponding to the MAC address of the destination gateway, wherein a router corresponding to the VTEP information is located in the first data center; and sending, by the first switch according to the VTEP information, an IP packet to the router corresponding to the VTEP information, so that the router corresponding to the VTEP information sends the IP packet to the second virtual machine through a tunnel between the router and the second switch; wherein the acquiring, by the first switch according to the MAC address of the destination gateway, VTEP information corresponding to the MAC address of the destination gateway comprises: sending, by the first switch, a request to the SDN controller to request to acquire the VTEP information corresponding to the MAC address of the destination gateway; and when the SDN controller queries the locally stored flow table according to the MAC address of the destination gateway and acquires two or more pieces of VTEP information, using VTEP information of the router located in the first data center as the VTEP information corresponding to the MAC address of the destination gateway; receiving the VTEP information that is acquired by the SDN controller and is corresponding to the MAC address of the destination gateway. sending, by the first switch, a request to the SDN controller to request to acquire the VTEP information corresponding to the MAC address of the destination gateway; and when the SDN controller queries the locally stored flow table according to the MAC address of the destination gateway and acquires two or more pieces of VTEP information, using VTEP information of the router located in the first data center as the VTEP information corresponding to the MAC address of the destination gateway; receiving the VTEP information that is acquired by the SDN controller and is corresponding to the MAC address of the destination gateway.