The Internet of Things (IoT) is connecting more devices every day. Security is critical to ensure that the devices operate in a trusted environment. The lack of proper IoT security encourages cybercriminals to target many smart devices across the network and gain sensitive information. Distributed Denial of Service (DDoS) attacks are common in the IoT infrastructure and involve hijacking IoT devices to consume resources and interrupt services. This may specifically vandalize the application running the service that the end users are trying to access (application layer DDoS attacks) or flood the network bandwidth leading to network failure (software defined network DDoS attacks). This article proposes a hybrid attention‐based bidirectional long short term memory (LSTM) with convolutional neural networks (CNN) to identify DDoS attacks in the application layer and SDN. We deploy several other machine learning models like logistic regression, decision trees, random forests, support vector machines, K‐nearest neighbors, extreme gradient boosting, artificial neural networks, CNN, LSTM, CNN‐LSTM to evaluate the performance of our proposed model. The evaluation metrics considered for the study are accuracy, precision, recall, and F‐1 score. The experimental analysis on multiple datasets exhibits that the proposed model performs the classification efficiently with an accuracy of 99.74% and 99.98%.