With the emergence of the Internet of Things (IoT) and the Industrial Internet of Things (IIoT), the flow of data across the world is experiencing a rapid expansion. Unfortunately, this exponential growth is accompanied by a proportional increase in cyber threats, jeopardizing the security and integrity of computer systems. In this context, intrusion detection becomes a necessity to protect networks and systems against potential attacks, ensuring their proper functioning and reliability. In this paper, we propose a deep learning-based model for attack detection. This model utilizes a convolutional neural network to train the datasets, which are first cleaned and preprocessed. The model inputs are selected using an optimization method called adaptive large neighborhood search. The results obtained for the four datasets used - CICIDS2017, Edge-IIoTset, ToN-IoT windows7, and ToN-IoT windows10 - demonstrate the model’s effectiveness for both multi-class and binary classification cases. In the binary case, the accuracy reaches 99.85%, 100%, 99.97%, and 100%, respectively, and in the multi-class case, it stands at 99.81%, 94.98%, 99.92%, and 99.84%, respectively.