In recent years, several industries have registered an impressive improvement in technological advances such as Internet of Things (IoT), e-commerce, vehicular networks, etc. These advances have sparked an increase in the volume of information that gets transmitted from different nodes of a computer network (CN). As a result, it is crucial to safeguard CNs against security threats and intrusions that can compromise the integrity of those systems. In this paper, we propose a machine mearning (ML) intrusion detection system (IDS) in conjunction with the Genetic Algorithm (GA) for feature selection. To assess the effectiveness of the proposed framework, we use the NSL-KDD dataset. Furthermore, we consider the following ML methods in the modelling process: decision tree (DT), support vector machine (SVM), random forest (RF), extra-trees (ET), extreme gradient boosting (XGB), and naïve Bayes (NB). The results demonstrated that using the GA algorithm has a positive impact on the performance of the selected classifiers. Moreover, the results obtained by the proposed ML methods were superior to existing methodologies.