In order to resolve the issues with Intrusion Detection Systems (IDS), a preprocessing step known as feature selection is utilized. The main objectives of this step are to enhance the accuracy of classification, improve the clustering operation on imbalance dataset and reduce the storage space required. During feature selection, a subset of pertinent and non-duplicative features is chosen from the original set. In this paper, a novel approach for feature selection in intrusion detection is introduced, leveraging an enhanced k-means clustering algorithm. The clustering operation is further improved using the combination of Gravity Search Algorithm (GSA) and Particle Swarm Optimization (PSO) techniques. Additionally, Biogeography Based Optimization (BBO) technique known for its successful performance in addressing classification problems is also employed. To evaluate the proposed approach, it is tested on the UNSW-NB15 intrusion detection dataset. Finally, a comparative analysis is conducted, and the results demonstrate the effectiveness of the proposed approach, in such a way that the value of the detection accuracy parameter in the proposed method was 99.8% and in other methods it was a maximum of 99.2%.