The invention provides a dual-host floating IP (
Internet Protocol) address master-slave switching method, which belongs to the technical field of communication and comprises the following steps of: detecting whether a local
service process is normal or not; if the local
service process is normal and the
heartbeat message of the opposite-end host is not received overtime, carrying out main-standby switching according to a first preset switching strategy; and if the local
service process is abnormal, carrying out main-standby switching according to a second preset switching strategy. The method has the beneficial effects that main-standby switching is realized by combining the working state of the local service process with a
heartbeat mechanism, and the switching mechanism is simple and does not need to depend on third-party
software; meanwhile, main and standby switching is carried out according to the internal working state of the service process, so that the situation of switching failure caused by process
deadlock, endless loop and the like can be avoided; in addition, the method supports Windows, Linux,
Unix and other operating systems, is wide in application range, supports deployment under a heterogeneous
operating system, is extremely low in resource occupation, is suitable for being deployed in various embedded devices, and is suitable for embedded application scenes needing main and
standby redundancy and meeting
high availability requirements.