Abstract The need for efficient routing that can be used to avoid malfunctioning or malicious network known issues, While Mobile Ad-hoc Networks (MANETs) are becoming extremely prevalent and are exploited in various applications, including the application of the Vehicle Ad-hoc Network (VANET), wireless sensor network (WSN) environmental monitoring, and 5G device-to-device (D2D) connectivity. This research presents the Resilience of Mobile Ad hoc Networks to various security attacks and optimizes the routing Process. Moreover, its application to Ant Colony Optimization (ACO), a flippant is implemented, a logic-improved routing algorithm that addresses all such difficulties. To identify the linear nodes of complexity, the distributed fuzzy logic module eliminates them from the Safety Aware Fuzzy Enhanced Ant Colony Optimization (SAFEACO) routing process. The NS-3 simulator follows the SAFEACO routing protocol, and various tests in MANET and VANET scenarios have been carried out. SAFEACO's efficiency is correlated to other innovative and well-known solutions. SAFEACO performs superiorly for each metric of its application, such as the Packet Delivery Ratio (PDR) and the End-to-End delay. SAFEACO also offers greater strength against the black hole, Sybil and inundation attacks due to its ability to classify linear-complexity nodes.