Nowadays it is very important to provide a high level of security for huge amount of information transferred in the network to protect them from threats. Due to that, an intrusion detection system (IDS) becomes a required component in terms of computer and network security. One of the biggest challenges for IDS is the high dimensionality of the feature space and how to select the relevant features to distinguish normalpacket traffic from attack packet traffics.In this paper, an optimization model based on genetic algorithm (GA) toselect the distinguished features is proposed. Moreover, the Naïve Bayes (NB) classifier is applied to judge the ability of the proposed modelto classify normal and attack traffics. The performance of the proposed model is evaluated against the well-known feature selection algorithm, namely,information gain algorithm. The experiments on NSL-KDD benchmark dataset reveal the effectiveness of the proposed model to detect attack and normal traffics.