The Internet of Things (IoT) system has been a hot topic in recent years. Its operation is a system that stores data in data storage and is completed by the exchange of network information about things. Therefore, the security of information between network transmissions is very important. In recent years, the most likely cause of information security problems has been a distributed denial of service (DDoS) attack. In this paper, we proposed an autonomous defense system that combines edge computing with a two-dimensional convolutional neural network (CNN) to recognize whether the data server in IoT suffers from DDoS attacks and identify the attack mode. The accuracy of trained two-dimensional CNN is up to 99.5% and 99.8% for packet traffic and packet features training, respectively. A field experiment’s results show that the data server in the proposed system can effectively distinguish the difference between the DDoS attacks and the normal transmission to reduce the impact of DDoS attacks on the IoT data storage while it is under attack.