Software-defined networking (SDN) technology enables and supports the 5G ecosystem, which is expected to handle a vast amount of sensitive data and provide connectivity to many users, making them more vulnerable to cyberattacks. Security measures, such as access control, encryption, authentication, and intrusion detection systems, must be implemented to protect network security against adversarial attacks. An intrusion detection system is a security technology designed to detect vulnerabilities in computer systems. Medium Access Control (MAC) addresses are required to identify and control access to specific devices on a network. Although there are various methods for intrusion detection, the most popular approaches have low accuracy. Therefore, a dual discriminator conditional sheep flock generative adversarial network-based intrusion detection system (IDS) in MAC-based SDN architecture is proposed to solve these issues and detect and prevent attacks. Initially, the 5G users authenticate with the help of the Four-Q-Curve algorithm. Next, the ideal switches are chosen to overcome the flow table overload using the univariate ensemble feature selection technique. Following this, a dual-discriminator conditional generative adversarial network (DC-GAN) is used to categorize selected features into normal, assault, and suspicious packets. The Sheep Flock Optimization Algorithm (SFOA) is used to optimize the DC-GAN. Then, the Growing Self-Organizing Map (GSOM) classifies the suspicious packets into normal and malicious packets. The experimental results show that the proposed method outperforms the existing methods in terms of accuracy, F1 score, sensitivity, and false alarm rate while ensuring low energy consumption and higher network throughput.