Now, the Cyber security is facing unprecedented difficulties as a result of the proliferation of smart devices in the Internet of Things (IoT) environment. The rapid growth in the number of Internet users over the past two decades has increased the need for cyber security. Users have provided new opportunities for attackers to do harm. Limited security budgets leave IoT devices vulnerable and easily hacked to launch distributed denial-of-service (DDoS) attacks, with disastrous results. Unfortunately, due to the unique nature of the Internet of Things environment, most security solutions and intrusion detection systems (IDS) cannot be directly adapted to the IoT with acceptable security performance and are vulnerable to various attacks that do not benefit. In this paper we propose an optimal secure defense mechanism for DDoS in IoT network using feature optimization and intrusion detection system (OSD-IDS). In OSD-IDS mechanism, first we introduce an enhanced ResNet architecture for feature extraction which extracts more deep features from given traffic traces. An improved quantum query optimization (IQQO) algorithm for is used feature selection to selects optimal best among multiple features which reduces the data dimensionality issues. The selected features have given to the detection and classification module to classify the traffic traces are affected by intrusion or not. For this, we design a fast and accurate intrusion detection mechanism, named as hybrid deep learning technique which combines convolutional neural network (CNN) and diagonal XG boosting (CNN-DigXG) for the fast and accurate intrusion detection in IoT network. Finally, we validate the performance of proposed technique by using different benchmark datasets are BoNeSi-SlowHTTPtest and CIC-DDoS2019. The simulation results of proposed IDS mechanism are compared with the existing state-of-art IDS mechanism and analyze the performance with respects to different statistical measures. The results show that the DDoS detection accuracy of proposed OSD-IDS mechanism is high as 99.476% and 99.078% for BoNeSi-SlowHTTPtest, CICDDoS2019, respectively.