Consensus is an emerging technique using neighbor-to-neighbor interaction to generate steering commands for cooperative control of multiple vehicles. A three-dimensional formation keeping strategy for multiple unmanned aerial vehicles (multi-UAV) is proposed based on consensus, aiming at maintaining a specified geometric configuration. A formation control algorithm with guidance and corresponding flight controllers is given, managing position and attitude, respectively. In order to follow a three-dimensional predefined flight path, by introducing the tracking orders as reference states into the consensus, the formation control algorithm is designed, following the predefined flight path and maintaining geometric configuration simultaneously. The flight controllers are constructed by nonlinear dynamic inverse, including attitude design and velocity design. With the whole system composed of a nonlinear six-degree-of-freedom UAV model, the formation control algorithm and the flight controllers, the formation keeping strategy is closed loop and with full states. In simulation, three-dimensional formation flight demonstrates the feasibility and effectiveness of the proposed strategy.