Routing optimization for FANETs is a kind of NP-hard in the field of combinatorial optimization that describes simple and difficult to handle. The quality of routing has a direct impact on the network quality of FANETs, and the design of routing protocols becomes a very challenging topic in FANETs. In this paper, we study the characteristics of dynamic routing, combine the characteristics of FANETs themselves, use the energy of nodes, bandwidth, link stability, etc. as the metric of routing, and use Boltzmann machine for routing search to form an optimized dynamic routing protocol. The NS3 simulation simulator is used to compare and study with traditional MANET dynamic routing AODV and DSR, and the simulation results show that the routes obtained by using Boltzmann machine search are better than AODV and DSR in many aspects such as end-to-end average delay, average route survival time and control overhead.