The exponential expansion of the Internet of Things (IoT) has fundamentally transformed the way people, machines, and gadgets communicate, resulting in unparalleled levels of interconnectedness. Nevertheless, the growth of IoT has also brought up notable security obstacles, requiring the creation of strong intrusion detection systems to safeguard IoT networks against hostile actions. This study investigates the utilization of fog computing architectures in conjunction with machine learning approaches to improve the security of the IoT. The UNSW-NB15 dataset, containing an extensive range of network traffic characteristics, is used as the basis for training and assessing the machine learning models. The study specifically applies and evaluates the performance of various models, including linear regression, Ridge classifier, SGD classifier, and ensemble learning. Furthermore, the findings indicate that these models are capable of accurately identifying intrusions, with success rates of 94%, 97%, 96.60%, and 96.50%, respectively. The Ridge Classifier demonstrates exceptional accuracy, highlighting its potential for effective implementation in IoT security frameworks. The results emphasize the efficacy of combining machine learning with fog computing to tackle the distinct security obstacles faced by IoT networks. In the future, our work will prioritize optimizing these models for real-time applications, improving their scalability, and investigating more advanced ensemble strategies to enhance detection accuracy. The project intends to enhance these areas to create a comprehensive and scalable intrusion detection system that can offer strong security solutions for the growing IoT environment. This will guarantee the integrity and dependability of linked devices and systems.