Internet usage became increasingly ubiquitous. The concern regarding security and privacy has become essential for Internet users. As the usage of the Internet increases the number of cyber-attacks also increases substantially. Intrusion detection is one of the challenging aspects of network security. Efficient intrusion detection is crucial for every organization to mitigate the vulnerability. This paper presents a novel intrusion detection system to detect malicious attacks targeted at a smart environment. The proposed Intrusion detection method uses a correlation tool and a random forest method to detect the predominant independent variables for improvising neural-based attack classifier. To detect a malicious attack, a shallow neural network and an optimized neural-based classifier are presented. The designed intrusion detection system has experimented on the KDDCUP99 dataset. The experimental results reveal that the performance of the proposed intrusion detection system is superior in terms of quantitative metrics. Thus, the proposed system can be deployed in the IoT and wireless networks to detect cyber-attacks. © 2021 John Wiley & Sons, Ltd.