The invention relates to a method for redirecting
network connection of a
virtual machine when being transferred across subnets online, including the steps that: 1, the
virtual machine is transferred from a first subnet to a second subnet; 2, a
foreign agent arranged in the second subnet sends a registration request to a home agent in the first subnet; 3, after receiving the registration request, the home agent builds a bidirectional
data transmission tunnel between the home agent and the
foreign agent; 4, the data to be sent to the
virtual machine by a communication counterpart terminal is first sent to the home agent and then is sent to the
foreign agent by the home agent through the bidirectional
data transmission tunnel, and the foreign agent sends the received data to the virtual
machine. The method is unnecessary to change the
operating system of the virtual
machine, can ensure the transparency to the virtual
machine in the network redirection process when transferring the virtual machine across the subnets, and can overcome the defect in prior art that data is forwarded between the communication counterpart terminal and the virtual machine through a source host, which leads to the increase of the load of the source host.