Nowadays, networks provide an efficient global connection and serve as the backbone for modern communication and information exchange. Their importance is in facilitating collaboration and sustaining the data flow that is essential for individuals, organizations, and businesses. Therefore, implementing cybersecurity countermeasures is essential for ensuring data availability, integrity, and confidentiality. Therefore, detecting and preventing abnormal behaviors in networks such as Denial-of-Service (DoS) attacks has become crucial. This paper presents a novel optimized intelligent Intrusion Detection System (IDS) for detecting DoS attacks. The proposed model utilizes synergies between the Firefly Algorithm (FA) and the Light Gradient Boosting Machine (LightGBM) model based on the decision tree algorithm to improve its accuracy and efficiency in detecting DoS attacks. However, the firefly algorithm is implemented for optimization and feature selection, thus enhancing the performance of the LightGBM learning model in classification and detecting attacks. The proposed model is developed and tested using the NSL-KDD dataset to validate its efficiency. The experimental results from the proposed model prove its utility and feasibility. Compared to the state of art, the proposed model achieves an average accuracy up to 99.3%.