The number of illegal intruders is growing at the same rate as the number of computer networks and the amount of data on those networks. They try to steal important and private information from the network about its users. An intrusion detection system (IDS) blocks all malicious or unauthorized activity from a computer network. However, it is important to detect illegal activity as early as possible; otherwise, attackers might access all the resources of the system. So, an effective and efficient IDS can be very useful for that. In this paper, we propose an ensemble learning method based on a voting classifier technique for detecting intrusion into a system. We have used the NSL-KDD dataset for our study. First, we preprocess the dataset. Then we implemented different machine learning algorithms. Based on the results, the Extra Trees Classifier, Decision Tree, and Random Forest algorithms achieved the highest accuracy scores of 98.68%, 98.58%, and 98.70% respectively. In the next step, we applied voting classifier techniques using these top three models, and we achieved an accuracy of 98.73% which indicates that this method can effectively increase the performance of the models. Finally, we have evaluated our models using different performance evaluation metrics.